Fix delivery problems
This commit is contained in:
parent
f6902fefd5
commit
623966b907
5 changed files with 255 additions and 20 deletions
|
@ -12,7 +12,7 @@ float g_fEmpty = -1.142;
|
|||
float g_fFull = -0.202;
|
||||
integer g_iRequestTime = 0;
|
||||
string WATER_WELL_NAME = "WoodStoneWaterWell";
|
||||
string VERSION = "1.0.0";
|
||||
string VERSION = "1.0.1";
|
||||
integer g_iWaterPrim;
|
||||
integer g_iRoofPrim;
|
||||
integer g_iDestroyed = 0;
|
||||
|
@ -50,6 +50,11 @@ SCAN() {
|
|||
}
|
||||
}
|
||||
|
||||
integer g_iDevListener;
|
||||
integer g_iWaitDelivery = 0;
|
||||
string g_sCallbackURL;
|
||||
key g_kCallbackURLRequest;
|
||||
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
|
@ -69,9 +74,33 @@ default
|
|||
updateLevel();
|
||||
setText();
|
||||
|
||||
g_iDevListener = llListen(99, "", "", "");
|
||||
|
||||
}
|
||||
|
||||
listen(integer c,string n,key i,string m) {
|
||||
if(c==99) {
|
||||
if(m == "devmode_off") {
|
||||
g_iTotalWater=100;
|
||||
llSetTimerEvent(1);
|
||||
g_iLastFillTime=llGetUnixTime();
|
||||
if(g_iWellChannel != 0) {
|
||||
llListenRemove(g_iWellListener);
|
||||
}
|
||||
g_iWellChannel = (integer)("0x" + llGetSubString(llGetKey(), 0, 5));
|
||||
g_iWellListener = llListen(g_iWellChannel, "", "", "");
|
||||
|
||||
setText();
|
||||
} else if(m == "empty") {
|
||||
g_iTotalWater = 0;
|
||||
setText();
|
||||
}else if(m == "freeze") {
|
||||
llSetTimerEvent(0);
|
||||
} else if(m == "reset") {
|
||||
llResetScript();
|
||||
}
|
||||
return;
|
||||
}
|
||||
string sJson = xtea_decrypt_string(m);
|
||||
if(llJsonGetValue(sJson, ["cmd"]) == "alive" && llJsonGetValue(sJson, ["type"]) == "Bucket") {
|
||||
|
||||
|
@ -127,6 +156,21 @@ default
|
|||
}
|
||||
|
||||
timer() {
|
||||
if(g_iWaitDelivery) {
|
||||
g_iWaitDelivery--;
|
||||
|
||||
if(g_iWaitDelivery == 1) {
|
||||
// Failed, request by fallback
|
||||
llReleaseURL(g_sCallbackURL);
|
||||
llHTTPRequest(API_SERVER + "/Get_Server_URL.php?NAME=Farming", [], "");
|
||||
}
|
||||
|
||||
|
||||
if(g_iTotalWater >= 100 && !g_iWaitDelivery) {
|
||||
llSetTimerEvent(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(llGetUnixTime() > (g_iLastFillTime + 30)) {
|
||||
g_iLastFillTime = llGetUnixTime();
|
||||
g_iTotalWater ++;
|
||||
|
@ -187,6 +231,22 @@ default
|
|||
}
|
||||
}
|
||||
|
||||
http_request(key kID, string sMethod, string sBody)
|
||||
{
|
||||
if(kID == g_kCallbackURLRequest) {
|
||||
if(sMethod == URL_REQUEST_GRANTED) {
|
||||
requestProductForDelivery("Water Bucket [AC]", g_kAv, sBody);
|
||||
g_sCallbackURL = sBody;
|
||||
|
||||
g_iWaitDelivery = 30;
|
||||
llSetTimerEvent(1);
|
||||
}
|
||||
} else {
|
||||
llHTTPResponse(kID, 200, "");
|
||||
llReleaseURL(g_sCallbackURL);
|
||||
}
|
||||
}
|
||||
|
||||
http_response(key kID, integer iStatus, list lMeta, string sBody) {
|
||||
list lParams = llParseString2List(sBody, [";", ";;"], []);
|
||||
string sScript = llList2String(lParams,0);
|
||||
|
@ -196,8 +256,10 @@ default
|
|||
if(sScript == "GetServerID") {
|
||||
string sJson = llList2String(lParams,1);
|
||||
g_sServerID = llJsonGetValue(sJson, ["id"]);
|
||||
requestProductForDelivery("Water Bucket [AC]", g_kAv);
|
||||
}else if(sScript == "Modify_ProductV2") {
|
||||
g_kCallbackURLRequest = llRequestURL();
|
||||
} else if(sScript == "Get_Server_URL") {
|
||||
altRequestDelivery(llList2String(lParams, 2), g_kAv, "Water Bucket [AC]");
|
||||
} else if(sScript == "Modify_ProductV2") {
|
||||
// Gives the version information
|
||||
string sJson = llList2String(lParams,1);
|
||||
if(llJsonGetValue(sJson, ["status"]) == "ok") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue