dbeckerton Posted July 24, 2013 Posted July 24, 2013 I was hoping someone could spend just a few minutes helping me or possibly giving me a code, i want to have some type of link that a user can click in which it costs say 100 crystals and a user gets 5 or 4 or whatever amount of Random items from the game is this possible and could someone help me do this Quote
jcvenom Posted July 24, 2013 Posted July 24, 2013 I was hoping someone could spend just a few minutes helping me or possibly giving me a code, i want to have some type of link that a user can click in which it costs say 100 crystals and a user gets 5 or 4 or whatever amount of Random items from the game is this possible and could someone help me do this yes it is i can help you also will this be daily or just once Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 yes it is i can help you also will this be daily or just once i was planning for it to be a whenever you want it kind of thing! :) if you get me Quote
KyleMassacre Posted July 24, 2013 Posted July 24, 2013 i was planning for it to be a whenever you want it kind of thing! :) if you get me Just some advice so take it as you will: But dont give your players stuff "whenever they want" it will hurt in the long run and inflate economy, that is one of the worst things to happen to a lot of games Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 dont worry mate ive thought about it quite well, i did economics at a-level, im sure ill figure out a system Quote
Razor42 Posted July 24, 2013 Posted July 24, 2013 For the link do something like: <a href='reward.php'>Reward</a> Then create a file called reward and add something along the lines of.... <?php include_once 'globals.php'; echo "<h2>Reward</h2>"; $creward = mt_rand(1,100); //amount of crystals they will recieve between 1 & 100 $mreward = mt_rand(1,100); //amount of money they will recieve between 1 & 100 $db->query("UPDATE users SET money=money+$mreward, crystals=crystals+$creward WHERE userid=$userid"); echo "You recieved {$creward} crystals and \${$mreward}."; $h->endpage(); ?> This is just soemthing really simple to show you how it can be done, you'd need to add in some kind of limiter so players can't just sit and click it all day. Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 thankyou guys now ill just complile it cheers big help Quote
SRB Posted July 24, 2013 Posted July 24, 2013 thankyou guys now ill just complile it cheers big help Purchase of... ? Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 i just need to figure out a code that charges the user say 100 crystals for the random items and using a specific 5 random items Quote
Razor42 Posted July 24, 2013 Posted July 24, 2013 To charge the user 100 crystals simply do.. $db->("UPDATE users SET crystals=crystals-100 WHERE userid=$userid"); But why charge crystals when your giving them aswell? Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 Ill try to explain it a little better, well basically i am trying to make afeature that almost works like a random card pack , so the user spends 100 crystals on this card back which contains 6 random items within the game in which they will receive for spending the 100 crystals Quote
SRB Posted July 24, 2013 Posted July 24, 2013 Then click the link I provided on page one of this thread, and you have almost what you want -- if you want 6 every time, just change the mt_rand to 6 and they'll get 6 every time. Quote
Razor42 Posted July 24, 2013 Posted July 24, 2013 Well guest has set you on your way pretty well. Surly you can add the little extras in yourself? 1 Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 thankyou everyone :) when i actually get better at this which hopefully will be soon ill provide help as well to anyone that needs it thanks Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 i cannot seem to find where to add the line to take 100 crystals from the user for using the daily random item giver can anyone implement it for me, code is shown below, im sorry for all the issues im having only new to this stuff <?php include_once('globals.php'); $sql = "SELECT * FROM `random_items` WHERE `user` = '{$ir['userid']}'"; $run = mysql_query($sql, $c) or die (mysql_error()); if (mysql_num_rows($run) == 0) { $amount = mt_rand(4); echo '<p>You have Recieved ' . $amount . ' </p> <p>The items you have been given, are:</p> <ul>'; $sql = "SELECT `itmid`,`itmname` FROM `items` WHERE `itmbuyprice` < 9000 AND `itmbuyable` = 1 ORDER BY RAND() LIMIT $amount"; $run = mysql_query($sql, $c) or die (mysql_error()); while ($item = mysql_fetch_assoc($run)) { echo '<li>1x ' . htmlentities($item['itmname'], ENT_QUOTES, "UTF-8") . '</li>'; item_add($ir['userid'], $item['itmid'], 1); } echo '</ul>'; } else { echo '<p>You have already claimed your free items today.</p>'; } $h->endpage(); Quote
Dominion Posted July 24, 2013 Posted July 24, 2013 i cannot seem to find where to add the line to take 100 crystals from the user for using the daily random item giver can anyone implement it for me, code is shown below, im sorry for all the issues im having only new to this stuff The query is on line 29 of Guest's mod. Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 (edited) it doesnt seem to be working instead it still allows the user to have the items even without the 100 crystals, :( Edited July 24, 2013 by dbeckerton Quote
dbeckerton Posted July 24, 2013 Author Posted July 24, 2013 hmmmmmmmmmmmmmmmmmmmmmmmmmmm just trying to think Quote
Dragon Blade Posted July 24, 2013 Posted July 24, 2013 <?php include_once('globals.php'); if($ir['crystals'] > 100) { echo"You do not have 100 crystals to spend."; $h->endpage(); exit; } $sql = "SELECT * FROM `random_items` WHERE `user` = '{$ir['userid']}'"; $run = mysql_query($sql, $c) or die (mysql_error()); if (mysql_num_rows($run) == 0) { $amount = mt_rand(4); echo '<p>You have Recieved ' . $amount . ' </p> <p>The items you have been given, are:</p> <ul>'; $sql = "SELECT `itmid`,`itmname` FROM `items` WHERE `itmbuyprice` < 9000 AND `itmbuyable` = 1 ORDER BY RAND() LIMIT $amount"; $run = mysql_query($sql, $c) or die (mysql_error()); while ($item = mysql_fetch_assoc($run)) { echo '<li>1x ' . htmlentities($item['itmname'], ENT_QUOTES, "UTF-8") . '</li>'; item_add($ir['userid'], $item['itmid'], 1); mysql_query("UPDATE users SET crystals=crystals -100 WHERE userid={$ir['userid']}"); } echo '</ul>'; } else { echo '<p>You have already claimed your free items today.</p>'; } $h->endpage(); There you go. Quote
SRB Posted July 24, 2013 Posted July 24, 2013 <?php include_once('globals.php'); if($ir['crystals'] > 100) { echo"You do not have 100 crystals to spend."; $h->endpage(); exit; } $sql = "SELECT * FROM `random_items` WHERE `user` = '{$ir['userid']}'"; $run = mysql_query($sql, $c) or die (mysql_error()); if (mysql_num_rows($run) == 0) { $amount = mt_rand(4); echo '<p>You have Recieved ' . $amount . ' </p> <p>The items you have been given, are:</p> <ul>'; $sql = "SELECT `itmid`,`itmname` FROM `items` WHERE `itmbuyprice` < 9000 AND `itmbuyable` = 1 ORDER BY RAND() LIMIT $amount"; $run = mysql_query($sql, $c) or die (mysql_error()); while ($item = mysql_fetch_assoc($run)) { echo '<li>1x ' . htmlentities($item['itmname'], ENT_QUOTES, "UTF-8") . '</li>'; item_add($ir['userid'], $item['itmid'], 1); mysql_query("UPDATE users SET crystals=crystals -100 WHERE userid={$ir['userid']}"); } echo '</ul>'; } else { echo '<p>You have already claimed your free items today.</p>'; } $h->endpage(); There you go. Ugh :/ http://makewebgames.io/showthread.php/43770-Daily-random-items?p=294409&viewfull=1#post294409 Quote
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.