Author Topic: is there a way to, if the item fails, gives the item back to the user?  (Read 2572 times)

Offline feeble

is there a way, that if say, the script fails for a certain reason.
that it will give the item back to the user so that it will not be wasted?

if not, im thinking of, editing the Shop-Inventory.php that receives the return text.

if CANCEL is in it? then it will strip the cancel from the return, not deduct the item, and relay the message to the user, which is after CANCEL in the return.

something like,
return "CANCEL user doesnt exist, you decide not to waste it";
« Last Edit: October 21, 2006, 05:43:09 am by feeble »

Offline Daniel15

Re: is there a way to, if the item fails, gives the item back to the user?
« Reply #1 on: October 21, 2006, 11:14:14 am »
Edit the item to die() if the item doesn't work...
For example:

// ... do a MySQL query here...

if (mysql_num_rows($result) == 0)
    die("ERROR: That user doesn't exist!")

// Continue your usual code here

This works because it makes the main shop script exit before reaching the code that removes the item from the inventory.  But I must admit, I should implement something better than this :P

Offline feeble

Re: is there a way to, if the item fails, gives the item back to the user?
« Reply #2 on: October 21, 2006, 05:02:59 pm »
ok sweet, just what i was looking for. yeah no worries to that.