Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Bolodefchoco
- --2015
- --[[ Functions ]]--
- --[[ Serialization ]]--
- serialization={table={},string={}}
- serialization.table.tostring=function(t)
- local str=""
- for index,value in next,t do
- local prefix,tbOption=(type(value)=="string" and "_@" or type(value)=="boolean" and "_!" or type(value)=="number" and "_#" or type(value)=="table" and "_%" or ""),(type(value)~="table" and tostring(value) or "+&"..serialization.table.tostring(value):gsub(";","?").."&-")
- str = str..':'..tostring(index)..prefix..tbOption..";"
- end
- return str
- end
- serialization.string.totable=function(s)
- local list={}
- for str in s:gmatch("(.-);") do
- local varName,valueType,value=str:match(':(.-)_(%p)(.+)')
- if varName~=nil then
- varName=tonumber(varName) or varName
- if valueType=="@" then
- list[varName]=tostring(value)
- elseif valueType=="!" then
- list[varName]=value=="true"
- elseif valueType=="#" then
- list[varName]=tonumber(value)
- elseif valueType=="%" then
- list[varName]={serialization.string.totable(value:gsub("+&",""):gsub("&-",""):gsub("%?",";"))}
- end
- end
- end
- return list
- end
- --[[ Tables ]]--
- table.concat=function(t,sep,i,j)
- i=i or 1;
- j=j or #t;
- sep=sep or "";
- local _="";
- for k,v in next,t do
- if k>=i and k<=j then
- _=_..v..sep
- end
- end
- return _:sub(1,#_-#sep)
- end
- table.destroy=function(_table,value)
- for _,__ in next,_table do
- if value==__ then table.remove(_table,_);break
- end
- end
- end
- table.find=function(_table,value)
- local _,__=false,nil
- for ___,____ in next,_table do
- if value==____ then
- _=true;__=___;break
- end
- end
- return _,__
- end
- --[[ Strings ]]--
- string.equal=function(string1,string2)
- string1,string2=string.split(string1,1,"%S"),string.split(string2,1,"%S")
- local _=#string1>#string2 and #string2 or #string1
- local __,___=0,0
- for ____=1,_ do
- if string1[____]==string2[____] then __=__+1
- else ___=___+1 end
- end
- return __>=___,__/#string1*100
- end
- string.nick=function(player)
- local _=1
- if player:find("^%p") then _=2 end
- return player:sub(1,_):upper()..player:sub(_+1):lower()
- end
- string.split=function(string,_type,split)
- local _={}
- for __ in string.gmatch(string,(_type==0 and '[^'..(split or '%s')..']+' or _type==1 and split)) do
- table.insert(_,__)
- end
- return _
- end
- --[[ addEvent ]]--
- event={}
- addEvent=function(v,f)
- local c=0
- v=v:lower()
- event[v]=event[v] or {}
- for _ in next,event[v] do
- c = c + 1
- end
- event[v]["e"..c+1]=f
- return "e"..c+1
- end
- do
- for e,f in next,{
- "Loop",
- "TextAreaCallback",
- "PopupAnswer",
- "ChatMessage",
- } do
- _G["event"..f]=function(...)
- for g,h in next,event[f:lower()] or {} do
- h(...)
- end
- end
- end
- end
- --[[ Tables ]]--
- interface={
- [1] = "main",
- [2] = "updateNews",
- [3] = "timelines",
- [4] = "friends",
- [5] = "profile",
- [6] = "search",
- [7] = "chat",
- }
- system={}
- mice={}
- --[[ News ]]--
- system.news={
- [1] = "$ is more expensive than £",
- [2] = "Dilma sucked Lula, said TV Globo",
- [3] = "Satan is the newest god!",
- [4] = "Bolodefchoco has the biggest dick ever, says Sasha Grey",
- }
- --[[ Variables ]]--
- --[[ Timers ]]--
- system.newsTimer = os.time() + 20000
- --[[ Interfaces ]]--
- do
- for id,f in next,interface do
- interface[f] = function(...)
- local values = {...}
- local text = ui.addTextArea
- local n = values[1]
- if id == 1 then -- Main
- text(0,"",n,5,2,790,500,1,1,1)
- text(1,"",n,318,130,25,25,0x324650,1,1)
- text(2,"<font size='20'><J>☎",n,318,129,30,30,0x324650,1,0)
- text(3,"",n,359,130,25,25,0x324650,1,1)
- text(4,"",n,30,105,740,20,0x192f39,0x192f39,1)
- text(5,"",n,5,24,790,72,0x2e6581,0x2e6581,1)
- text(6,"<p align='center'><font size='35'>TFM SCNetwork ©",n,5,36,790,50,0x324650,1,0)
- text(7,"<p align='center'><font size='25'><V><a href='event:timelines'>Timelines</a>",n,5,174,200,35,0x224557,0x224557,1)
- text(8,"<p align='center'><font face='Impact' size='25'><V><a href='event:@"..n.."'>"..n,n,5,134,245,35,0x103e55,0x103e55,1)
- text(9,"<p align='center'><font size='25'><V><a href='event:friends'>Friends</a>",n,5,214,200,35,0x224557,0x224557,1)
- text(10,"<p align='center'><font size='25'><V><a href='event:chat'>Chat</a>",n,5,254,200,34,0x224557,0x224557,1)
- text(11,"<p align='center'><font size='25'><V><a href='event:search'>Search</a>",n,5,294,200,35,0x224557,0x224557,1)
- text(12,"<p align='center'><font size='25'><V>??????",n,5,334,200,35,0x224557,0x224557,1)
- text(13,"<font size='20'><J>★",n,359,129,30,30,0x324650,1,0)
- text(14,"[News] : "..system.news[math.random(#system.news)],n,40,105,720,30,0x192f39,0x192f39,0)
- end
- if id == 2 then -- updateNews
- ui.updateTextArea(14,"[News] : "..system.news[math.random(#system.news)],n)
- end
- if id == 3 then -- Timelines
- local e = values[2]
- if not e then
- local txt = ""
- for i,v in next,mice[n].timelines[1] do
- txt = (type(v)=="table" and v[2] or v) .. '\n' .. txt
- end
- if #txt > 1999 then
- mice[n].timelines[1] = {}
- txt = ""
- end
- text(15,"<G><B>[<U><BL><a href='event:newpost'>Publicar</a></BL> ||| <BL><a href='event:resettimelines'>Reset Page</a></BL></U>]</B></G>\n\n"..txt,n,232,185,555,205,0x1c3d3c,0x1c3d3c,1)
- else
- ui.removeTextArea(15,n)
- end
- end
- if id == 4 then -- Friends
- local e = values[2]
- if not e then
- local friendlist={}
- table.sort(mice[n].friends[1])
- for i = 1,#mice[n].friends[1] do
- local name = mice[n].friends[1][i]
- table.insert(friendlist,(tfm.get.room.playerList[name] and "<PT>" or "<R>").."<a href='event:@"..name.."'>"..name.."</a> "..(table.find(mice[name].friends[1],n) and "<VP>" or "<R>").."•")
- end
- text(16,"",n,232,185,555,205,0x224462,0x224462,1)
- text(17,(#friendlist>0 and table.concat(friendlist,'\n',1,15) or "<BL>Empty :("),n,233,185,555,205,1,1,0)
- text(18,table.concat(friendlist,'\n',16,31) or "",n,377,185,132,205,1,1,0)
- text(19,table.concat(friendlist,'\n',32,47) or "",n,521,185,132,205,1,1,0)
- text(20,table.concat(friendlist,'\n',48,63) or "",n,665,185,132,205,1,1,0)
- else
- for i = 16,20 do
- ui.removeTextArea(i,n)
- end
- end
- end
- if id == 5 then -- Profile
- local p,e = values[2],values[3]
- if not e and mice[p] then
- local register,friends,lastConnection = mice[p].profile[1],#mice[p].friends[1],mice[p].profile[4]
- local nickname = (mice[p].profile[2]=="" and (n==p and "<BV><a href='event:addnickname'>Adicionar</a>" or "-") or (n==p and "<a href='event:addnickname'>" or "")..mice[p].profile[2]..(n==p and "</a>" or ""))
- local gender = mice[p].profile[3]..(n==p and " <J>(<N><a href='event:gender1'>Indefinido</a> <G>| <CH><a href='event:gender2'>Masc.</a> <G>| <S><a href='event:gender3'>Fem.</a><J>)" or "")
- local publications,likedPublications,sharedPublications = mice[p].actions[1],mice[p].actions[2],mice[p].actions[3]
- text(21,"<p align='center'><font face='Impact' size='25'><V>"..p.." "..(n==p and "" or (table.find(mice[n].friends[1],p) and "<J><a href='event:unadd_"..p.."'>★</a></font>" or "<font size='20'><VP><a href='event:add_"..p.."'>★</a></font>")).."<J>\n<font size='15' face='Calibri,Verdana'><p align='left'><J><B>Data de registro : </B><V>"..register.."\n<J><B>Apelido : </B><V>"..nickname.."\n<J><B>Gênero : </B><V>"..gender.."\n<J><B>Amigos : </B><V>"..friends.."\n<J><B>Publicações : </B><V>"..publications.."\n<J><B>Publicações curtidas : </B><V>"..likedPublications.."\n<J><B>Publicações compartilhadas : </B><V>"..sharedPublications.."\n<J><B>Última vez online : </B><V>"..lastConnection,n,355,185,300,205,0x505553,0x455a4e,1,true)
- else
- ui.removeTextArea(21,n)
- end
- end
- if id == 6 then -- Search
- local found,e = values[2],values[3]
- if not e then
- text(22,"",n,396,205,250,50,0x212E35,0x212E35,1)
- ui.addPopup(1,2,"",n,396,207,250)
- text(23,"",n,376,188,25,185,0x37385b,0x37385b,1,true)
- text(24,"",n,640,188,25,185,0x37385b,0x37385b,1,true)
- text(25,"\n<p align='center'><PT>Search a nickname below!</p>",n,393,188,251,30,0x37385b,0x37385b,1,true)
- text(26,found or "",n,403,247,243,126,0x37385b,0x37385b,1,true)
- else
- for i = 22,26 do
- ui.removeTextArea(i,n)
- end
- ui.addPopup(1,2,"",n,-3500,-3500)
- end
- end
- if id == 7 then -- Chat
- local e = values[2]
- if not e then
- text(27,"",n,232,185,555,205,0x3d1c29,0x3d1c29,1,true)
- else
- ui.removeTextArea(27,n)
- end
- end
- end
- end
- end
- --[[ Events ]]--
- --[[ Timer ]]--
- addEvent("Loop",function()
- if os.time()>system.newsTimer then
- system.newsTimer = os.time() + 20000
- table.foreach(tfm.get.room.playerList,interface.updateNews)
- end
- end)
- --[[ Welcome ]]--
- addEvent("Loop",function(currentTime)
- if currentTime % 5 == 0 then
- ui.setMapName("<BL>"..("@"):rep(15).."<BV> Welcome to the TFM SCNewtwork <BL>"..("@"):rep(15).."<")
- else
- ui.setMapName("<")
- end
- end)
- --[[ Mice - NewPlayer ]]--
- eventNewPlayer=function(n)
- if not mice[n] then
- mice[n] = {
- profile = {
- [1] = os.date("%d/%m/%Y"), -- Register
- [2] = "", -- Nickname
- [3] = "Indefinido", -- Gender
- [4] = os.date("%X"), -- Last Connection
- [5] = false,
- },
- friends = {
- [1] = {}, -- List
- [2] = false,
- },
- timelines = {
- [1] = {},
- [2] = false,
- [3] = "",
- [4] = "",
- },
- search = false,
- actions = {
- [1] = 0, -- Plublications
- [2] = 0, -- Liked Publications
- [3] = 0, -- Shared Publications
- },
- chats = false,
- }
- end
- mice[n].profile[4] = os.date("%X")
- interface.main(n)
- end
- eventPlayerLeft=function(n)
- mice[n].profile[4]=os.date("%X")
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- --[[ Open / Close ]]--
- addEvent("TextAreaCallback",function(_,n,command)
- if command == 'timelines' then
- interface.timelines(n,mice[n].timelines[2])
- mice[n].timelines[2] = not mice[n].timelines[2]
- end
- if command == 'friends' then
- interface.friends(n,mice[n].friends[2])
- mice[n].friends[2] = not mice[n].friends[2]
- end
- if command:sub(1,1) == "@" then
- command = command:sub(2)
- interface.profile(n,command,mice[n].profile[5])
- mice[n].profile[5] = not mice[n].profile[5]
- end
- if command:sub(1,6) == 'gender' then
- local genders = {'Indefinido','Masculino','Feminino'}
- local id = tonumber(command:sub(7))
- mice[n].profile[3] = genders[id]
- interface.profile(n,n,false)
- end
- if command == 'resettimelines' then
- interface.timelines(n,false)
- end
- if command == 'chat' then
- interface.chat(n,mice[n].chats)
- mice[n].chats=not mice[n].chats
- end
- end)
- --[[ Popup / Timelines ]]--
- addEvent("TextAreaCallback",function(_,n,c)
- if c == 'addnickname' then
- interface.profile(n,n,true)
- ui.addPopup(0,2,"Digite aqui seu apelido.",n,360,278,293)
- end
- if c == 'search' then
- interface.search(n,'',mice[n].search)
- mice[n].search = not mice[n].search
- end
- if c=='newpost' then
- interface.timelines(n,true)
- ui.addPopup(2,2,"Digite aqui a sua publicação",n,360,278,293)
- end
- if c:sub(1,9)=='likepost_' or c:sub(1,10)=='sharepost_' then
- _c = tonumber(c:match('._(%d+)'))
- local _table = mice[n].timelines[1][_c]
- local name = _table[1]
- local l = (c:sub(1,4)=='like' and 'curtiu' or c:sub(1,5)=='share' and 'compartilhou' or "")
- local t = "<V><B>[<a href='event:@"..n.."'>"..n.."</a>]</B><J> "..l.." a publicação de <V><a href='event:@"..name.."'>"..name.."</a> <BL><B>[<a href='event:post_".._c.."'>".._table[3]:sub(1,10)..(#_table[3]>10 and "</a><J>...</J>" or "</a>").."]</B></BL>"
- table.insert(mice[n].timelines[1],t)
- table.foreach(tfm.get.room.playerList,function(x) if table.find(mice[x].friends[1],n) then table.insert(mice[x].timelines[1],t) end end)
- local numb=(c:sub(1,1)=='l' and 2 or 3);mice[n].actions[numb]=mice[n].actions[numb]+1
- interface.timelines(n,false)
- end
- if c:sub(1,10)=='quotepost_' then
- mice[n].timelines[4] = c
- c = tonumber(c:match('._(%d+)'))
- local _table = mice[n].timelines[1][c]
- local name = _table[1]
- if mice[n].timelines[3]=="" then
- ui.addPopup(3,2,"Digite aqui seu comentário.",n,360,278,293)
- else
- local t = "<V><B>[<a href='event:@"..n.."'>"..n.."</a>]</B><J> citou a publicação de <V><a href='event:@"..name.."'>"..name.."</a> <BL><B>[<a href='event:post_"..c.."'>".._table[3]:sub(1,10)..(#_table[3]>10 and "</a><J>...</J>" or "</a>").."]</B> : </BL><VP>"..(mice[n].timelines[3] or "")
- table.insert(mice[n].timelines[1],t)
- table.foreach(tfm.get.room.playerList,function(x) if table.find(mice[x].friends[1],n) then table.insert(mice[x].timelines[1],t) end end)
- end
- end
- end)
- --[[ Post ]]--
- addEvent("TextAreaCallback",function(_,n,c)
- if c:sub(1,5)=='post_' then
- c = tonumber(c:match('._(%d+)'))
- local _table = mice[n].timelines[1][c]
- local name = _table[1]
- ui.updateTextArea(15,"<G><B>[<U><BL><a href='event:resettimelines'>Voltar</a></BL></U>]</B></G>\n\n<J>From <V>"..name.." <BL> : \n ".._table[3] or "-",n)
- end
- end)
- --[[ Friend List ]]--
- addEvent("TextAreaCallback",function(_,n,c)
- if c:sub(1,4)=='add_' then
- c = c:sub(5)
- table.insert(mice[n].friends[1],c)
- interface.profile(n,c,false)
- end
- if c:sub(1,6)=='unadd_' then
- c = c:sub(7)
- table.destroy(mice[n].friends[1],c)
- interface.profile(n,c,false)
- end
- end)
- --[[ Popup ]]--
- addEvent("PopupAnswer",function(i,n,c)
- if i==0 then
- if c ~= nil then
- local nick=string.split(c,1,'%S')
- mice[n].profile[2]=string.nick(table.concat(nick)):sub(1,(string.find(nick[1],"%p") and 13 or 12))
- end
- interface.profile(n,n,false)
- end
- if i==1 then
- c=string.nick(c)
- local t = ""
- for i,v in next,mice do
- local bo,pe = string.equal(i,c)
- if pe > 40 and #c>2 and i~=n then
- t = t .. ("<G>_"):rep(10)..("\n<J>Name : <V><a href='event:@"..i.."'>"..i.."</a>\n<J>Apelido : <V>%s\n<J>Amigos : <V>%s\n<J>Última vez online: <J>%s"):format((mice[i].profile[2]~="" and mice[i].profile[2] or '<R>-<R>'),#mice[i].friends[1],mice[i].profile[4]) .. '\n'
- end
- end
- if mice[n].search then
- interface.search(n,(t~="" and t or "<R>No results"),false)
- end
- end
- if i==2 then
- if #c > 4 then
- local txt = "<V><B>[<a href='event:@"..n.."'>"..n.."</a>]</B><J> publicou : <N><a href='event:post_"..(#mice[n].timelines[1]+1).."'>"..c:sub(1,35)..(#c>35 and "</a><J>..." or "</a>").." <G><B>|</B> <BV><a href='event:likepost_"..(#mice[n].timelines[1]+1).."'>Curtir</a> <G>| <BV><a href='event:sharepost_"..(#mice[n].timelines[1]+1).."'>Compartilhar</a> <G>| <BV><a href='event:quotepost_"..(#mice[n].timelines[1]+1).."'>Citar</a>"
- mice[n].actions[1] = mice[n].actions[1] + 1
- table.insert(mice[n].timelines[1],{n,txt,c})
- table.foreach(tfm.get.room.playerList,function(x) if table.find(mice[x].friends[1],n) then table.insert(mice[x].timelines[1],{n,txt,c}) end end)
- end
- interface.timelines(n,false)
- end
- if i==3 and #c>1 then
- mice[n].timelines[3] = c:sub(1,50) .. (#c>50 and "<R>..." or "")
- eventTextAreaCallback(nil,n,mice[n].timelines[4])
- mice[n].timelines[3] = ""
- interface.timelines(n,false)
- end
- end)
- --[[ Chat Commands ]]--
- addEvent("ChatMessage",function(n,c)
- local p = string.split(c,0)
- if p[1]:lower() == "open" or p[1]:lower() == "close" then
- p[1] = p[1]:lower()
- p[2] = p[2]:lower()
- local x = {"timelines","friends","search",mice[n].timelines[2],mice[n].friends[2],mice[n].search}
- local bo,pos = table.find(x,p[2])
- if bo then
- if x[pos+3]==(p[1]=="close" and true or false) then
- eventTextAreaCallback(nil,n,p[2])
- end
- end
- end
- if p[1]:lower() == "profile" then
- if p[2] and #p[2]>3 then
- p[2] = string.nick(p[2])
- if tfm.get.room.playerList[p[2]] then
- eventTextAreaCallback(nil,n,'@'..p[2])
- end
- else
- eventTextAreaCallback(nil,n,'@'..n)
- end
- end
- if p[1]:lower() == "new" and p[2]:lower() == "post" then
- if mice[n] then
- eventChatMessage(n,"open timelines")
- eventTextAreaCallback(nil,n,'newpost')
- end
- end
- if p[1]:lower() == "add" or p[1]:lower() == "unadd" then
- p[1] = p[1]:lower()
- if p[2] and #p[2]>3 then
- p[2] = string.nick(p[2])
- if mice[p[2]] then
- eventChatMessage(n,"profile "..p[2])
- eventTextAreaCallback(nil,n,p[1].."_"..p[2])
- end
- end
- end
- if p[1]:lower() == "search" and p[2] then
- eventChatMessage(n,"open search")
- eventPopupAnswer(1,n,p[2])
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement