Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <VEOS.lsl>
- key notecardQueryId;
- string notecardName;
- integer notecardLine;
- key requestKey;
- key initializeHTTP;
- string basename;
- string server;
- integer disabled = FALSE;
- string handling = "";
- initialize()
- {
- if(llGetInventoryNumber(INVENTORY_NOTECARD) == 0)
- {
- llOwnerSay("Please drop the VEOS-SETTINGS notecard into this object.");
- }
- else
- {
- llListen(VEOS_CLIENT_CHANNEL, "", NULL_KEY, "");
- requestKey = llReadKeyValue("VEOS-basename");
- }
- }
- integer startswith(string haystack, string needle)
- {
- return llDeleteSubString(haystack, llStringLength(needle), 0x7FFFFFF0) == needle;
- }
- default
- {
- state_entry()
- {
- initialize();
- llTargetOmega(<0,0,0>, 0, 0);
- }
- touch_start(integer num)
- {
- if(llGetOwner() == llDetectedKey(0))
- {
- llResetScript();
- }
- }
- changed(integer change)
- {
- if(change & CHANGED_INVENTORY)
- {
- llResetScript();
- }
- }
- on_rez(integer param)
- {
- llResetScript();
- }
- dataserver(key query_id, string data)
- {
- if(disabled) return;
- if(query_id == notecardQueryId)
- {
- if(data == EOF)
- {
- llOwnerSay("Done sending settings. Read " + (string) notecardLine + " notecard lines.");
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=settings-complete");
- return;
- }
- data = llStringTrim(llList2String(llParseStringKeepNulls(llStringTrim(data, STRING_TRIM), ["#"], []), 0), STRING_TRIM);
- if(data != "KV_SETTINGS" && data != "SERVER_STAFF" && data != "SERVER_TELEPORT_PUBLIC" && data != "SERVER_TELEPORT_STAFF" && data != "SERVER_MOTD")
- {
- if(handling == "KV_SETTINGS" && data != "")
- {
- string k = llStringTrim(llList2String(llParseStringKeepNulls(data, ["="], []), 0), STRING_TRIM);
- string v = llStringTrim(llList2String(llParseStringKeepNulls(data, ["="], []), 1), STRING_TRIM);
- if(v == "delete")
- {
- llDeleteKeyValue(server + " - " + k);
- }
- else
- {
- llUpdateKeyValue(server + " - " + k, v, FALSE, "");
- }
- }
- else if(handling == "SERVER_STAFF" && data != "")
- {
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=setting-staff\nvalue=" + data);
- }
- else if(handling == "SERVER_TELEPORT_PUBLIC" && data != "")
- {
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=setting-teleport-public\nvalue=" + data);
- }
- else if(handling == "SERVER_TELEPORT_STAFF" && data != "")
- {
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=setting-teleport-staff\nvalue=" + data);
- }
- else if(handling == "SERVER_MOTD" && data != "")
- {
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=setting-motd\nvalue=" + data);
- }
- else if(handling == "VEOS_ZONES" && data != "")
- {
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=setting-zones\nvalue=" + data);
- }
- }
- if(data == "KV_SETTINGS")
- {
- handling = "KV_SETTINGS";
- llOwnerSay("Sending KV settings...");
- }
- else if(data == "SERVER_STAFF")
- {
- handling = "SERVER_STAFF";
- llOwnerSay("Sending staff settings...");
- }
- else if(data == "SERVER_TELEPORT_PUBLIC")
- {
- handling = "SERVER_TELEPORT_PUBLIC";
- llOwnerSay("Sending public teleport settings...");
- }
- else if(data == "SERVER_TELEPORT_STAFF")
- {
- handling = "SERVER_TELEPORT_STAFF";
- llOwnerSay("Sending staff teleport settings...");
- }
- else if(data == "VEOS_ZONES")
- {
- handling = "VEOS_ZONES";
- llOwnerSay("Sending VEOS zones...");
- }
- else if(data == "SERVER_MOTD")
- {
- handling = "SERVER_MOTD";
- llOwnerSay("Sending MOTD settings...");
- }
- ++notecardLine;
- notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
- }
- else if(query_id == requestKey)
- {
- string arg = "sim=" + llEscapeURL(llGetRegionName());
- if((integer)llGetSubString(data, 0, 0) == 1)
- {
- baseName = llGetSubString(data, 2, -1);
- }
- initializeHTTP = llHTTPRequest(baseName, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], arg);
- }
- }
- http_response(key id, integer status, list meta, string body)
- {
- if(disabled) return;
- if(id != initializeHTTP) return;
- if(status != 200)
- {
- llOwnerSay("Something went wrong... Try clicking me in a few minutes.");
- return;
- }
- if(body == "DIE" || body == "SIM_NOT_REGISTERED")
- {
- llOwnerSay("Your sim has been ejected from the VEOS system or has not been registered.");
- disabled = TRUE;
- }
- else
- {
- server = llList2String(llParseStringKeepNulls(body, ["\n"], []), 1);
- notecardLine = 0;
- notecardName = llGetInventoryName(INVENTORY_NOTECARD, notecardLine);
- llOwnerSay("Sending new settings...");
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=clear-settings");
- llRegionSay(VEOS_SERVER_CHANNEL, "mode=region-pos");
- notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
- }
- }
- listen(integer c, string n, key k, string m)
- {
- if(disabled) return;
- if(m == "RESEND-SERVER-SETTINGS")
- {
- llResetScript();
- }
- else if(startswith(m, "REGION-POS"))
- {
- llSetRegionPos((vector)llList2String(llParseString2List(m, ["\n"], []), 1));
- llSetRot(llList2Rot(llGetObjectDetails(k, [OBJECT_ROT]), 0));
- llTargetOmega(<1.0,0.0,0.0>*llGetRot(),1.0,0.1);
- }
- }
- }
Advertisement