Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- groups={}
- players={}
- houses={"@1984227","@2365752","@2875713","@2999993","@4052896"}
- function groups_make(name,data)
- if not groups[name] then
- groups[name]={
- name=name
- }
- end
- if data then
- for key,value in pairs(data) do
- groups[name][key]=value
- end
- end
- return groups[name]
- end
- function groups_delete(name)
- if groups[name] then
- groups[name]=nil
- for name,group in pairs(players) do
- players[name]=nil
- end
- return true
- else
- return false
- end
- end
- function groups_priv(name,priv,set)
- if groups[name] then
- groups[name][priv]=set
- return true
- else
- return false
- end
- end
- function groups_get(name)
- return players[name] or groups.public
- end
- function groups_add(name,group)
- if groups[group] then
- players[name]=groups[group]
- return true
- else
- return false
- end
- end
- function groups_remove(name,group)
- if players[name]==groups[group] then
- players[name]=nil
- return true
- else
- return false
- end
- end
- groups_make("public",{
- queuemap=true
- })
- groups_make("admin",{
- playmap=true,
- queuemap=true,
- makegroup=true,
- settime=true,
- setgroup=true,
- sethouse=true,
- setconstants=true
- })
- for name,player in pairs(tfm.get.room.playerList) do
- players[name]=groups.admin
- break
- end
- function eventNewPlayer(name)
- if greeting then
- tfm.exec.chatMessage("<N>"..greeting,name)
- else
- eventChatCommand(name,"help")
- end
- tfm.exec.respawnPlayer(name)
- end
- function eventPlayerDied(name)
- tfm.exec.respawnPlayer(name)
- end
- function eventPlayerWon(name)
- tfm.exec.respawnPlayer(name)
- end
- function eventNewGame()
- queue=nil
- if round_time then
- tfm.exec.setGameTime(round_time)
- end
- end
- function eventLoop(time,remaining)
- local inhouse=tfm.get.room.currentMap==house
- if queue and inhouse then
- tfm.exec.newGame(queue)
- elseif remaining<=500 and not inhouse then
- tfm.exec.setGameTime(5)
- tfm.exec.disableAutoShaman(not queue)
- tfm.exec.newGame(queue or house)
- end
- end
- function eventChatCommand(name,message)
- local args={}
- for arg in message:gmatch("[^%s]+") do
- table.insert(args,arg:lower())
- end
- local privs=groups_get(name)
- message=message:match("%s(.*)") or ""
- if args[1]=="help" then
- tfm.exec.chatMessage("<N><b>Welcome to "..tfm.get.room.name.."</b><br>You can use the following features...",name)
- local cando={}
- if privs.playmap then
- table.insert(cando,{"%s to play a map","np @code"})
- end
- if privs.queuemap then
- table.insert(cando,{"%s to queue a map (play next)","npp @code"})
- end
- if privs.settime then
- table.insert(cando,{"%s to set time to # seconds","set time #"})
- end
- if privs.sethouse then
- table.insert(cando,{"%s to change the tribe house","set house @code"})
- end
- table.insert(cando,{"%s to get groups (or other things)","get groups"})
- for i=1,#cando do
- tfm.exec.chatMessage("<N> • "..cando[i][1]:format("<VP>!"..cando[i][2].."<N>"),name)
- end
- elseif args[1]=="a" then
- tfm.exec.chatMessage("<V>[~Anonymous]<N> "..message)
- elseif args[1]=="np" and privs.playmap then
- local map=args[2] or house
- tfm.exec.chatMessage(" • "..name.." played "..map)
- tfm.exec.newGame(map)
- elseif args[1]=="npp" and privs.queuemap then
- queue=args[2] or house
- tfm.exec.chatMessage(" • "..name.." queued "..queue)
- elseif args[1]=="add" then
- if args[2]=="group" and privs.makegroup then
- groups_make(args[3])
- tfm.exec.chatMessage(" • Added group "..args[3])
- elseif args[2]=="priv" and args[4]=="to" and args[5] then
- if groups_priv(args[5],args[3],true) then
- tfm.exec.chatMessage(" • Added privilege "..args[3].." to "..args[5])
- else
- tfm.exec.chatMessage(" • No such group "..args[5],name)
- end
- elseif args[3]=="to" and args[4] then
- local user=args[2]:gsub("^%l",string.upper)
- if groups_add(user,args[4]) then
- tfm.exec.chatMessage(" • Added "..user.." to "..args[4])
- else
- tfm.exec.chatMessage(" • No such group "..args[4],name)
- end
- end
- elseif args[1]=="remove" then
- if args[2]=="group" then
- if groups_delete(args[3]) then
- tfm.exec.chatMessage(" • Removed group "..args[3])
- else
- tfm.exec.chatMessage(" • No such group "..args[3],name)
- end
- elseif args[2]=="priv" and args[4]=="from" and args[5] then
- if groups_priv(args[5],args[3],false) then
- tfm.exec.chatMessage(" • Removed privilege "..args[3].." from "..args[5])
- else
- tfm.exec.chatMessage(" • No such group "..args[5],name)
- end
- elseif args[3]=="from" and args[4] then
- local name=args[2]:gsub("^%l",string.upper)
- if groups_remove(name,args[4]) then
- tfm.exec.chatMessage(" • Removed "..name.." from "..args[4])
- else
- tfm.exec.chatMessage(" • "..name.." isn't in "..args[4],name)
- end
- end
- elseif args[1]=="get" then
- if args[2]=="groups" then
- for group,data in pairs(groups) do
- local privs={}
- for priv,set in pairs(data) do
- if set==true then
- table.insert(privs,priv)
- end
- end
- tfm.exec.chatMessage(" • "..group.." ("..table.concat(privs,", ")..")",name)
- end
- elseif args[2] then
- tfm.exec.chatMessage(" • "..args[2].." = "..tostring(_G[args[2]]),name)
- end
- elseif args[1]=="set" then
- if args[2]=="house" and privs.sethouse then
- house=args[3] or houses[math.random(#houses)]
- tfm.exec.chatMessage(" • Room house set to "..house)
- elseif args[2]=="time" and privs.settime and tonumber(args[3]) then
- tfm.exec.setGameTime(tonumber(args[3]),args[4]=="relative")
- tfm.exec.chatMessage(" • Set time to "..args[3].."s")
- elseif privs.setconstants then
- args[3]=message:match("%s(.*)")
- args[3]=tonumber(args[3]) or args[3]
- if not args[3] or not _G[args[2]] or type(args[3])==type(_G[args[2]]) then
- _G[args[2]]=args[3]
- tfm.exec.chatMessage(" • Set "..args[2].." = "..tostring(args[3]),name)
- else
- tfm.exec.chatMessage(" • "..args[2].." is not a "..type(args[3]).."!",name)
- end
- end
- end
- end
- groups_add("Fxie","admin")
- eventChatCommand("Fxie","set house")
- tfm.exec.disableAutoNewGame(true)
- for i,command in ipairs({"a","np","npp","get","set","add","remove"}) do
- system.disableChatCommandDisplay(command)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement