script is pulling more then they have....
Posted on
16th Feb 2014 07:03 pm by
admin
I have this script for my game where they can change there race. This will cost them 2,500 points. However in our database points are called crystals.
If the person has 500 points, and the script takes 2,500 it will put them at -2,000 points. I need the script to tell them they dont have enough points and then not change there race because they dont have enough to do so. However im not to sure on how I would write it.
This is the race change script im editing, can anyone explain how to write this to do what I need:
Code: function conf_race_change()
{
global $ir,$c,$userid,$h;
if($ir['race'] == "Pirate") { $r="Ninja"; } else { $r="Pirate"; }
print "Switching your race will cost 2,500 points. Are you sure you want to become a $r?<br />
<a href='preferences.php?action=racechange2'>Yes</a> | <a href='preferences.php'>No</a>";
}
function do_race_change()
{
global $db,$ir,$c,$userid,$h;
if($ir['race'] == "Pirate") { $r="Ninja"; } else { $r="Pirate"; }
$db->query("UPDATE users SET race='$r' WHERE userid=$userid");
$db->query("UPDATE users SET crystals=crystals-2500 WHERE userid=$userid");
print "Success, you are now $r!<br />
<a href='preferences.php'>Back</a>";
}
No comments posted yet
Your Answer:
Login to answer
64
25
Other forums
preg_match logical error
Code: <?php
$s = file_get_contents("page.html");
preg_match('/<div cla
Array disappearing in foreach loop
Okay, I have this problem where an array will become undefined in a foreach loop.
Here is the
Performance impact of cookies
Hi, I was just wondering what impact there would be in terms of performance if you where to set then
Multiple upload and Resize
I would like some help on my script I have the for my index.php
////
<html&
for loop without same $i digits?
Hi,
Can some guru please advise how can I accomplish this with a simple for loop ?
I
php or sql?
Sorry not sure if this is a sql problem or php the following code is supposed to delete data from th
setcookie and isset($_COOKIE(name)) seem very finnicky.
I'm currently playing around with a user system with login and registration. I'm trying to use cooki
BB_Code error
I'm having a problem with a custom built function and keep getting this error:
Warning: M
cyrillic string conversion question
Hello,
First time here...
I would like to know if there is a way to convert a
Problems with adding a link to one position in a 'foreach' loop, please help
Hello!
Iam pretty new to programming and I wanna create a table with users from an array. It