Skip to content

Instantly share code, notes, and snippets.

@FloooD
Created May 5, 2011 06:02
Show Gist options
  • Select an option

  • Save FloooD/956606 to your computer and use it in GitHub Desktop.

Select an option

Save FloooD/956606 to your computer and use it in GitHub Desktop.
flood's lame admin system
admins={} --ADMIN TABLE HERE
------usgn id---name----@say color
admins[13962]={"FlooD","080210255"}
------^^^^^^^CHANGE TO ADD/REMOVE ADMINS
timeouts={}
for i=1,32 do
timeouts[i]={0,0}
end
lock={[0]=0,0,0}
names={[0]="Spectator","Terrorist","Counter-Terrorist"}
addhook("spawn","spawn")
function spawn(p)
if game("mp_startmoney")=="16000" then
parse("setmoney "..p.." 16000")
end
end
addhook("leave","leave")
function leave(p,r)
timeouts[p]={0,0}
if r==1 then
msg(player(p,"name").." has left the game (ping timeout).")
end
end
addhook("serveraction","serveraction")
function serveraction(p,a)
if a==3 then
if os.time()>timeouts[p][2] then
parse("setscore "..p.." 0; setdeaths "..p.." 0")
msg("©255000000"..player(p,"name").." reset his score. Press F4 to reset your score.")
timeouts[p][2]=os.time()+10
else
msg2(p,"©255100000Don't spam resetscore. You may reset once every 10 seconds.")
end
end
end
addhook("say","say")
function say(p,t)
if string.sub(t,1,1)=="!" then
local cmd=t:gsub("%s.*","")
if cmd=="!broadcast" then
if os.time()>timeouts[p][1] then
msg("©100255000"..player(p,"name").." (BROADCAST): "..string.sub(t,12))
msg2(p,"©255100000You have 15 seconds before your next broadcast.")
timeouts[p][1]=os.time()+15
else
msg2(p,"©255100000You may not broadcast for "..timeouts[p][1]-os.time().." more seconds.")
end
elseif cmd=="!resetscore" then
if os.time()>timeouts[p][2] then
parse("setscore "..p.." 0; setdeaths "..p.." 0")
msg("©255000000"..player(p,"name").." reset his score. Type !resetscore to reset your score.")
timeouts[p][2]=os.time()+10
else
msg2(p,"©255100000Don't spam resetscore. You may reset once every 10 seconds.")
end
else
msg2(p,"©255100000"..cmd.."is an invalid command.")
end
return 1
elseif string.sub(t,1,1)=="@" then
local usgn=player(p,"usgn")
if admins[usgn] or player(p,"rcon") then
local cmd=t:gsub("%s.*","")
local color=admins[usgn] and admins[usgn][2] or "000000000"
local name=admins[usgn] and admins[usgn][1] or "ADMIN"
if cmd=="@say" then
msg("©"..color..player(p,"name").." ("..name.."): "..string.sub(t,6))
else
parse("echo "..player(p,"name").." "..player(p,"ip")..":"..player(p,"port").." "..usgn.." used "..t)
msg("©255000000"..player(p,"name").." ("..name..") used "..cmd)
parse(string.sub(t,2))
end
else
msg2(p,"©255100000You are not an admin.")
end
return 1
end
end
addhook("parse","_parse")
function _parse(t)
local cmd=t:gsub("%s.*","")
if cmd=="lock" then
local tm=tonumber(string.sub(t,6))
if not tm then
if lock[0]==0 and lock[1]==0 and lock[2]==0 then
lock={[0]=1,1,1}
msg("©255000000All teams locked.")
else
lock={[0]=0,0,0}
msg("©255000000All teams unlocked.")
end
elseif lock[tm]==0 then
lock[tm]=1
msg("©255000000"..names[tm].." team locked.")
elseif lock[tm]==1 then
lock[tm]=0
msg("©255000000"..names[tm].." team unlocked.")
end
return 2
elseif string.lower(string.sub(t,1,4))=="make" and string.find(t,"\"") then
local i=tonumber(string.sub(t,string.find(t,"%d"),string.len(t)-1))
local temp=lock
lock={[0]=0,0,0}
parse(t:gsub("%s.*","").." "..i)
lock=temp
return 2
elseif cmd=="switchteams" then
local temp=lock
lock={[0]=0,0,0}
for i=1,32 do
if player(i,"team")==1 then
parse("makect "..i)
elseif player(i,"team")==2 then
parse("maket "..i)
end
end
lock=temp
return 2
elseif cmd=="specall" then
local temp=lock
lock={[0]=0,0,0}
for i=1,32 do
if player(i,"exists") then
parse("makespec "..i)
end
end
lock=temp
return 2
end
end
addhook("rcon","rcon")
function rcon(t,p,ip)
msg("©255000000"..(p==0 and "EXTERNAL RCON: "..ip or player(p,"name")).." used rcon "..t:gsub("%s.*",""))
end
addhook("team","team")
function team(p,tm)
if lock[player(p,"team")]==1 then
msg2(p,"©255100000Your team is locked.")
return 1
elseif lock[tm]==1 then
msg2(p,"©255100000The "..names[tm].." team is locked.")
return 1
end
end
@leegao

leegao commented Jul 9, 2011

Copy link
Copy Markdown

xD, tokenizing and then parsing is still much easier :P

@leegao

leegao commented Jul 9, 2011

Copy link
Copy Markdown

btw, where have you been? o_O

@FloooD

FloooD commented Jul 9, 2011

Copy link
Copy Markdown
Author

uh every day = summer classes + working in lab + badminton

@FloooD

FloooD commented Jul 9, 2011

Copy link
Copy Markdown
Author

oh btw i wrote this like a year ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment