1
0
mirror of https://github.com/SWProBuilders/stormworks-tools.git synced 2025-06-15 04:07:25 +00:00
stormworks-tools/CustomCommandsV2.lua
Tobias Lenhardt 54e8c03a31
Update CustomCommandsV2.lua
Signed-off-by: Tobias Lenhardt <hammer@ht-dev.de>
2022-08-04 12:49:13 +02:00

8 lines
7.4 KiB
Lua

-- Author: Hammer1279
-- GitHub: https://github.com/Hammer1279
-- Repository: https://github.com/SWProBuilders/stormworks-tools
-- Workshop: https://steamcommunity.com/id/hammer1279/myworkshopfiles
--This code is the intellectual property of me and you do not hold any rights to this, do not copy or use this unless you got the clear ok from me!--
w="&peer="v="CCV2_Hide"u="Could not find User with PeerID "t="[Server]"s="/command?cmd="r="&steam_id="q="&user="p="default"o="/life?type="n="CCV2_Item"m="Error Giving Item"l=""k='[CCV2]'j="server"i="CCV2_Godmode"h="&server="g="/connection?type="f="autoauth"e="&admin="d="&auth="c="[CCV2]"b="&state="a="You forgot the PeerID"_=8080;function toboolean(x)local y=false;if x=="true"then y=true end;return y end;function getPlayer(z)local A=server.getPlayers()for B,C in pairs(A)do if C.id==z then return C end end end;function getindex(table,D)local E={}for k,v in pairs(table)do E[v]=k end;return E[D]end;function getEquipmentID(F)table={"diving","firefighter","scuba","parachute","arctic","binoculars","cable","compass","defibrillator","fire_extinguisher","first_aid","flare","flaregun","flaregun_ammo","flashlight","hose","night_vision_binoculars","oxygen_mask","radio","radio_signal_locator","remote_control","rope","strobe_light","strobe_light_infrared","transponder","underwater_welding_torch","welding_torch","coal","hazmat","radiation_detector","c4","c4_detonator","speargun","speargun_ammo","pistol","pistol_ammo","smg","smg_ammo","rifle","rifle_ammo","grenade","machine_gun_ammo_box_k","machine_gun_ammo_box_he","machine_gun_ammo_box_he_frag","machine_gun_ammo_box_ap","machine_gun_ammo_box_i","light_auto_ammo_box_k","light_auto_ammo_box_he","light_auto_ammo_box_he_frag","light_auto_ammo_box_ap","light_auto_ammo_box_i","rotary_auto_ammo_box_k","rotary_auto_ammo_box_he","rotary_auto_ammo_box_he_frag","rotary_auto_ammo_box_ap","rotary_auto_ammo_box_i","heavy_auto_ammo_box_k","heavy_auto_ammo_box_he","heavy_auto_ammo_box_he_frag","heavy_auto_ammo_box_ap","heavy_auto_ammo_box_i","battle_shell_k","battle_shell_he","battle_shell_he_frag","battle_shell_ap","battle_shell_i","artillery_shell_k","artillery_shell_he","artillery_shell_he_frag","artillery_shell_ap","artillery_shell_i","chemlight","bomb_disposal","chest_rig","black_hawk_vest","plate_vest","armor_vest"}return getindex(table,F)end;function uri(G)return G:gsub("%%","%%25"):gsub("%s","%%20"):gsub("%!","%%21"):gsub("%#","%%23"):gsub("%$","%%24"):gsub("%&","%%26"):gsub("%'","%%27"):gsub("%(","%%28"):gsub("%)","%%29"):gsub("%*","%%2A"):gsub("%+","%%2B"):gsub("%,","%%2C"):gsub("%/","%%2F"):gsub("%:","%%3A"):gsub("%;","%%3B"):gsub("%=","%%3D"):gsub("%?","%%3F"):gsub("%@","%%40"):gsub("%[","%%5B"):gsub("%]","%%5D")end;function onTick(H)if not g_savedata[j]then g_savedata[j]=p end end;function onCreate(I)if not g_savedata[j]then g_savedata[j]=p end;server.notify(-1,"Custom Commands V2","Successfully loaded Plugin",9)server.httpGet(_,"/start?is_world_create="..tostring(I)..h..tostring(g_savedata[j]))end;function onPlayerJoin(J,K,z,L,M)if J then server.announce(t,K.." joined the game")server.announce(c,"All available Commands: (only when Authed)",z)server.announce(l,"?revive [Peer_ID] - Revive someone",z)server.announce(l,"?heal [Peer_ID] - Heal someone",z)server.announce(l,"---",z)server.announce(l,"Feel free to join our Discord:",z)server.announce(l,"https://swprobuilders.com",z)server.httpGet(_,g.."join"..q..uri(K)..w..z..r..J..h..tostring(g_savedata[j])..e..tostring(L)..d..tostring(M))server.httpGet(_,"/info")if g_savedata[f]then server.addAuth(z)end end end;function onPlayerLeave(J,K,z,L,M)server.announce(t,K.." left the game")server.httpGet(_,g.."leave"..q..uri(K)..w..z..r..J..h..tostring(g_savedata[j])..e..tostring(L)..d..tostring(M))end;function onPlayerDie(J,K,z,L,M)server.announce(t,K.." died")server.httpGet(_,o.."die"..q..uri(K)..w..z..r..J..h..tostring(g_savedata[j])..e..tostring(L)..d..tostring(M))end;function onPlayerRespawn(z)local p=getPlayer(z)server.httpGet(_,o.."respawn"..q..uri(p.name)..w..z..r..p.steam_id..h..tostring(g_savedata[j])..e..tostring(p.admin)..d..tostring(p.auth))end;function onVehicleUnload(N)end;function onCustomCommand(O,z,P,Q,R,S,T,U,V,W)local X=getPlayer(z)if R:lower()=="?item"and(P or z==0)then local F=getEquipmentID(S)local Y=tonumber(T)local Z=tonumber(U)local a0=tonumber(V)local a1=false;local a2,a3=server.getPlayerCharacterID(z)local a4=server.setCharacterItem(a2,Y,F,a1,Z,a0)if a4 then server.announce(n,"Item Given",z)else server.announce(n,m,z)end end;if R:lower()=="?give"and(P or z==0)then local a5=tonumber(S)local F=getEquipmentID(T)local Y=tonumber(U)local Z=tonumber(V)local a0=tonumber(W)local a1=false;local a2,a3=server.getPlayerCharacterID(a5)local a4=server.setCharacterItem(a2,Y,F,a1,Z,a0)if a4 then server.announce(n,X.name.." gave "..T.." in Slot "..U,a5)server.announce(n,"Item Given to "..getPlayer(a5).name,z)else server.announce(n,m,z)end end;if R:lower()=="?godmode"and(P or z==0)then local a2,a3=server.getPlayerCharacterID(z)local a6=toboolean(S)local N,a4=server.getCharacterVehicle(a2)a4=server.setVehicleInvulnerable(N,a6)if a4 then server.announce(i,"Godmode set",z)else server.announce(i,"Error setting Godmode",z)end end;if R:lower()=="?hide"and(P or z==0)then local a2,a3=server.getPlayerCharacterID(z)local a7=toboolean(S)local N,a4=server.getCharacterVehicle(a2)a4=server.setVehicleShowOnMap(N,a7)if a4 then server.announce(v,"Hide set",z)else server.announce(v,"Error setting hide",z)end end;if R:lower()=="?autoauth"and(P or z==0)then if not g_savedata[f]then server.announce(k,"AutoAuth has been Enabled")server.httpGet(_,s..f..b.."on"..q..uri(X.name)..w..z..r..X.steam_id..h..tostring(g_savedata[j])..e..tostring(P)..d..tostring(Q))g_savedata[f]=true else server.announce(k,"AutoAuth has been Disabled")server.httpGet(_,s..f..b.."off"..q..uri(X.name)..w..z..r..X.steam_id..h..tostring(g_savedata[j])..e..tostring(P)..d..tostring(Q))g_savedata[f]=false end end;if R:lower()=="?setServer"and(P or z==0)then g_savedata[j]=S;server.announce(k,"Server Name set to "..S)server.httpGet(_,s.."setServer"..b..S..q..uri(X.name)..w..z..r..X.steam_id..h..tostring(g_savedata[j])..e..tostring(P)..d..tostring(Q))end;if R:lower()=="?kill"and(P or z==0)then if not S then server.announce(c,a,z)else local a2,a4=server.getPlayerCharacterID(tonumber(S))if a4 then local p=getPlayer(tonumber(S))server.killCharacter(a2)server.announce(c,X.name.." killed "..p.name)server.httpGet(_,s.."kill"..b..p.id..q..uri(X.name)..w..z..r..X.steam_id..h..tostring(g_savedata[j])..e..tostring(P)..d..tostring(Q))else server.announce(c,u..S,z)end end end;if R:lower()=="?revive"and(Q or z==0)then if not S then server.announce(c,a,z)else local a2,a4=server.getPlayerCharacterID(tonumber(S))if a4 then local a8=100;server.reviveCharacter(a2)server.setCharacterData(a2,a8,true,false)local p=getPlayer(tonumber(S))server.announce(c,X.name.." revived "..p.name)server.httpGet(_,s.."revive"..b..p.id..q..uri(X.name)..w..z..r..X.steam_id..h..tostring(g_savedata[j])..e..tostring(P)..d..tostring(Q))else server.announce(c,u..S,z)end end end;if R:lower()=="?heal"and(Q or z==0)then if not S then server.announce(c,a,z)else local a2,a4=server.getPlayerCharacterID(tonumber(S))if a4 then local a8=100;server.setCharacterData(a2,a8,true,false)local p=getPlayer(tonumber(S))server.announce(c,X.name.." healed "..p.name)server.httpGet(_,s.."heal"..b..p.id..q..uri(X.name)..w..z..r..X.steam_id..h..tostring(g_savedata[j])..e..tostring(P)..d..tostring(Q))else server.announce(c,u..S,z)end end end end;function httpReply(a9,aa,ab)end