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

Program with calculate Meteorologic measurements
Hello I'm a beginner and I want to make a program with calculate Meteorologic measurements:
ba

Syntax Help
Code:


im having trouble with that code snipped
Parse error: syntax error, unexpec

How to search for several parameters from objects in a database?
I have a database with lots of information about objects.
Now I would like to search for 4 or 5 p

Greek characters in php
Hi,

I'm making a script and I m using for first time greek characters.
I started to write

Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree

problem in program for counting no of chars using pointers
Hi all, I was trying to make a program which counts number of chars in a string using concpt of poin

Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba

PHP, Arrays & A Lot Of Confusion
I've been doing basic PHP work on sites for a few years now, but I've never been tempted to learn ho

Writing Windows Device Drivers with C
Yes: one of the nice features of C is void*. You can put anything there and get anything out. Very

Coding question?
Hey guys, I have a quick question. If I want to make a way for people to pay for health in my game,

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