Jump to content

Giving object from inventory if status code = 200


Elvio Zobovic
 Share

You are about to reply to a thread that has been inactive for 3002 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi there,

I am working on a system that stores info into a database. 

I've got a lot working already, it's basically a custom currency with points.

Now what I did to check if the user purchase was valid is change the status code in the php:

//Set points before sale to variable
$beforePoints = $row['points'];
$afterPoints = $beforePoints - $price;
//Start Update Query
if($beforePoints >= $price)
{
http_response_code(200);
$query = "UPDATE `users` SET `points` = (`points`-".$price.") WHERE `uuid` = '".$avatar_key."' AND points > 0";
echo "You paid ". $price ." points. You have " . $afterPoints . " points left.";
}
else {
http_response_code(402);
	echo("Not Enough! This item costs ". $price ." Points. You have: " . $beforePoints . " Points.");
	die();	
}

So then in the LSL I check the response code to see if the user made the purchase or not to give the item.

//tell us what was returned.
    if(status = 402) {
            llSay(0, body);
            return;
        }
    if(status = 200) {
            llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_OBJECT,0));
            llSay(0, body);
            return;
        }
}

So, everything works just fine but one thing. It never gives the inventory item.

What am I doing wrong here?

 

Thanks in advance,

 

Brian

Link to comment
Share on other sites

Is this status checking happening in an event handler where llDetectedKey() is meaningful?

[ETA: Oh, also, you don't want to be assigning a value to the "status" variable with "=", you want to be comparing it with "==", so as-is, the script is just setting it to 402, always.]

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3002 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...