danman24 Posted May 16, 2014 Share Posted May 16, 2014 Hey evertone. ive been trying to make a property that will randomly drop crystals to the user as they play. i havnt had any luck messing around with it. is there anyone willing to help out? im not even sure how to go about doing it really. still new to coding. if youre not willing to help please dont leave smart (BLEEP) comments. Quote Link to comment Share on other sites More sharing options...
Script47 Posted May 16, 2014 Share Posted May 16, 2014 Well, I'm not sure what you mean by property, but take a look at rand(); use that for the random number of crystals you would like to give. Then have a query which updates the users crystals and add on the random amount. So something like this: // Will give a random number between 1-5 $random = rand(1, 5); // The query to update the users, the field may not be called crystals (I'm not sure). Make sure you have the "WHERE" or you will update everyone. $updateCrystals = $db->query("UPDATE `users` SET crystals=crystals+$random WHERE userid=$userid"); Other than that, I think you should know how to add you own things. Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted May 16, 2014 Share Posted May 16, 2014 sounds like you need something like a hourly rewards module. I don't really see why you would want houses to drop random crystals # In case you want to set a different type of prices for houses if($ir['house'] > 1 && $ir['house'] < 10) { # Lets set a chance so the user doesn't always get crystals $chance = rand(1,1000); if($chance == 1) { # As kyle says sets a random amount of crystals from 5-10 $amount = rand(5,10); $db->query("UPDATE `users` SET `crystals` = `crystals` + '$amount' WHERE `userid` = '$userid'"); } else if($chance == 25) { $amount = rand(1,2) { $db->query("UPDATE `users` SET `crystals` = `crystals` + '$amount' WHERE `userid` = '$userid'"); } else if($chance > 800) { $amount = rand(7,6) { $db->query("UPDATE `users` SET `crystals` = `crystals` + '$amount' WHERE `userid` = '$userid'"); } } else if($ir['house'] > 9) { # code goes here } Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted May 16, 2014 Share Posted May 16, 2014 sounds like you need something like a hourly rewards module. I don't really see why you would want houses to drop random crystals # In case you want to set a different type of prices for houses if($ir['house'] > 1 && $ir['house'] < 10) { # Lets set a chance so the user doesn't always get crystals $chance = rand(1,1000); if($chance == 1) { # As kyle says sets a random amount of crystals from 5-10 $amount = rand(5,10); $db->query("UPDATE `users` SET `crystals` = `crystals` + '$amount' WHERE `userid` = '$userid'"); } else if($chance == 25) { $amount = rand(1,2) { $db->query("UPDATE `users` SET `crystals` = `crystals` + '$amount' WHERE `userid` = '$userid'"); } else if($chance > 800) { $amount = rand(7,6) { $db->query("UPDATE `users` SET `crystals` = `crystals` + '$amount' WHERE `userid` = '$userid'"); } } else if($ir['house'] > 9) { # code goes here } Ummm...... Thats not me :p that would be [MENTION=69670]Script47[/MENTION]. Yes I know our avatars look exactly the same haha Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted May 16, 2014 Share Posted May 16, 2014 Ummm...... Thats not me :p that would be [MENTION=69670]Script47[/MENTION]. Yes I know our avatars look exactly the same haha Yep haha stupid me yes your avatars are very confusing hehe but owell comment tag can be edited :P Quote Link to comment Share on other sites More sharing options...
wrux Posted May 16, 2014 Share Posted May 16, 2014 Not tested it but this in theory should work (just place it in your header.php somewhere I guess): <?php // ID of the property that gives the crystals $property_id = X; if($ir['house'] === $property_id) { // User has the property that has random drops // generate two random numbers and check if they match $chance1 = mt_rand(1,10); $chance2 = mt_rand(1,10); $crystal_gain = 3; if($chance1 === $chance2) { // got the crystals so update user reccord $sql = sprintf("UPDATE `users` SET `crystals` = `crystals` + %u WHERE `userid` = %u;", $crystal_gain, $userid); $db->query($sql); } } ?> Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted May 16, 2014 Share Posted May 16, 2014 Ive sent you my skype so if you require help with a few things im here. http://makewebgames.io/showthread.php/40980-Hourly-Reward - A module by Newbie, simple but effective and is pretty much what you are asking for here. If you want this to work with the propertys then it shouldn't be hard to insert. Otherwise id suggest keep this module as it is but neaten it up a little. Quote Link to comment Share on other sites More sharing options...
Script47 Posted May 16, 2014 Share Posted May 16, 2014 Ummm...... Thats not me :p that would be [MENTION=69670]Script47[/MENTION]. Yes I know our avatars look exactly the same haha Yeah haha. Kyle has the smaller beard. :D I would think instead of giving him full codes or links to other modules, people would encourage him to code it himself. So merely directing them in the right direction, just my opinion though. Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted May 16, 2014 Share Posted May 16, 2014 Ive sent you my skype so if you require help with a few things im here. http://makewebgames.io/showthread.php/40980-Hourly-Reward - A module by Newbie, simple but effective and is pretty much what you are asking for here. If you want this to work with the property then it shouldn't be hard to insert. Otherwise id suggest keep this module as it is but neaten it up a little. ah you found my old module yep its pretty basic if my memory serves me correctly someone did a recoded version of it Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted May 16, 2014 Share Posted May 16, 2014 Ah yes thats the recoded version Steven :-) Quote Link to comment Share on other sites More sharing options...
danman24 Posted May 19, 2014 Author Share Posted May 19, 2014 nice guys! ive always tried coding things on my own i was just having trouble with this one. i was trying to use {$ir['maxwill']} and couldnt get it to work the way i wanted it to. im not looking for full codes at all just more guidance. also i think giving the user a chance to NOT get random drops was eluding me. im really new to random functions. Also the reason i want random crystal drops for a property is because its for my game's top property which will be a donation items. :) I thank you all for your assistance. This website has lived up to its reputation for great people. 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.