StallBoard/LSL/raw/Server.lsl
2024-08-14 00:13:51 -07:00

104 lines
No EOL
4.3 KiB
Text
Executable file

#include "variables.lsl"
#include "functions.lsl"
default
{
state_entry()
{
llListen(SERVER_CHANNEL, "", "", "");
UpdateDSRequest(NULL, llGetNotecardLine("config", 0), SetDSMeta(["read",0]));
}
listen(integer c,string n,key i,string m)
{
if(llJsonGetValue(m,["op"]) == "get_admins")
{
llRegionSayTo(i,c,llList2Json(JSON_OBJECT, ["op", "set_admins", "adm", llList2Json(JSON_ARRAY, g_lAdminTag)]));
} else if(llJsonGetValue(m,["op"]) == "get_managers")
{
llRegionSayTo(i,c,llList2Json(JSON_OBJECT, ["op", "set_managers", "mgr", llList2Json(JSON_ARRAY, g_lManagerTag)]));
} else if(llJsonGetValue(m,["op"]) == "get_flags")
{
llRegionSayTo(i,c,llList2Json(JSON_OBJECT, ["op", "set_flags", "flag", g_iFlags, "ppd", g_iPricePerDay]));
} else if(llJsonGetValue(m,["op"]) == "get_textures")
{
llRegionSayTo(i,c,llList2Json(JSON_OBJECT, ["op", "set_textures", "txt", g_sTextureSet]));
}
}
changed(integer c){
if(c & CHANGED_INVENTORY)
{
llResetScript();
}
}
dataserver( key queryid, string data )
{
if(HasDSRequest(queryid) != -1)
{
list lMeta = GetMetaList(queryid);
if(llList2String(lMeta,0) == "read")
{
if(data==EOF)
{
DeleteDSReq(queryid);
llSay(0, "Server is now ready");
}else{
integer iLine = (integer)llList2String(lMeta,1);
if(data=="" || llGetSubString(data,0,0)=="#")jump next;
list lTmp = llParseStringKeepNulls(data,[" = "], []);
if(llList2String(lTmp,0) == "Admin")
{
g_lAdminTag += [llList2String(lTmp,1)];
}else if(llList2String(lTmp,0) == "Manager")
{
g_lManagerTag += [llList2String(lTmp,1)];
} else if(llList2String(lTmp,0) == "TextureLogo")
{
g_sTextureSet = llJsonSetValue(g_sTextureSet, ["logo"], llList2String(lTmp,1));
} else if(llList2String(lTmp,0) == "TextureOffline")
{
g_sTextureSet = llJsonSetValue(g_sTextureSet, ["offline"], llList2String(lTmp,1));
} else if(llList2String(lTmp,0) == "TextureOnline")
{
g_sTextureSet = llJsonSetValue(g_sTextureSet, ["online"], llList2String(lTmp,1));
} else if(llList2String(lTmp,0) == "TextureAvailable")
{
g_sTextureSet = llJsonSetValue(g_sTextureSet, ["available"], llList2String(lTmp,1));
} else if(llList2String(lTmp,0) == "TextureAvailDeveloper")
{
g_sTextureSet = llJsonSetValue(g_sTextureSet, ["dev"], llList2String(lTmp,1));
}else if(llList2String(lTmp,0) == "NoTexture")
{
g_sTextureSet = llJsonSetValue(g_sTextureSet, ["none"], llList2String(lTmp,1));
} else if(llList2String(lTmp,0) == "SelfLease")
{
integer iEnabled = (integer)llList2String(lTmp,1);
g_iFlags = mask(iEnabled, g_iFlags, 1);
} else if(llList2String(lTmp,0) == "AllowTransferLeases")
{
integer iEnabled = (integer)llList2String(lTmp,1);
g_iFlags = mask(iEnabled, g_iFlags, 2);
}else if(llList2String(lTmp,0) == "LeaseRequiresPayment")
{
integer iEnabled = (integer)llList2String(lTmp,1);
g_iFlags = mask(iEnabled, g_iFlags, 4);
} else if(llList2String(lTmp,0) == "LeasePricePerDay")
{
g_iPricePerDay = (integer)llList2String(lTmp,1);
}
@next;
iLine++;
UpdateDSRequest(queryid, llGetNotecardLine("config", iLine), SetDSMeta(["read", iLine]));
}
}
}
}
}