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

Shopping Cart
Can anyone direct me to a Simple, Basic structure of a shopping cart.
New to classes. I want to s

I am stumped
OK. Here is what I am trying to do. I have the conditions set, and if the conditions are met, I want

ok i need to join all this pages to make 1 neat code
i have 5 pages that make up my tv guide it works 100% but i want to make it 1 page if i can or 2, i

asp authentication problem
Hello all, I want to use the asp authentication (from asp.net configuration) in my web site. there

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

Simple program to copy files between two computers over the web
I use logmein free and often need to move files between my two computers. Generally, I move the file

Check something, wait, check again, do something!
Hi guys.

I wonder if someone can help me with this.

Basically, what I want to do is (

puting for loop in 1 value
hi ,

how do i put this code in 1 value:
Code: <?php
for ($i=1; $i<=5; $i

Shuffle Array
Hi,

I am writing a script for a game that needs players to randomly be assigned a target (ano

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

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