boionfire81 Posted April 24, 2016 Share Posted April 24, 2016 (edited) So, I found this mod at http://makewebgames.io/forum/ga...spital-explore and I decided to update it a bit. Instead of using energy and restricting the amount of attempts, I decided to use stamina with unlimited attempts (as there are no medical items for healing, if you get hurt your hurt! or have insurance for healing and/or credits). I also added the ability to find items with a random amount, and a bribe feature. So here it is. Real simple. 1 file. 1 sql. 1 line for cron_day. Replace the numbers 87 & 88 with your item id's. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add to cron_day You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Feedback is welcome. But just remember I basically read my first line of php only a month ago. Edited April 24, 2016 by boionfire81 1 Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted April 24, 2016 Share Posted April 24, 2016 Looks good, but, $result 6 does not check for if the player has enough cash on them for the bribe. They'll go negative cash if they have none. Someone can correct me if I'm wrong, but I think its a better idea to use mt_rand() over rand(). Also, in $result == 2, I think it may be smart to resolve the item_id to a variable, for easier editing. I understand you were only fixing bugs from an existing mod, but, still, a little advice might help you when it comes to your own mods. :D -TMG 1 Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted April 24, 2016 Author Share Posted April 24, 2016 Yeah. I was trying to think how to solve that. I can check the cash, but no idea how to properly add that. And I'll add the items to a variable. Just had to update to use the cron. Without steps you can just keep going and time added has no effect. So when time is added it simply blocks you from exploring anymore that day. So a simple roll of the dice. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 24, 2016 Share Posted April 24, 2016 ... Someone can correct me if I'm wrong, but I think its a better idea to use mt_rand() over rand... This is debatable and I believe Guest knows a great resource to show a comparison of rand vs mt_rand. But I believe with such a small range you won't really see a huge difference in random number generation with mt_rand. And to test it with rand just change the mt_rand to rand Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 24, 2016 Share Posted April 24, 2016 Nevermind, the forum broke my link since I am mobile Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 25, 2016 Share Posted April 25, 2016 Here is a gist that you can copy and run through phpfiddle: Gist Just change the iterations variable to suit and also the $method var can be either mt_rand or rand Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 25, 2016 Share Posted April 25, 2016 http://en.code-bude.net/2013/01/06/php-rand-vs-mt_rand-what-is-more-accurate-what-is-faster/ http://golearnphp.com/php-rand-vs-mt_rand-and-openssl_random_pseudo_bytes/ Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted April 25, 2016 Share Posted April 25, 2016 I can check the cash, but no idea how to properly add that You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Thanks for the read, [uSER=65530]Coly010[/uSER] ! Very informing. I kinda thought the same, [uSER=68711]KyleMassacre[/uSER], haha. :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.