Jump to content

slyte33

Members
  • Posts

    137
  • Joined

  • Last visited

Everything posted by slyte33

  1. Makes sense...logical answers here... so storing a list isn't really a good way of doing 'anything' if theres better ways?
  2. I wasn't sure how much space it'd take, thanks for the info. You're right, but what if I wanted to use this for say, checking which users read a forum thread. If new post in thread update the list of ids to blank VS having to delete 1,000s of rows in "users_who_havent_read_thread" table; would that be efficient. Heck, is the second way I listed efficient for anything
  3. I didn't know how to phrase the title correctly.. I'm creating a friends list for players in my game. I could easily create a table and have fields "players_id" and "friends_id". so my table "friends" could be friends players_id | friends_id ---------------------------- players_id = 1 | friends_id = 2 players_id = 1 | friends_id = 11 players_id = 1 | friends_id = 6 players_id = 1 | friends_id = 64 but with 1,000 players each having 100 friends, that's 100,000 rows. ..or i could do this: friends players_id | friends_id ---------------------------- players_id = 1 | friends_id = (2)(11)(6)(64) with this code: $get_friends= explode(')(', substr($player['friends_id'], 1, -1)); foreach($get_friends as $friend_list) { $list_ids_query=$db->execute("select * from players where pID='".$friend_list[0]."'"); $friends=$list_ids_query->fetchrow(); if ($friends['id']!=$_GET['friendID']){$add_friend=1;}else{$add_friend=0;} } if ($add_friend==1){ $update=$db->execute("update friends set friends_id= CONCAT( friends_id, '(".$_GET['friendID'].")')"); }else{ //is already friend } I'm just wondering if that saves space, works more efficiently and if I'm doing it correctly to begin with. Thanks EDIT: Accidentally posted thread without finishing if you didn't get the rest hitman6003
  4. I got it working using your method. I made a new table "has_read_chat" and had it JOIN the table with message_id in table "chat". It's working very nicely, thanks!
  5. But then I cannot update the database for each player that visit the chat room. I need it to update based on the players ID because if I don't it will update the database for every player instead :/
  6. I've spent 3 hours trying to achieve this and decided to come for help I have tried exploding to insert each ID then using if hasread!=in_array(players_id,hasread)..can't seem to get it working correctly. I have a chatroom with tabs to change the room including user private messaging.. my chat table looks like this: user_id message_id chatroom_id message time_sent user_has_read Let's say you're in the general chat..when sending a message it will insert as chatroom_id=1 private messaging chat_id's are mt_rand'd but all open rooms appear at the top of the chat. Tabs at the top display chat rooms name and how many new chat posts since you last visited the page, I.E. [General (0) *viewing now*] [Trade (2)] [slyte33(5)] So basically, I need to update the "user_has_read" field which each player's ID that entered that chatroom where players_id is not in the field. user_has_read could be displayed like this (1)(5)(3) (users with ID 1,5,3 entered chatroom, so all messages unread for those users now become read) Any help would be greatly appreciated!
  7. Try this if ($ip == $test1 || $ip == $test2)
  8. I have a textbox to enter your username on my game.. As you type, the text is replaced with a php imagecreate using a TTF font with css positioning it in the textbox. the text-indent is set to -9999. I need to know if this is a good approach to making my game look more professional.. go to http://foarpg.com/game.php and simply click "Register", begin typing in the textbox Also how can I stop, using PHP ofcourse, the textbox from acting as if a slash ( \ ) is two characters even with stripslashes being used? Max char length is 12, but 6 slashes acts as 12 O.O
  9. Try changing your last line to <?php } ?> just incase your server doesn't support short tags
  10. I managed to get the login working & returning the right results. All I need now is how to get that session c=#. I checked my cookies, there is no session with the same session I have. I don't think it's a cookie.. i think it's just a validator to make sure you can't change their links or something. If you change the key in anyway it'll return to login screen + reset the key, no going back.
  11. I am trying to make a username availability checker on my website for the game runescape to see if a username is in use or not. The link to get the result is https://secure.runescape.com/m=displaynames/c=tjl0oh6Ehhs/check_name.ws?displayname=name If you click it, you'll notice you can't access the page without being logged in first. I'm trying to use curl to log the account in + get the session key (c=tjl0oh6Ehhs) because it's needed for the name checker page. I can't seem to figure out how to do this..here's my code though. Notice I haven't attempted to store the session key because I can't even get it to login yet :\ <?php $username = 'username'; $password = 'password'; $feedUrl = 'https://secure.runescape.com/m=weblogin/loginform.ws?mod=www&ssl=1'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $feedUrl); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_TIMEOUT, 30 ); curl_setopt($curl, CURL_HTTP_VERSION_1_1, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, 'username='.$username.'&password='.$password.'&dest=title.ws&mod=www&ssl=0'); curl_setopt($curl, CURLOPT_ENCODING, "gzip, deflate"); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); $feedContent = curl_exec ($curl); curl_close ($curl); ?>
  12. I'm clueless with java fairly good with PHP. How could i make this line an if else like you would with php listener.statusUpdated(i, "OK".equals(lines[0]) ? "AVAILABLE" : "NOT AVAILABLE"); Thanks
  13. Very smart..I've been trying to think of all kinds of ways to do this and you solved it that quick! Thank you!!
  14. So I'm making a game. The game has a village, you start at the center of the village. North,east,south and west of the village, for example, is "areas" you can travel to. These areas are stored in the database, with an INT as (travel_time). I need the travel time to be accurate based on where you're already at and where you plan to go. I've created a crappy example below..but it would better give an idea as to what I'm asking for: If you're in the center already, the travel time to "Battle2, Training1, Markets1 and Trading1 would all be the same. What if you are in "Training2" and want to travel to "Trading2". That would be a longer travel time. I'm not sure how to store these in the database to make a formula or something for travel time. This might be a little confusing, just ask me more questions if needed. Thank you for any help, it is much appreciated.
  15. Ok I did figure out a way to fetch the data and update the database with each players ID that viewed the new announcement. Now how would I check to see if 1 player's ID has been stored?
  16. I'm not too sure what that means :X If it means don't store it with a comma, I could do (1)(3) as my values being set. But if it means not to store it the way I wanted, how could I have each individual player be stored as if they read the announcement or not?
  17. What I'm trying to achieve is: I create a new announcement for my game. When players login the game they are right on the announcement page. The new announcements I want displayed in red, and once they've read it, the announcement would go back to normal color. Each player is specified by an ID. I want the database to update a TEXT with their ID. Like so: Player 1 reads it Player 2 doesn't Player 3 reads it so in the database the the "has_read" value would update the type "TEXT" to this: 1,3 After it's stored, how would I display it correctly, for example, (completely incorrect since the players ID isn't 1,3) if (announcements->has_read == players_id) { display red announcement }else{ display normal since they've read it } Any help would be greatly appreciated, I hope I made this easy to understand
  18. Weird I have no idea how it posted 3 times...lagged ctrl+v maybe Ok, level 1->2 = getting 500xp, total XP of 500 level 2->3 getting (500*1.5) xp , total xp = 500+750=1,250 total XP when reaching level 3 level 100 = 10,000,000 total XP when reaching level 100
  19. This might sound confusing, so I'll post a code for my example You have 100 levels to go through, each level needs a certain amount of EXPERIENCE to get to the next level. To hit level 100 you need that last 10,000,000th exp point. So [10,000,000/100] would be 100,000 EXP per level, correct? But I dont want getting level 2 to be so hard you need 100,000 EXP, off the start. I want it to get harder as you progress through your levels. Here's what I have and it equals a couple thousand from 10,000,000. $number=1; $num=99; for($x=2;$x<=99;$x++) { $xp2+=($number*250)+($x*250)*0.211; echo "<br>"; echo "Level: $x"; echo "- <b>".number_format($xp2)."</b>"; $tot+=$xp2; } echo "<br>"; echo "TOTAL: ".number_format($tot).""; echo stripslashes($message); This might sound confusing, so I'll post a code for my example You have 100 levels to go through, each level needs a certain amount of EXPERIENCE to get to the next level. To hit level 100 you need that last 10,000,000th exp point. So [10,000,000/100] would be 100,000 EXP per level, correct? But I dont want getting level 2 to be so hard you need 100,000 EXP, off the start. I want it to get harder as you progress through your levels. Here's what I have and it equals a couple thousand from 10,000,000. $number=1; $num=99; for($x=2;$x<=99;$x++) { $xp2+=($number*250)+($x*250)*0.211; echo "<br>"; echo "Level: $x"; echo "- <b>".number_format($xp2)."</b>"; $tot+=$xp2; } echo "<br>"; echo "TOTAL: ".number_format($tot).""; echo stripslashes($message); This might sound confusing, so I'll post a code for my example You have 100 levels to go through, each level needs a certain amount of EXPERIENCE to get to the next level. To hit level 100 you need that last 10,000,000th exp point. So [10,000,000/100] would be 100,000 EXP per level, correct? But I dont want getting level 2 to be so hard you need 100,000 EXP, off the start. I want it to get harder as you progress through your levels. Here's what I have and it equals a couple thousand from 10,000,000. $number=1; $num=99; for($x=2;$x<=99;$x++) { $xp2+=($number*250)+($x*250)*0.211; echo "<br>"; echo "Level: $x"; echo "- <b>".number_format($xp2)."</b>"; $tot+=$xp2; } echo "<br>"; echo "TOTAL: ".number_format($tot).""; echo stripslashes($message); Output: Level: 2- 356 Level: 3- 764 Level: 4- 1,225 Level: 5- 1,739 Level: 6- 2,306 Level: 7- 2,925 Level: 8- 3,597 Level: 9- 4,322 Level: 10- 5,100 Level: 11- 5,930 Level: 12- 6,814 Level: 13- 7,750 Level: 14- 8,739 Level: 15- 9,780 Level: 16- 10,875 Level: 17- 12,022 Level: 18- 13,222 Level: 19- 14,474 Level: 20- 15,780 Level: 21- 17,138 Level: 22- 18,549 Level: 23- 20,013 Level: 24- 21,530 Level: 25- 23,099 Level: 26- 24,721 Level: 27- 26,396 Level: 28- 28,124 Level: 29- 29,904 Level: 30- 31,738 Level: 31- 33,624 Level: 32- 35,562 Level: 33- 37,554 Level: 34- 39,598 Level: 35- 41,695 Level: 36- 43,845 Level: 37- 46,048 Level: 38- 48,304 Level: 39- 50,612 Level: 40- 52,973 Level: 41- 55,387 Level: 42- 57,853 Level: 43- 60,372 Level: 44- 62,944 Level: 45- 65,569 Level: 46- 68,247 Level: 47- 70,977 Level: 48- 73,761 Level: 49- 76,597 Level: 50- 79,485 Level: 51- 82,427 Level: 52- 85,421 Level: 53- 88,468 Level: 54- 91,568 Level: 55- 94,721 Level: 56- 97,926 Level: 57- 101,184 Level: 58- 104,495 Level: 59- 107,859 Level: 60- 111,275 Level: 61- 114,745 Level: 62- 118,267 Level: 63- 121,842 Level: 64- 125,469 Level: 65- 129,150 Level: 66- 132,883 Level: 67- 136,669 Level: 68- 140,507 Level: 69- 144,399 Level: 70- 148,343 Level: 71- 152,340 Level: 72- 156,390 Level: 73- 160,493 Level: 74- 164,648 Level: 75- 168,856 Level: 76- 173,117 Level: 77- 177,431 Level: 78- 181,797 Level: 79- 186,216 Level: 80- 190,688 Level: 81- 195,213 Level: 82- 199,791 Level: 83- 204,421 Level: 84- 209,104 Level: 85- 213,840 Level: 86- 218,629 Level: 87- 223,470 Level: 88- 228,364 Level: 89- 233,311 Level: 90- 238,311 Level: 91- 243,363 Level: 92- 248,469 Level: 93- 253,627 Level: 94- 258,838 Level: 95- 264,101 Level: 96- 269,418 Level: 97- 274,787 Level: 98- 280,209 Level: 99- 285,683 TOTAL: 10,002,479
  20. Hello everyone! I cant seem to figure this out... here's a code for example: $number = "20"; echo "2"; echo "0"; If you're wondering why I need something like this it's because I'm making the number show in a php image, but instead of outputting numbers 0-99, I could split the number 20 into "2" and "0" to output only numbers 0-9 Any help would be greatly appreciated
  21. Hello, I am having trouble with getting the total of the value of the two text fields(labeled price1, price2). If anyone could help me add them that'd be greatly appreciated, thanks <script> function price(sum,val) { e = document.getElementById(sum); document.getElementById(val).innerHTML = e.value; } </script> Amount: <input type="text" id="price1" value="0" onkeyup="price('price1','price1_price')"> <b>First Price</b> $<span id="price1_price">0</span><br> Amount: <input type="text" id="price2" value="0" onkeyup="price('price2','price2_price')"> <b>Second Price</b> $<span id="price2_price">0</span>
  22. I don't really need to post any code to get help with this, but I can explain what I am talking about. I've heard using onkeyup could cause problems, but I'm unsure on this. Basically, i have a registration form, but let's just concentrate on a simple "Username" field and a "Register" button to keep this simple. Let's say the username must be at least 4 characters long. Using onkeyup: <input type='text' id='username' name='username' onkeyup="validate();"><span id=error1></span> The user enters a username, beside the usernames textfield is a <span id=error1> tag. onkeyup event obviously will update the span id as the user types. If the username is less than 4 characters, it will display "Too short, 4 characters minimum". Using onclick: <input type="submit" onClick="validate();" value="Register"> You click register... it updates the span tag if there are any errors, unlike the onkeyup event which does it without clicking submit. So my question is, which would be a better choice? Or is it whatever I'd like to use? I've just heard about onkeyup causing problems with some people. All help would be much appreciated
  23. I sent you a PM. I am using server side validation also, i'll just give the link to the webpage. When visiting, click Create character and type only in the username box. the only username taken is "test", which is where the error occurs. http://foarpg.com/game/login/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.