Skip to content

Instantly share code, notes, and snippets.

@leegao
Created May 18, 2009 18:52
Show Gist options
  • Save leegao/113670 to your computer and use it in GitHub Desktop.
Save leegao/113670 to your computer and use it in GitHub Desktop.
if flacko==nil then flacko={} end
flacko.admins={}
function flacko.admins.split(t,b)
return toTable()
end
function toTable(t, b) --By leegao--
local cmd = {}
local match = "[^%s]+"
if b then
match = "%w+"
end
if type(b) == "string" then match = "[^"..b.."]+" end
if not t then return invalid() end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
function flacko.admins.message(color,txt,center)
if(center==0) then
parse("sv_msg ©"..color..txt)
elseif(center==1) then
parse("sv_msg ©"..color..txt.."@C")
end
--PARAMETERS: 1-RGB| 2-Text| 3-Centered?
end
function initArray(m,t)
local array = {}
for i = 1, m do
array[i]=t
end
return array
end
flacko.admins.playerpower = initArray(32,0)
flacko.admins.password = {"pwn2d","flacko"}
addhook("say","flacko.admins.say")
function flacko.admins.say(id,txt)
if(string.find(txt,"!")) then
local text = toTable(txt)
if(text[1]=="!login") then
for i=0 , 3 do
if(text[2]==flacko.admins.password[i]) then
flacko.admins.playerpower[id] = i
parse("sv_msg2 "..id.." Logged in! @C")
return 1
end
end
end
if(string.find(txt,"!say")) then
local message
message = string.gsub(txt,"!say","")
if(flacko.admins.playerpower[id]==1) then
flacko.admins.message("000255000",player(id,"name").."(MOD) Says:"..message,0)
return 1
end
if(flacko.admins.playerpower[id]==2) then
flacko.admins.message("255255255",player(id,"name").."(ADMIN) Says:"..message,0)
return 1
end
end
if(text[1]=="!byteam") then
if(flacko.admins.playerpower[id]>=1) then
for i=1,32 do
local name = player(i,"name")
if (string.find(name, text[2])) then
parse("maket "..i)
elseif(string.find(name, text[3])) then
parse("makect "..i)
end
end
return 1
end
end
if(text[1]=="!swapteams") then
if(flacko.admins.playerpower[id]>=1) then
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
return 1
end
end
if(text[1]=="!ban") then
if(flacko.admins.playerpower[id]==2) then
flacko.admins.message("000255255",player(id,"name").."(ADMIN) Says: I've banned "..player(text[2],"name"),0)
parse("banname "..text[2])
return 1
end
end
if(text[1]=="!changeteam") then
if(flacko.admins.playerpower[id]>=1) then
if(text[3]=="1") then
parse("maket "..text[2])
elseif(text[3]=="2") then
parse("makect "..text[2])
elseif(text[3]=="3") then
parse("makespec "..text[2])
end
return 1
end
end
if(text[1]=="!kick") then
if(flacko.admins.playerpower[id]>=1) then
parse("kick "..text[2])
end
end
end
end
addhook("parse","flacko.admins.parse")
function flacko.admins.parse(cmd)
local text = toTable(cmd)
if(text[1]=="!set_admin_pass") then
flacko.admins.password[2] = text[2]
return 2
end
if(text[1]=="!set_mod_pass") then
flacko.admins.password[1] = text[2]
return 2
end
if(cmd=="!unlogall") then
for i=1,32 do
flacko.admins.playerpower[i]=0
end
return 2
end
end
addhook("leave","flacko.admins.leave")
function flacko.admins.leave(id)
flacko.admins.playerpower[id] = 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment