Jump to content
MakeWebGames

Just a Little Help Needed


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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();

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...