Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer iPrice;
- key kProductRequest;
- key kKVPReadRequest;
- key kToucher;
- string strURL;
- string strKVPKeyForServer = "CurrentURL:";
- string strProduct;
- string strRequest;
- string strMyExperience= "My Experience Name";
- default {
- state_entry() {
- if(llList2String(llGetExperienceDetails(NULL_KEY),0)!=strMyExperience){
- llOwnerSay("Please ensure that "+strMyExperience+" is able to run on this parcel");
- }
- kKVPReadRequest=llReadKeyValue(strKVPKeyForServer);//ask for value of current url
- }
- dataserver(key queryid, string data) {
- if(queryid == kKVPReadRequest){
- integer success = (integer)llGetSubString(data,0,0);
- data = llDeleteSubString(data,0,1);
- if(success){
- strURL = data;
- if(llStringLength(kProductRequest)){
- //then there's an outstanding request
- kProductRequest = llHTTPRequest(strURL, [HTTP_METHOD,"POST"],strRequest);
- }
- }
- else{
- llOwnerSay("Could not read server url because "+llGetExperienceErrorMessage((integer)data));
- }
- }
- }
- money(key id, integer amount) {
- //don't know how we got here, but on the way we assigned values to kToucher and strProduct
- if(id == kToucher && amount == iPrice){
- strRequest = (string)kToucher+"~"+strProduct;
- kProductRequest = llHTTPRequest(strURL, [HTTP_METHOD,"POST"],strRequest);
- }
- }
- http_response(key request_id, integer status, list metadata, string body) {
- if(kProductRequest == request_id){
- if(200 != status){
- llOwnerSay("Need to ask for new url");
- kKVPReadRequest=llReadKeyValue(strKVPKeyForServer);//ask for value of current url
- }
- else{
- kProductRequest = "";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement