Jump to content

Monkuar

Members
  • Posts

    987
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Monkuar

  1. Just curious, how would you go about rendering and storing this in a database. For example a simple small maze. With each keypress, the user is moved up,down,left,right like 1 inch. (1 block). Which is easy to do with jquery, etc. But how would go about storing the data in a databse (can update the position per update or using websockets), but essentially so maphacks are impossible and everything is saved/read from the server. Would the storage data be something like [0,0,0,1,0,0,1,1,1,1,0,1] I imagine or what?
  2. Thanks, I bookmarked this. I switched away from socket.io as I believe my attack system will be more based upon just turn based activities. I really want to incorporate attack speed, but have no idea how with socket.io or PHP. I have a feeling it would be easier with socket.io, but that thing loops the mysql database intensively too. (I'm sure I'll use socket.io for a chat system, but nothing more). Here is an example of my game with the loot animation / explosion: I made design edits to the left toolbar and top, disregard those for now Edit: I'll be pushing those temporary items into a temp variable session as well, so there is TONS of loot for the user to choose from. Similar to path of exile or Diablo 2, when you're killing a pack of mobs.
  3. I moved to socket.io for my attack monster system. Problem is I do not like how the serverside scripting language has to be written in javascript. Do you know any PHP modules that are available so we can use PHP as a WebSocket backend instead? I really dislike this javascript stuff, plus I would have to convert my whole attackmob.php file as well into javascript. No thanks.
  4. Which module let's us use our socket.io server written in PHP? Cause I am using socket.io right now, and I hate javascript. Much rather use PHP's language style.
  5. Never thought about the multiplayer shared loot option. I'm not at the multiplayer stage yet though. I do want to add PvP, but I am not using socket.io, so it's mostly real time turn based via AJAX requests. I guess I could store the item data in Json format in a field called "tempdatastorage" in my characters table, and just use that. One extra UPDATE query per mob kill might hinder performance though, but we'll see. Thanks for the tips.
  6. Yeah, that's how it works. The system checks the users cookie to validate it against the users table to authenticate them. But my question is for loot management. I need to store a huge amount of loot that drops from monsters. Using a php session temporary variable would work, but I need it to NOT change when someone logs in on a different browser. That's why I need to use session_id('sessionidhere') before every session_start right? (user is still authenticated ofc but I do not want to store the temporary data in a mysql column, maybe I should?)
  7. My users table on my forum is what gets checked everytime a user refreshes to authentic them. When killing a monster, I want users to be able to grab items and it will insert them into their inventory. I have this part done already. But I want them to have a plethora of loot available that drops from a mob, and once they click the specific item it will then be inserted into their inventory (server database). I'm storing the Temporary Item Data in a PHP session variable. Once they kill a monster, the Tempory Item Data variable get's filled with the specific loot and then the user will have the option to choose what items they want to go into their inventory. My problem is, if they open the game in a new browser they will get a new session id. Since I'm authenticating them through my users table, can I just make a new column called session_id and just use php's session_id() before every session start so no matter which browser they're on they will have the same session right? You might think, well why dont you just store the temporary item data in a mysql field or rows instead? I want to try to minimize mysql usage as much as possible, as players will be CLICKING a lot to kill mobs, it is most likely very mysql demanding as well and I want to be intuitive about it. I just want to use temporary session data for the loot. Then once the user clicks an item they want, it is EXTRACTED from their tempory item data variable, then I will use MYSQL to insert those items into their inventory. Is this a fair and intuitive way to do temporary data for item loot? For example, in action RPG's like Path of Exile you kill a group of mobs and you see a shit ton of loot on the floor. (I imagine that loot is just temporary waiting for someone to pick it up right?) Once you do pick it up, mysql is then called to save it right? That's the same logic I have with my web based game. Is using a session variable to store that temporay loot. Is this an intuitive way to do this, or are there other ways?
  8. Thanks. I've just gotten to the point where I don't think I'll ever truly master PHP. And sometimes after I post my questions (it helpes me anaylyze my code while literally writing out my question) I can answer it like 1-2 hours later. And then, I feel kind of guilty knowing Barand, or others are wasting their time on my dumb question. However, I do appreciate the support ,but I feel too guilty now asking all these questions sometimes. I've been here long enough and quite frankly, I should have PHP mastered by now, but I just rarely find time to code anymore. Used to be a lot easier back in the day with no college, etc. I would actually feel less guily about myself if I were to slip them a few donations. Edit: And I'm still using global, never will use pdo, etc. I'm juist weird like that, but whatever. (That even adds to the guiltyness)
  9. Ok. I increased the range to thousandths now: $prob = number_format(mt_rand(1,100)/100, 2) ; to: $prob = number_format(mt_rand(1,100)/100, 3) ; 2->3> So now when I'm iterating in my loop testing probability it shows: Which is now in the thousandths place, but even after 5000 + iterations in the loop, I still cannot get that 0.005% to spawn, just bad RNG luck or is the probability to high? Wait, Edit: I changed it to: $prob = number_format(mt_rand(1,1000)/1000, 3) ; And it looks like it's working now.
  10. Stupid Question, and it might even be as simple as adding a zero, but I cannot figure it out. $prob = number_format(mt_rand(1,100)/100, 2) ; $q = $db->query("SELECT * FROM rpg_monsters WHERE monster_zone = 1 AND chance >= $prob ORDER BY chance,rand() LIMIT 1"); As you can see this works out perfectly. But only one issue. I want that 0.05 to be in the thousandths of percent: 0.005%. So it's a higher probability. But if I change it to 0.005, it never shows, even with iterations over 5000 in a for loop? I feel like I need to do something with my mt_rand? I need to simply move a decimal over someplace, but not sure where.
  11. This actually looks more unified and simpler... I'll try this out, thanks. And to add even more probability to it (increase the odds), I could change the , 2) to ,3) to add a decimal place correct? I'll only do that for really unique items though, not sure if I'll do it for just spawning monsters. Edit: I even added it inside a for loop and changed the 0.10 to 1.00 except for Chris Wilson because it wasn't returning any data. for ($x=0; $x<=100; $x++) { $prob = number_format(mt_rand(1,100)/100, 2) ; echo $prob; $q = $db->query("SELECT * FROM rpg_monsters WHERE monster_zone = 1 AND chance >= $prob ORDER BY chance LIMIT 1"); $monsterdata = $db->fetch_assoc($q); var_dump($monsterdata); } This is a good way to test probability too I assume? I get roughly 4% Chris Wilson each time. And I changed the Goblin Attacker to 0.50 (50%) and he's showing up more than others. This is awesome, love probability and the randomness. And I'm just using that inside that for loop for testing, will never use that on production lol.
  12. Was just wondering if it's okay to make simple donations to other users on the forum. Just out of generosity. If true, if I want to make a donation to a specific user how would I go about doing it? Just pm them asking for their paypal?
  13. $rate = (double) '0.50'; // 3% $max = 1 / $rate; // 100 if (mt_rand(0, $max) === 0) { $uniquechance = true; } if ($uniquechance == true){ $q = $db->query('SELECT * from rpg_monsters where monster_zone = 1 AND monster_type="Unique" '); }else{ $q = $db->query('SELECT * from rpg_monsters where monster_zone = 1'); } while ($monsterdata = $db->fetch_assoc($q)) { $monsterarray[] = $monsterdata; } Boom, I need to keep this shit simple.. lol Sorry about that Barand, I was just over-thinking!
  14. Okay, scratch a bit of my first post. So, I have these values in my array (They are in the row "chance") array (size=4) 0 => string '0.10' (length=4) 1 => string '0.04' (length=4) 2 => string '0.10' (length=4) 3 => string '0.10' (length=4) Theoretically, the 10%'s will be spawned first over the 4% one right? So, I'm trying to figure how to do that with: $rate = (double) '0.03'; // 3% $max = 1 / $rate; // 100 if (mt_rand(0, $max) === 0) { // chance < $rate echo "Only 3% probability, holy cow!"; } I need to change that '0.03' to the values in my array: ( 0.10, 0.04, 0.10, 0.10 ) dynamically so I can get which array should be chosen if that makes sense? I'm just trying to make monsters have different chances to spawn over other monsters. For a example, a unique monster should be at 0.04% (4%) to spawn, as compared to a Normal White monster 0.10 (10%). The unique needs to have a lower probability. I am a bit lost myself.
  15. Here is my code: //Grab all the monster in Monster zone 1 $q = $db->query('SELECT * from rpg_monsters where monster_zone = 1'); while ($monsterdata = $db->fetch_assoc($q)) { $monster_chance[] = $monsterdata; } and my var_dump: array (size=4) 0 => array (size= 'monster_id' => string '1' (length=1) 'monster_name' => string 'Merman' (length=6) 'monster_level' => string '1' (length=1) 'monster_type' => string 'Normal' (length=6) 'monster_hp' => string '10' (length=2) 'monster_dmg' => string '1' (length=1) 'monster_zone' => string '1' (length=1) 'chance' => string '0.10' (length=4) 1 => array (size= 'monster_id' => string '2' (length=1) 'monster_name' => string 'Chris Wilson' (length=12) 'monster_level' => string '2' (length=1) 'monster_type' => string 'Unique' (length=6) 'monster_hp' => string '25' (length=2) 'monster_dmg' => string '3' (length=1) 'monster_zone' => string '1' (length=1) 'chance' => string '0.04' (length=4) 2 => array (size= 'monster_id' => string '3' (length=1) 'monster_name' => string 'Seaman Warrior' (length=14) 'monster_level' => string '2' (length=1) 'monster_type' => string 'Magic' (length=5) 'monster_hp' => string '20' (length=2) 'monster_dmg' => string '2' (length=1) 'monster_zone' => string '1' (length=1) 'chance' => string '0.10' (length=4) 3 => array (size= 'monster_id' => string '4' (length=1) 'monster_name' => string 'Goblin Attacker' (length=15) 'monster_level' => string '2' (length=1) 'monster_type' => string 'Normal' (length=6) 'monster_hp' => string '15' (length=2) 'monster_dmg' => string '2' (length=1) 'monster_zone' => string '1' (length=1) 'chance' => string '0.10' (length=4) As you can see, the Unique Monster (Chris Wilson) is the lowest chance at only 4%. And all the other mobs at at 10% chance to spawn. Here is my code for probability: $rate = (double) '0.03'; // 3% $max = 1 / $rate; // 100 if (mt_rand(0, $max) === 0) { // chance < $rate echo "Only 3% probability, holy cow!"; } My problem is, I'm a bit lost as how to get my probability code inside a loop and having the dynamic $rate correspond to my "chance" row. Although, I could just use ORDER BY rand() in mysql, it wouldn't let me use any probability and chances... hmmm
  16. Congratulations!
  17. Thanks Barand, that worked. Frank_b, not sure if I need that type of sortment at the moment. The current way checks only if one is out of line (from the range(1,9) then it error's out. But in the future, if I need to sort the Id's for a specific case, I'll use your example. Thank guys, been forever since I've posted here.
  18. For example for my Skill Tree: array (size=9) 0 => array (size=2) 'Skill_Id' => string '1' (length=1) 'Skill_Points' => string '0' (length=1) 1 => array (size=2) 'Skill_Id' => string '2' (length=1) 'Skill_Points' => string '0' (length=1) 2 => array (size=2) 'Skill_Id' => string '3' (length=1) 'Skill_Points' => string '0' (length=1) 3 => array (size=2) 'Skill_Id' => string '4' (length=1) 'Skill_Points' => string '1' (length=1) 4 => array (size=2) 'Skill_Id' => string '5' (length=1) 'Skill_Points' => string '1' (length=1) 5 => array (size=2) 'Skill_Id' => string '6' (length=1) 'Skill_Points' => string '1' (length=1) 6 => array (size=2) 'Skill_Id' => string '7' (length=1) 'Skill_Points' => string '0' (length=1) 7 => array (size=2) 'Skill_Id' => string '8' (length=1) 'Skill_Points' => string '1' (length=1) 8 => array (size=2) 'Skill_Id' => string '9' (length=1) For the Skill_Id, it must be in order when checking server side. 1 through 9. (or 9 can be changed by me whenever). So, I have: $skillrange = range(1,$amountofskills); Which will output: array (size=9) 0 => int 1 1 => int 2 2 => int 3 3 => int 4 4 => int 5 5 => int 6 6 => int 7 7 => int 8 8 => int 9 But, how do I check this order from my original array? I need to check My Skill_ID values in order from my original array and make sure they are 1 through 9. (So a user cannot tamper the data) Edit: I've come up with this solution since making this thread: $array1 = $skillidarray; $array2 = $skillrange; if (!empty(array_diff_assoc($array1, $array2))){ echo "Your skill tree data is out of order, please report this to an administrator."; } Something like this would work right?
  19. Lol, holy crap. Can't this all be solved with $_SESSION? (Storing it in session data, then submitting it all to db after xxx seconds/etC?) Same logic as old classic RPG games did right? (Except it was in buffer)
  20. I cant even switch to the new beta site on php.net no option to. I think they reverted everything back lol Edit: looks like you have to be onhttp://www.php.net/manual/ to change it to beta. The font looks absolutely terrible on my Chrome. I don't know why they use that font, it's all smushed and ugly: And no, it's not my computer, no other website has the font style like this.
  21. Yeah, that is my issue. How else can you store the data temporary unless using mysql field? I might be a bit lost, I apologize. I just want to know how those games store their data into "WHAT" then they update it what evey 2-3 seconds? This is where I am lost, what exactly do they store it in? MYSQL route is not what im looking for as in I want someone to beable to farm/kill mobs faster instead of waiting for each ajax request? Are you talking about having a file for each user's character and storing data in there on the server? Isn't fwrite slower than mysql? (Isn't a TON of fwrites gonna be same problem im having as I do with MYSQL) Because I know for Diablo 2, if u get a item, or add a skillpoint or lvl up your d2 filed is saved. So I am assuming they used the http://www.cplusplus.com/reference/cstdio/fwrite/ each time a user kills a mob or gains a item orupdates inventory. Wouldn't that just rape the server as in compared to doing it MYSQL? both would rape the server in my opinion.
  22. Sorry for the late reply, I thought you ditched the topic The thing about the cookie issue is, it's so EASILY editable. As in compared to program memory or whatnot [alot hard to use a cheat engine/etc] as in-compared to just downloading some cookie editor for firefox/etc. Simple issue I have is.... I have a full inventory system set up with jquery ondrag/drop to update each user_items position column. And I have it spitting it out from PHP to show which inventory slot the item was moved too. My theory is: Instead of each "OnDrop" method the users uses to drag each item on to each slot, it does a $.POST to update it (ajax) in the background and spits out a "Successfully Moved" message. To do this w/o using that ajax, I would need to store HUGE data in the cookie or whatnot then have a javascript timer running every 2-3seconds that just updates the user's character? [Or 1 update query] This would make performance go up by TEN fold, because instead of doing a ajax request on each time the user moves the item, the global save time via 2-3 seconds will update it. The downfall is, if the user is not-active on the browser/session it will do useless updates. I could always timeout a user though after xx seconds ofcourse. Is this kind of what you mean? Problem is the user's inventory is extracted from a different table than the main rpg_users table. so I guess I could just set cookies for each function the user is doing, and if it's =1 update that particular/correct database?
  23. What kind of global store do you mean? Like similar to how Diablo 2 does it with saved character files?
  24. "I would imagine (but have no pratical experience/knowledge) that a game server most likely handles a lot of the operations/changes that need done in-memory and has some kind of background thread which will periodically save changes to the database. That way it would be able to service all the clients quickly without waiting on the database." This is what Kicken said about updating and stuff via the client for a MMO. What about doing this same logic via Javascript/PHP? How would we temporary save this type of game data and do periodic updates so we don't get any hackers/exploiters? In other words I use a "Attackmob" function each time a user clicks "attack" to swing their sword or hit a monster. This function queries 3 queries and spits out data via AJAX and appends it to the page. [Monster loss of life/etc] So it seems like it's dynamic gameplay. My issue is, is there a way to scratch this ajax stuff temporary while the user is attacking the mob and then once the mob is dead or something, store the data in a temporary array or something then submit it? So we can proccess the mob actions client side [it's a turned based game] for PVP it would be different I know. Problem is, if someone can look at the source code of the page and see how we store this stuff, it's easily hackable/exploitable. [not so much via .exe's and mmorpg's] they have tools to stop looking/reading at memory/etc. But not so much with Javascript, it's really anyone can see the full source eh? Any thoughts guys? Edit: Another issue is the monster's damage is stored in a mysql field, same for it's "Current Health" and other stuff, it would be very easy for a hacker/exploiter to manipulate this if done in javascript. Or I could load up all the server details with javascript and make the "clean" "non-hacking" user play the game with the javascript variables.... It would speed up the process and be faster, but then I could just check if those data's changed via server side [if they decided to hack] and then check it server side each time. This wouldn't really work because of a monsters "Current Health" needs to be saved in a db no matter what... hmmmmmmm
  25. Yeah, well 200ms is mostly the time the user has to wait per ajax request. (Server lag) and I disable the user to attack via server side with php sessions and javascript 1 time each 2 seconds [so I can optimize queries and save em better] But now that I got this cool socket.io stuff, I'm thinking of dodging all this "2 second" per attack and just let the user click click click click click as fast as he needs and also I could put in Attack Speed % too. [Would need to validate it somehow serverside ofcourse, not sure how] but would be easier to do it with socket.io. For example, user has 20% attack speed, he could press the attack button faster than someone with 10% attk speed [like 300ms faster] or something lol iuno. [it's just a text based game, nothing fancy like swinging swords or whatnot] But im really looking forward for the chat system now, since I never knew we don't need to store/update them in mysql. [Can just be data over the connection] My problem is, what if a user accidentally closes the browser and comes back? all the data and chat logs will be gone, I need a temporary solution to hold like the last 10-20 lines in a cookie or something. [same logic as if ur character goes to the character selection screen and comes back] if all your whispers or whatever is gone, it would seem weird :/
×
×
  • 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.