Implemented basic water well and water bucket
This commit is contained in:
parent
f928139088
commit
3dbc618418
17 changed files with 862 additions and 0 deletions
89
LSL/raw/item_server.lsl
Normal file
89
LSL/raw/item_server.lsl
Normal file
|
@ -0,0 +1,89 @@
|
|||
#include "Common.lsl"
|
||||
|
||||
string API_SERVER;
|
||||
integer g_iActive = 1;
|
||||
integer g_iRegistered=0;
|
||||
|
||||
default {
|
||||
state_entry() {
|
||||
llSay(0, "Server '" + llGetObjectDesc() + "' is starting up...");
|
||||
llMessageLinked(LINK_SET, 2, "", "");
|
||||
llMessageLinked(LINK_SET, -1, "", "");
|
||||
|
||||
XteaKey(PSK);
|
||||
}
|
||||
|
||||
link_message(integer s,integer n,string m,key i) {
|
||||
if(n == 0x004f) {
|
||||
API_SERVER = DecipherService(m, "api");
|
||||
if(g_iRegistered)return;
|
||||
|
||||
// Register the server object ID
|
||||
llHTTPRequest(API_SERVER + "/zni/Put_Server_ID.php?NAME=" + llEscapeURL(llGetObjectDesc()) + "&PSK=" + llEscapeURL(SERVER_PSK), [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/json"], llList2Json(JSON_OBJECT, ["id", llGetKey()]));
|
||||
llMessageLinked(LINK_SET, 1, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
http_response(key k, integer s, list m, string b) {
|
||||
if(s == 200) {
|
||||
llMessageLinked(LINK_SET, 0, "", "");
|
||||
llSay(0, "Server '" + llGetObjectDesc() +"' is now ready");
|
||||
|
||||
g_iRegistered=TRUE;
|
||||
|
||||
llSetTimerEvent(1);
|
||||
}
|
||||
}
|
||||
|
||||
touch_start(integer t) {
|
||||
if(llDetectedKey(0) == llGetOwner()) {
|
||||
g_iActive = 1-g_iActive;
|
||||
if(g_iActive) {
|
||||
llSay(0, "Server '" + llGetObjectDesc() + "' reactivating...");
|
||||
llResetScript();
|
||||
} else {
|
||||
llMessageLinked(LINK_SET, 2, "", "");
|
||||
llSay(0, "Server '" + llGetObjectDesc() + "' has been taken offline for maintenance. Any pending requests will still be processed, but any new ones will be blocked");
|
||||
llHTTPRequest(API_SERVER + "/zni/Del_Server_ID.php?NAME=" + llEscapeURL(llGetObjectDesc()) + "&PSK=" + llEscapeURL(SERVER_PSK), [], "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timer() {
|
||||
llGetNextEmail("", "");
|
||||
}
|
||||
|
||||
on_rez(integer t) {
|
||||
llResetScript();
|
||||
}
|
||||
|
||||
email(string time, string address, string subject, string body, integer num_remain) {
|
||||
if(subject == "RequestProductDelivery") {
|
||||
//llSay(0, "EMAIL : " + body);
|
||||
llMessageLinked(LINK_SET, 1, "", "");
|
||||
list lPar = llParseString2List(body, [";;"], []);
|
||||
|
||||
string sPayload = xtea_decrypt_string(llList2String(lPar,1));
|
||||
// Check what object is being requested and by who
|
||||
string sRequest = llJsonGetValue(sPayload, ["item"]);
|
||||
string sID = llJsonGetValue(sPayload, ["id"]);
|
||||
|
||||
// Forbid giving scripts
|
||||
if(llGetInventoryType(sRequest) == INVENTORY_SCRIPT) return;
|
||||
|
||||
// Deliver if we have the item
|
||||
if(llGetInventoryType(sRequest) != INVENTORY_NONE) {
|
||||
llGiveInventory(sID, sRequest);
|
||||
llWhisper(999, sPayload);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Log this as an error in delivery
|
||||
llWhisper(998, sPayload);
|
||||
}
|
||||
|
||||
llSleep(0.25);
|
||||
llMessageLinked(LINK_SET, 0, "", "");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue