Jump to content

Monkuar

Members
  • Posts

    987
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Monkuar

  1. 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.
  2. 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?)
  3. 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?
  4. 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)
  5. 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.
  6. 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.
  7. 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.
  8. 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?
  9. $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!
  10. 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.
  11. 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
  12. 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.
  13. 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?
  14. Well, if u code for a living u could prob get the free classroom license lol Just say your a teacher
  15. Yeah but I don't got time to edit/fiddle around some editing program, I just right click my files, notepad++ and go, no need to mess around with colorizing stuff. Notepad ++ is already colorized every language onclick from the language dropdown menu Plus PHPStorm is bloated :/ and costs $.. http://www.jetbrains.com/phpstorm/buy/index.jsp
  16. PHPStorm is a joke unless you like unreadable rainbow colors. Notepad ++ is clean and has plenty of plugins to support it. Been using it since I was like 15
  17. View Counters OP lol

  18. not a animal abuser..

  19. Loving the new boards

  20. yeah it probably depends I guess who is hosted with them or whatnot, but you have see, that guy got null routed for 24hours and was trying to get customer service to help him and get information from the attack and was denied plenty of times, that == horrible customer service i know and agree with you. your experience with them are probably great and they might be a good company but all companies have weaknesses and stuff. the point i was trying to make is that Nyphrex just cant come in here and say "Hey This hosting provider is great!" and say "It was Linode!" w/o any sauce or anytype of review or confirmation that he actually has sites hosted with them, which indeed makes his point completely useless, until I stepped in and gave him a full out negative review, just proving my point that he should atleast make an effort to explain "WHY" that host is good. (forgive my grammar...) Now, if that user had a "GURU" tag or something to show proof that he was reputable or known , then yeah I wouldn't of replied, but someone just cannot come in here say "OH this hosting company is great!" w/o any sauce or legitimate review/etc/etc...
  21. Linode? Overpopulated crowded as hell with 0 customer service? Sauce: http://www.lowendtalk.com/discussion/4706/why-linode-sucks-a-personal-rant/p1
  22. FileZilla is #1
  23. oops, I meant where the aces = 11 if the total value is less than 21 or whatever, that's the only feature i don't have working, it's 100% serverside and everything works, pikachu what u mean?
  24. i've created a blackjack game, can u add me to the list too? it just doesn't support jokers yet, but does work with a mysql db for security. (no sessions, purely serverside) pretty good too. dealer stands on 17's, hit stand/run/etc.
  25. please use mysql_real_escape_String nn hackers
×
×
  • 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.