XbabylonX Posted January 2, 2013 Share Posted January 2, 2013 Hello,Im using this script from here http://wiki.secondlife.com/wiki/LlSetPayPriceAfter 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 More sharing options...
Darkie Minotaur Posted January 2, 2013 Share Posted January 2, 2013 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 More sharing options...
XbabylonX Posted January 2, 2013 Author Share Posted January 2, 2013 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 More sharing options...
Innula Zenovka Posted January 3, 2013 Share Posted January 3, 2013 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 More sharing options...
XbabylonX Posted January 3, 2013 Author Share Posted January 3, 2013 Yes, that worked Thank you both for your help! However I have one more question regarding this piece of code. When trying to add a touch event, nothing works again. Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 4, 2013 Share Posted January 4, 2013 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 More sharing options...
XbabylonX Posted January 4, 2013 Author Share Posted January 4, 2013 No, I have to right click and click Pay Link to comment Share on other sites More sharing options...
Innula Zenovka Posted January 4, 2013 Share Posted January 4, 2013 You will need to post the code so we can see what's happening, but I've just put touch_start (integer total_number){ llRegionSayTo(llDetectedKey(0),0,"you touched me"); } into state cash and it works as expected. Link to comment Share on other sites More sharing options...
XbabylonX Posted January 4, 2013 Author Share Posted January 4, 2013 Most probably I was doing it all wrong, because in the state cash it worked perfect Again, thank you all for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
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