Jump to content

Action after payment recieved


XbabylonX
 Share

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

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

Recommended Posts

Hello,

Im using this script from here http://wiki.secondlife.com/wiki/LlSetPayPrice

After recieving the payment (means inside the else condition) I want to inform my webserver and recieve back a response.

What Im trying to do is to include inside the else the following code:

key myRequest;
string Who;

Who=llDetectedKey(0);
llInstantMessage(Who,"Sending request to the server");
    myRequest=llHTTPRequest("http://example.com/Page.asp",
          [HTTP_METHOD, "POST",
           HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
           "Who=" + llGetUsername(llDetectedKey(0)));
    

    http_response(key request_id, integer status, list metadata, string body)
    {
            if (request_id == myRequest)
            {

            llInstantMessage(Who,body);
            }
    }

 The code above works perfect in other places Im using it but not in this scenario.

Could someone give me instructions on how to make it work?

Thank you very much!

Link to comment
Share on other sites

In which event do use this code? I guess it's the money event (the part before the http_response event), which doesn't support llDetectedKey() but passes the key of the ava that has payed money as a parameter. , id or Who are keys, so you have to convert them, using them as a string. AlsoYour code could look something like:

 

key myRequest;key Who;state cash {	money(key id, integer amount) {		Who = id;		llInstantMessage(Who,"Sending request to the server");		myRequest=llHTTPRequest("http://example.com/Page.asp",		          [HTTP_METHOD, "POST",		           HTTP_MIMETYPE, "application/x-www-form-urlencoded"],		           "Who=" + (string)Who);	}        http_response(key request_id, integer status, list metadata, string body)    {            if (request_id == myRequest)            {            	llInstantMessage(Who,body);            }    }}            

 

Link to comment
Share on other sites

Thank you for your answer.

It throws an error

integer price=100; default{    state_entry()    {    llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);    llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);    }    run_time_permissions(integer perm)    {        if(perm & PERMISSION_DEBIT)            state cash;    }} state cash{    state_entry()    {    llSetPayPrice(price, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);    }    money(key id, integer amount)    {        if(amount != price)        {        llGiveMoney(id, amount);        llInstantMessage(id, "You paid "+(string)amount+", which is the wrong price, the price is: "+(string)price);        }        else        {        Who = id;        llInstantMessage(Who,"Sending request to the server");        myRequest=llHTTPRequest("http://example.com/Page.asp",        [HTTP_METHOD, "POST",        HTTP_MIMETYPE, "application/x-www-form-urlencoded"],        "Username=" + (string)Who);        llInstantMessage(id, "You paid the right price");        http_response(key request_id, integer status, list metadata, string body)        {            if (request_id == myRequest)            {            llInstantMessage(Who,body);            }        }        }    }}

At the line I wrote  http_response(key request_id, integer status, list metadata, string body)

Link to comment
Share on other sites

It was giving you errors because you hadn't declared two global varibles and the bracketing was all over the place.

This compiles, but I don''t know if it works or not

 

integer price=100;key Who;key myRequest;default{	state_entry()	{		llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);		llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);	}	run_time_permissions(integer perm)	{		if(perm & PERMISSION_DEBIT)			state cash;	}}state cash{	state_entry()	{		llSetPayPrice(price, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);	}	money(key id, integer amount)	{		if(amount != price)		{			llGiveMoney(id, amount);			llInstantMessage(id, "You paid "+(string)amount+", which is the wrong price, the price is: "+(string)price);		}		else		{			Who = id;			llInstantMessage(Who,"Sending request to the server");			myRequest=llHTTPRequest("http://example.com/Page.asp",				[HTTP_METHOD, "POST",				HTTP_MIMETYPE, "application/x-www-form-urlencoded"],				"Username=" + (string)Who);			llInstantMessage(id, "You paid the right price");		}	}	http_response(key request_id, integer status, list metadata, string body)	{		if (request_id == myRequest)		{			llInstantMessage(Who,body);		}	}}

 

Link to comment
Share on other sites

If your object is set to PAY when it's clicked, then it won't respond to a touch_start event.  The PAY option will only trigger a money event. If you want a touch* event, leave the object's click option at TOUCH, not PAY. Then you'll have to put a touch_end event in state default, and include in it a llSetClickAction(CLICK_ACTION_PAY) statement.  Then send execution to state cash.  A second click on the object will therefore be interpreted as a trigger to PAY in state cash.  Just remember to add a llSetClickAction(CLICK_ACTION_TOUCH) statement before you send execution back to state default, so that the touch_end event can be triggered there again.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4182 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...