SMF Shop

SMFShop => Coding => Topic started by: feeble on October 21, 2006, 05:27:11 am

Title: is there a way to, if the item fails, gives the item back to the user?
Post by: feeble on October 21, 2006, 05:27:11 am
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";
Title: Re: is there a way to, if the item fails, gives the item back to the user?
Post by: Daniel15 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
Title: Re: is there a way to, if the item fails, gives the item back to the user?
Post by: feeble on October 21, 2006, 05:02:59 pm
ok sweet, just what i was looking for. yeah no worries to that.