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 Like 25 Dislike
Previous forums Next forums
Other forums

How to pass parameter to tag query?
Hi,
I want to get the value of a tag at a specific time (like 10/27/09 15:29:59), I need to giv

Delete HTML file after loading
I have limited experience with php and its been a year or two since I've last used it. I have a sma

socket communication between c++/java and sending image
hi,

i have a class in c++ called win32_sockserver which creates socket to java. i am trying

Uploading/Downloading files stored in MySQL database
Hey all,

This problem just came up in my website and I'm having a hard time figuring out what

Varible in trigger - refering to correct schema
Hello

Im having some issues with my trigger.
What I want to do is call opon a differ

Strange cookie problem. setcookie dependant on where user was directed from?
Hello,

I have a website that sets a cookie when a user visits the website. The cookie holds a

php and downloading
I want to use a php script to create two files. Then I want it to redirect (or whatever) to have tho

Extract specific information from a PHP Multidimensional Array
Howdy! I've racked my brain over this for 24 hours now. I think it's time I asked for help. I'm lear

Generating unique numbers using php
Hi,
I need help in generating unique number using php.I tired using rand() in php.But, by using r

Save data in input fields when they press "BACK BUTTON"
Hi, this is html form: And let's say they get a error "Please enter ur title must be more then

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash