XbabylonX Posted January 4, 2013 Share Posted January 4, 2013 Hello,I have the following code:key myRequest; string Who; default { state_entry() { } touch_start(integer number) { Who=llDetectedKey(0); llInstantMessage(Who,"Sending request to the server! Please wait..."); 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 scenario is as follows:Avatar clicks the prim and the code runs.If avatar wants to click it again, has to wait some seconds. As you understand, I want to protect my webserver from accepting mass requests with this button. Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted January 4, 2013 Share Posted January 4, 2013 To stop the object to react on clicks for a bit, you simply add a timer and a flag: key myRequest;string Who;integer touchable = 1;default{ state_entry() { } touch_start(integer number) { if (touchable) { touchable = 0; Who=llDetectedKey(0); llSetTimerEvent(10.0); llInstantMessage(Who,"Sending request to the server! Please wait..."); myRequest=llHTTPRequest("http://example.com/Page.asp", [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], "Who=" + llGetUsername(llDetectedKey(0))); } else { llInstantMessage(Who,"Please wait a bit"); } } http_response(key request_id, integer status, list metadata, string body) { if (request_id == myRequest) { llInstantMessage(Who,body); } } timer() { touchable = 1; llSetTimerEvent(0); }} You could also wait for the http_response for setting touchable to 1 again, which at you current design would be better, since if the response has not arrived back when a second avi touches the objects, Who will be overwritten and the first ava won't get the IM in the response event, but the 2nd avi would get two mesages- Link to comment Share on other sites More sharing options...
XbabylonX Posted January 4, 2013 Author Share Posted January 4, 2013 Thank you Darkie for your anwer. It doesnt get back the response. Link to comment Share on other sites More sharing options...
XbabylonX Posted January 4, 2013 Author Share Posted January 4, 2013 Negative, negative Works!!!!!! Thank youuuu Link to comment Share on other sites More sharing options...
Nexii Malthus Posted January 4, 2013 Share Posted January 4, 2013 The touchee is likely in the same sim to be able to click on the prim. llInstantMessage has a forced delay of 2 seconds ( http://wiki.secondlife.com/wiki/LlInstantMessage ) llRegionSayTo performs similar function (for messages sent to a user in the same sim) but has no delay. ( http://wiki.secondlife.com/wiki/LlRegionSayTo ) Replace the function calls with llRegionSayTo(Who, PUBLIC_CHANNEL, "Text"); "Text" being your original message. 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