Tectoon

[TFM] #Records

Aug 4th, 2015
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.75 KB | None | 0 0
  1. adm = {Sagazgamer = true, Tectoon = true}
  2.  
  3.  
  4. print("<J>#Records <n>carregado com sucesso!")
  5. module={}
  6. module.time=os.time()
  7. module.text={
  8.     info="<b>Gravidade:<v>%s</v>\nVento:<v>%s</v>\nRecords:<j>%s</j>-<v>%s",
  9. }
  10. module.addText=function(self,id,txt,p,x,y)
  11.     ui.addTextArea(id,txt,p,x,y,nil,nil,1,1,0)
  12. end
  13.  
  14. function module:start(m,name,t)
  15.     self.data={}
  16.     self.record={}
  17.     self.name=name
  18.     self.mt=t
  19.     self.m=m
  20.     self.NewPlayer=function(self,p)
  21.         self.data[p]=not self.data[p] and {time=os.time()} or self.data[p]
  22.         tfm.exec.bindKeyboard(p,string.byte('X'),true,true)
  23.         tfm.exec.bindKeyboard(p,string.byte('C'),true,true)
  24.         self.data[p].CP=function(self,x,y)
  25.             if self.time<os.time()-1000 then
  26.                 self.x=x
  27.                 self.y=y
  28.                 tfm.exec.displayParticle(9,x,y,0,0,0,0,p)
  29.                 self.time=os.time()
  30.             end
  31.         end
  32.     end
  33.    
  34.     self.PlayerDied=function(self,p)
  35.         tfm.exec.respawnPlayer(p)
  36.     end
  37.     self.Keyboard=function(self,p,k,d,x,y)
  38.         if string.byte('X')==k then
  39.             self.data[p]:CP(x,y)
  40.         elseif string.byte('C')==k then
  41.             if self.data[p].x then
  42.                 tfm.exec.movePlayer(p,self.data[p].x,self.data[p].y)
  43.             end
  44.         end
  45.     end
  46.     self.Chat=function(self,p,c)
  47.         clower=c:lower()
  48.         if clower=="mort" then
  49.             tfm.exec.killPlayer(p)
  50.         end
  51.     end
  52.     self.Loop=function(self,a,b)
  53.         if self.carregado then
  54.             if b<=0 then self:np() end
  55.             w,g=0,10
  56.             for a,b in self.xml.xml:gmatch('G="(.-),(.-)"') do
  57.                 w,g=a,b
  58.             end
  59.             if #self.record[self.xml.mapCode]>0 then
  60.                 table.sort(self.record[self.xml.mapCode],function(a,b) return a.t<b.t end)
  61.             end
  62.             top_tb=self.record[self.xml.mapCode][1] or {p="",t=""}
  63.             self:addText(0,self.text.info:format(g or 10,w or 0,top_tb.p,top_tb.t),nil,5,20)
  64.         end
  65.     end
  66.     self.NewGame=function(self,xml)
  67.         self.xml=xml
  68.         tfm.exec.setGameTime(self.mt)
  69.         self.record[xml.mapCode]=not self.record[xml.mapCode] and {} or self.record[xml.mapCode]
  70.     end
  71.     self.Won=function(self,player,_,time,p)
  72.         table.insert(self.record[self.xml.mapCode],{p=player,t=time/100})
  73.     end
  74.     self.np=function(self)
  75.         local pm=self.m
  76.         tfm.exec.newGame(pm[math.random(#pm)])
  77.     end
  78.     self.config=function()
  79.         tfm.exec.disableAutoShaman(true)
  80.         tfm.exec.disableAutoNewGame(true)
  81.         tfm.exec.disableAfkDeath(true)
  82.     end
  83.     self:config()
  84.     self:np()
  85.     _G.eventLoop=function(a,b) self:Loop(a,b) end
  86.     _G.eventNewPlayer=function(p) self:NewPlayer(p) end
  87.     _G.eventNewGame=function() self:NewGame(tfm.get.room.xmlMapInfo) end
  88.     _G.eventPlayerWon=function(p,_,t) self:Won(p,_,t) end
  89.     _G.eventPlayerDied=function(p) self:PlayerDied(p) end
  90.     _G.eventKeyboard=function(p,k,d,x,y) self:Keyboard(p,k,d,x,y) end
  91.     _G.eventChatCommand=function(p,c) self:Chat(p,c) end
  92.     table.foreach(tfm.get.room.playerList,function(k) self:NewPlayer(k) end)
  93.     self.carregado=true
  94. end
  95.  
  96. s_table={
  97.     {511136,3999991,3547571,3161324,3012311,4317592,3734991,3734997,3750360,3734998,3999979,4390388,4367270,3137929,3547571,3471016,2860211,2967631,2805938,3815568,720672,3849999,3551333,3493490,3136410,842019,3668888,3850000,3264848,2996951,2805938,3815568,720672,3849999,3551333,3493490,3136410,842019,2805938,3815568,720672,3849999,3551333,3493490,3136410,842019,3668888,3850000,3668877,3200001,3483300,3920916,3395605,3386996,3478040,4656973},
  98.     "#Records",
  99.     121,--Tempo
  100. }
  101. module:start(table.unpack(s_table))
  102. print(("\n<v>%s\n%s"):format(module.name,tostring(os.time()-module.time)))
  103.  
  104. function eventChatCommand(p,c)
  105.   local args={}
  106.     for i in c:gmatch('[^%s]+') do
  107.         table.insert(args,i)
  108.     end
  109.   if args[1]=="map" and adm[p] then
  110.     tfm.exec.disableAutoNewGame(true)
  111.     tfm.exec.disableAfkDeath(true)
  112.     print("<ch>#Records<n> Mapa carregado com sucesso!")
  113.         if args[2] then
  114.       tfm.exec.newGame(args[2])
  115.         else
  116.       print("<R>O mapa não existe ou não carrega")
  117.     end
  118.   end
  119. end
Advertisement
Add Comment
Please, Sign In to add comment