Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 03/04/2016
- --Last update: 26/05/2016
- --[[ Notes:
- Does:
- Permite que você divulgue sua tribo.
- Commands:
- !
- infotribe --> Liberado apenas ao primeiro jogador na sala que for da tribo X, ele poderá publicar a tribo adicionando uma descrição e quem pode recrutar.
- share --> Publica após fazer o !infotribe
- adm --> Dá a administração da publicação a outro jogador da mesma tribo.
- Player --> Jogador
- new --> Refaz a publicação do !infotribe
- remove --> Remove a publicação do +Tribes
- ]]--
- table.find=function(list,value)
- local found,keys,times = false,{},0
- for k,v in next,list do
- if type(v) ~= "table" then
- if v == value then
- found = true
- keys[#keys+1] = k
- times = times + 1
- end
- else
- local a,b,c = table.find(v,value)
- if not found then found = a end
- if b then table.insert(keys,table.unpack(b)) end
- if c then times = times + c end
- end
- end
- return found,keys,times
- end
- string.nick=function(player)
- return player:lower():gsub('%a',string.upper,1)
- end
- table.destroy=function(list,value)
- for k,v in next,list do
- if v == value then
- table.remove(list,k);break
- end
- end
- end
- mice={}
- tribeList={}
- tribeShared={}
- eventNewPlayer=function(n)
- mice[n]={
- tribe=tfm.get.room.playerList[n].tribeName,
- description={"",""},
- id=99,
- shared=false,
- on=false,
- timer=os.time(),
- }
- if mice[n].tribe ~= nil and not table.is(tribeList,mice[n].tribe) then
- table.insert(tribeList,mice[n].tribe)
- _G[mice[n].tribe:gsub("%s","_").."admin"] = n
- end
- ui.addTextArea(0,"<PT><p align='center'><a href='event:tribelist'>+Tribes",n,745,375,50)
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- eventPlayerLeft=function(n)
- if table.is(tribeList,mice[n].tribe) then
- _G[mice[n].tribe:gsub("%s","_").."admin"] = nil
- table.destroy(tribeList,mice[n].tribe)
- end
- end
- eventChatCommand=function(n,c)
- local p={}
- for v in c:gmatch('[^%s]+') do table.insert(p,v) end
- if p[1]:lower()=="infotribe" and mice[n].shared==false and _G[mice[n].tribe:gsub("%s","_").."admin"]==n and mice[n].tribe ~= nil then
- local texts={"Write a short description of your tribe.\n@ = Break line","Quote the leaders of the tribe, or who could recruit someone"}
- local y={30,130}
- for i=0,1 do
- ui.addPopup(i,2,texts[i+1],n,5,y[i+1],790,true)
- end
- end
- if p[1]:lower()=="share" and _G[mice[n].tribe:gsub("%s","_").."admin"]==n and mice[n].description[1]~="" and mice[n].description[2]~="" then
- mice[n].shared=true
- table.insert(tribeShared,{n,"<J>Tribe Name : <V>"..mice[n].tribe.."\n<J>Description : <PT>"..mice[n].description[1].."\n<R>Leaders : <J>"..mice[n].description[2].."\n<ROSE>Publisher : <a href='event:@"..n.."'>"..n.."</a>"})
- end
- if p[1]:lower()=="adm" and p[2] and mice[n].tribeList == mice[string.nick(p[2])].tribeList and _G[mice[n].tribe:gsub("%s","_").."admin"]==n then
- _G[mice[n].tribe:gsub("%s","_").."admin"] = string.nick(p[2])
- end
- if (p[1]:lower()=="new" or p[1]:lower()=="remove") and _G[mice[n].tribe:gsub("%s","_").."admin"]==n then
- mice[n].shared=false
- for i = 1,2 do
- mice[n].description[i]=""
- end
- end
- end
- for _,c in next,{'infotribe','share','adm','new','remove'} do
- system.disableChatCommandDisplay(c,true)
- end
- eventPopupAnswer=function(i,n,c)
- if i == 0 then
- mice[n].description[1] = (#c>10 and c:gsub("%s*@%s*","\n",3) or "<R>No description")
- end
- if i == 1 then
- mice[n].description[2] = (#c>2 and c or "<R>No leaders")
- end
- end
- F_tribeList=function(n)
- local t = ""
- local d = {}
- for i in next,tribeShared do
- if mice[tribeShared[i][1]].shared == true then
- t = t .. tribeShared[i][2] .. '\n\n'
- else
- table.insert(d,i)
- end
- end
- for i,v in next,d do
- table.remove(tribeShared,v)
- end
- ui.addTextArea(1,t,n,10,30,780,300)
- end
- eventTextAreaCallback=function(i,n,c)
- if c=='tribelist' then
- if mice[n].on then
- ui.removeTextArea(1,n)
- ui.updateTextArea(0,"<PT><p align='center'><a href='event:tribelist'>+Tribes",n)
- else
- F_tribeList(n)
- ui.updateTextArea(0,"<PT><p align='center'><a href='event:tribelist'>-Tribes",n)
- end
- mice[n].on=not mice[n].on
- end
- if c:sub(1,1)=="@" and os.time()>mice[n].timer and n~=c:sub(2) then
- mice[n].timer = os.time() + 20000
- c = c:sub(2)
- mice[c].id = mice[c].id+1
- ui.addTextArea(mice[c].id,"<J>The player <V>"..n.." <J>want to visit your tribe :)\nName : <V>"..n.."\n<J>Current tribe : <V>"..(mice[n].tribe or "<R>There's no tribe.").."\n<p align='center'><R><a href='event:closemessage'>Close</a>",c)
- ui.addTextArea(10000,"<J>You sent a solicitation to <V>"..c.."<J>, just wait!\n<p align='center'><R><a href='event:closead'>Close</a>",n)
- end
- if c == 'closemessage' then
- ui.removeTextArea(mice[n].id)
- mice[n].id=mice[n].id-1
- end
- if c == 'closead' then
- ui.removeTextArea(10000,n)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement