Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Author: Nettoork#0000
- OBS: Script 90% terminado, falta os menus.
- ]]--
- userPrivilege = {
- owner = {users = {'Nettoork#0000', 'Sandstorm#4261'}},
- admin = {users = {}},
- moderator = {users = {}},
- vip = {users = {}},
- member = {users = {}}
- }
- textContent = {
- buyVipMessage = 'Que tal comprar vip? Só falar com um dos donos!',
- welcomeMessage = 'Seja Bem-vindo ao cafofo da tribo!',
- noPlayers = 'Não há jogadores online nesta categoria',
- yePlayers = function(a, b) return string.format('Jogadores %s online: %s', a, b) end
- }
- rankPrivilege = {
- owner = {tag = '<font color="#00FFF9">Owner</font>', permissions = {'nick', 'me', 'all', 'others'}, commands = {':admin'}},
- admin = {tag = '<font color="#FF0000">Admin</font>', permissions = {'nick', 'me', 'all', 'others'}, commands = {':moderator', 'cheese', 'hole', 'shaman', 'kill'}},
- moderator = {tag = '<font color="#00FFBD">Moderator</font>', permissions = {'nick', 'me', 'all'}, commands = {':vip', 'nextmap', 'np', 'score', 'maptime'}},
- vip = {tag = '<font color="#F2FF00">Vip</font>', permissions = {'nick', 'me'}, commands = {':member', 'up', 'meep', 'vamp', 'snow', 'respawn', 'blackname', 'tp', 'explode'}},
- member = {tag = '<font color="#02FF00">Member</font>', permissions = {'me'}, commands = {'dance', 'confetti'}}
- }
- function rankCommands()
- for i, v in next, {'member', 'vip', 'moderator', 'admin', 'owner'} do
- for o, a in next, rankPrivilege[v].commands do
- if a:sub(1, 1) == ':' then
- for _, __ in next, rankPrivilege[a:sub(2, #a)].commands do
- rankPrivilege[v].commands[#rankPrivilege[v].commands + 1] = __
- end
- table.remove(rankPrivilege[v].commands, o)
- break
- end
- end
- end
- end
- function tableStringToTable(tableC)
- local finalTable = {}
- for i, v in next, tableC do
- finalTable[v] = v
- end
- return finalTable
- end
- function changeTables()
- for i, v in next, rankPrivilege do
- rankPrivilege[i]['commands'] = tableStringToTable(v['commands'])
- rankPrivilege[i]['permissions'] = tableStringToTable(v['permissions'])
- end
- for i, v in next, userPrivilege do
- userPrivilege[i]['users'] = tableStringToTable(v['users'])
- end
- end
- function split(t, s)
- local a={}
- for i in string.gmatch(t, "[^" .. (s or "%s") .. "]+") do
- a[#a + 1] = i
- end
- return a
- end
- function executeCommand(name, cmd, func, meall)
- if meall then
- if not cmd[meall] then return end
- func(cmd)
- elseif cmd[2] == havePermission(name, 'me') then
- func(name)
- elseif cmd[2] == havePermission(name, 'all') then
- table.foreach(tfm.get.room.playerList, func)
- elseif cmd[2] == havePermission(name, 'others') then
- for i in next, tfm.get.room.playerList do
- if i ~= name then
- func(i)
- end
- end
- elseif havePermission(name, 'nick') then
- func(cmd[2])
- end
- end
- function havePermission(name, permission)
- return rankPrivilege[getTagPrivilege(name)[1]].permissions[permission]
- end
- function haveCommand(name, command)
- return rankPrivilege[getTagPrivilege(name)[1]].commands[command]
- end
- function getTagPrivilege(name)
- local rank = {'nothing', '<font color="#FFFFFF">Desconhecido</font>'}
- for i, v in next, userPrivilege do
- if v.users[name] then
- rank = {i, rankPrivilege[i]['tag']}
- end
- end
- return rank
- end
- function buyVipMenu(name)
- ui.addTextArea(5, 'Em construção.', name, 250, 60, 300, 300, 1, 0x324650, 1, true)
- end
- function commandMenu(name)
- ui.addTextArea(5, 'Em construção.', name, 250, 60, 300, 300, 1, 0x324650, 1, true)
- end
- function playersOnlineMenu(name, rank)
- ui.addTextArea(6, '<DE><a href="event:close_playersOnline">'..playersOnline(rank), name, 5, 28, 700, 0, 1, 0x9F9F9F, 0.5, true)
- end
- function playersOnline(rank)
- playersOn={}
- table.foreach(tfm.get.room.playerList, function(p) if rank and getTagPrivilege(p)[1] == rank then playersOn[#playersOn+1] = p end end)
- if playersOn[1] then
- return textContent['yePlayers'](rankPrivilege[rank].tag, table.concat(playersOn, ", "))
- else return textContent['noPlayers'] end
- end
- function eventNewPlayer(name)
- if tfm.get.room.playerList[name].tribeName == tfm.get.room.name:sub(3, #tfm.get.room.name) and getTagPrivilege(name)[1] == 'nothing' then
- userPrivilege.member.users[name] = true
- end
- ui.addTextArea(1, '<font color="#ED3232"> Menu', name, 725, 30, 60, 25 , 0x0e232b, 0x173845, 1, true)
- ui.addTextArea(2, '<p align="center"><a href="event:menu"><font color="#E22E2E"> ▼', name, 726, 32, 60, 25, 0, 0, 0, true)
- ui.addTextArea(3, '<p align="center">Rank:\n'..getTagPrivilege(name)[2], name, 695, 365, 100, 30, 1, 0x9F9F9F, 0.5, true)
- ui.addTextArea(4, '<p align="center"><a href="event:fechar_cmd_1">'..textContent['welcomeMessage'], name, 5, 375, 320, 20, 1, 0x9F9F9F, 0.5, true)
- end
- function eventChatCommand(name, cmd)
- cmd = split(cmd, ' ')
- if cmd[1] == 'owners' or cmd[1] == 'admins' or cmd[1] == 'moderators' or cmd[1] == 'vips' or cmd[1] == 'members' then
- playersOnlineMenu(name, cmd[1]:gsub('s', ''))
- elseif cmd[1] == haveCommand(name, 'cheese') then
- executeCommand(name, cmd, function(name)
- tfm.exec.giveCheese(name)
- end)
- elseif cmd[1] == haveCommand(name, 'hole') then
- executeCommand(name, cmd, function(name)
- tfm.exec.playerVictory(name)
- end)
- elseif cmd[1] == haveCommand(name, 'up') then
- executeCommand(name, cmd, function(name)
- tfm.exec.movePlayer(name, 0, 1)
- end)
- elseif cmd[1] == haveCommand(name, 'meep') then
- executeCommand(name, cmd, function(name)
- tfm.exec.giveMeep(name)
- end)
- elseif cmd[1] == haveCommand(name, 'shaman') then
- executeCommand(name, cmd, function(name)
- tfm.exec.setShaman(name)
- end)
- elseif cmd[1] == haveCommand(name, 'vamp') then
- executeCommand(name, cmd, function(name)
- tfm.exec.setVampirePlayer(name)
- end)
- elseif cmd[1] == haveCommand(name, 'snow') then
- executeCommand(name, cmd, function(config)
- tfm.exec.snow(config[2])
- end, 2)
- elseif cmd[1] == haveCommand(name, 'dance') then
- executeCommand(name, cmd, function(name)
- tfm.exec.playEmote(name, 0)
- end)
- elseif cmd[1] == haveCommand(name, 'confetti') then
- executeCommand(name, cmd, function(name)
- tfm.exec.playEmote(name, 9)
- end)
- elseif cmd[1] == haveCommand(name, 'respawn') then
- executeCommand(name, cmd, function(name)
- tfm.exec.respawnPlayer(name)
- end)
- elseif cmd[1] == haveCommand(name, 'kill') then
- executeCommand(name, cmd, function(name)
- tfm.exec.killPlayer(name)
- end)
- elseif cmd[1] == haveCommand(name, 'blackname') then
- executeCommand(name, cmd, function(name)
- tfm.exec.setNameColor(name, 0x333333)
- end)
- elseif cmd[1] == haveCommand(name, 'nextmap') then
- executeCommand(name, cmd, function()
- tfm.exec.newGame()
- end, 2)
- elseif cmd[1] == haveCommand(name, 'np') then
- executeCommand(name, cmd, function(config)
- tfm.exec.newGame(config[2])
- end, 2)
- elseif cmd[1] == haveCommand(name, 'maptime') then
- executeCommand(name, cmd, function(config)
- tfm.exec.setGameTime(config[2])
- end, 2)
- elseif cmd[1] == haveCommand(name, 'explode') then
- executeCommand(name, cmd, function(name)
- if not tfm.get.room.playerList[name] then return end
- tfm.exec.explosion(tfm.get.room.playerList[name].x, tfm.get.room.playerList[name].y+2, 15, 100)
- end)
- elseif cmd[1] == haveCommand(name, 'score') then
- executeCommand(name, cmd, function(config)
- if config[4] == 'true' then config[4] = true else config[4] = false end
- executeCommand(name, config, function(name)
- if type(name) == 'table' then name = name[2] end
- tfm.exec.setPlayerScore(name, config[3], config[4])
- end)
- end, 4)
- elseif cmd[1] == haveCommand(name, 'tp') then
- executeCommand(name, cmd, function(config)
- if not tfm.get.room.playerList[config[3]] then return end
- executeCommand(name, config, function(config2)
- if not tfm.get.room.playerList[config2] then return end
- tfm.exec.movePlayer(config2, tfm.get.room.playerList[config[3]].x, tfm.get.room.playerList[config[3]].y, false, 0, 0, false)
- end)
- end, 3)
- end
- end
- rankCommands()
- changeTables()
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement