Advertisement
Tectoon

[TFM] Test para Mapcrew

Oct 16th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.90 KB | None | 0 0
  1. admin = {"Sagazgamer", "Tectoon", "Theapps"}
  2.  
  3. function newGameLoader(playerName,turn)
  4.     if mLoader then
  5.                 currentMap = currentMap + turn
  6.                 mapList[currentMap].LOAD = true
  7.                     for k,v in pairs(admin) do
  8.                         print("<ROSE>[&#8226;] Loading @" .. mapList[currentMap].MAP .. " exported by " .. mapList[currentMap].playerName .."." , v)
  9.                     end
  10.                 mLoader = false
  11.                 tfm.exec.newGame(mapList[currentMap].MAP)
  12.                 system.newTimer(function () mLoader = true system.removeTimer(0) end,3500,false)
  13.     else
  14.         print("<R>[&#8226;] Please be patient and don't spam the buttons", playerName)
  15.     end
  16. end
  17.        
  18.  
  19. for player,playerName in pairs(admin) do
  20.         tfm.exec.bindKeyboard(playerName,77,true,true)
  21.         tfm.exec.bindKeyboard(playerName,188,true,true)
  22.         tfm.exec.bindKeyboard(playerName,190,true,true)
  23. end
  24.  
  25.  
  26. player = { }
  27. mapList = { }
  28. mLoader = true
  29. currentMap = 1
  30.  
  31. function newPlayer(playerName)
  32.        
  33.         player[playerName] = { MAPS = { }, inRoom = true }
  34.  
  35. end
  36.  
  37. for v,k in pairs(tfm.get.room.playerList) do
  38.        
  39.         newPlayer(v)
  40.  
  41. end
  42.  
  43. system.disableChatCommandDisplay('maplist',true)
  44. system.disableChatCommandDisplay('addmap',true)
  45. system.disableChatCommandDisplay('m',true)
  46. function eventChatCommand(name, command)
  47.        
  48.         if command == 'help' then
  49.             print("<ROSE>!addmap @xxxxxxx<J> - add a map to the queue, 2 max.",name)
  50.         end
  51.  
  52.         split = string.split(command)
  53.  
  54.         if split[1] == "addmap" then
  55.                 if #split > 1 then
  56.                         if string.sub(split[2], 1, 1) == "@" then
  57.                                 split[2] = string.sub(split[2],2,#split[2])
  58.                                 getPlayerMap(split[2],name)
  59.                         end
  60.                 end
  61.         end
  62.  
  63.  
  64.  
  65.         for playerName, playerKey in pairs(admin) do
  66.        
  67.                 if playerKey == name then
  68.                                 message = string.find(command,"m ",1)
  69.                                 if message == 1 then
  70.                                         print("<FONT COLOR=\"#DC85FF\">&#9824; [" .. name.. "]<B>" .. string.sub(command,message + 1,string.len(command)) .. "</B></FONT>")
  71.                                 end
  72.                
  73.                
  74.                                 if split[1] == 'checkRoom' then
  75.                                         for v,k in pairs(player) do
  76.                                                 if player[v].inRoom then
  77.                                                         print(v)
  78.                                                 end
  79.                                         end
  80.                                 end
  81.                                
  82.                                 if split[1] == 'addMapTest' then
  83.                                     for i=0,10,1 do
  84.                                         mapList[#mapList + 1] = { MAP = '12345' .. i , playerName = name , LOAD = false}
  85.                                     end
  86.                                 end
  87.                                
  88.                                 if split[1] == 'maplist' then
  89.                                     if #mapList > 0 then   
  90.                                         if split[2] == 'all' then
  91.                                             for k,v in pairs(mapList) do
  92.                                             print("<J>[&#8226;] Queue: " .. k .. " | Player Name: " .. v.playerName .. " | Map code: @" .. v.MAP, name)
  93.                                             end
  94.                                         elseif split[2] == nil or split[3] == nil then
  95.                                         for k,v in pairs(mapList) do
  96.                                             if v.LOAD == false then
  97.                                             print("<J>[&#8226;] Queue: " .. k .. " | Player Name: " .. v.playerName .. " | Map code: @" .. v.MAP, name)
  98.                                             end
  99.                                         end
  100.                                         else
  101.                                             split[2] = tonumber(split[2])
  102.                                             split[3] = tonumber(split[3])
  103.                                                 if split[2] ~= nil and split[3] ~= nil then
  104.                                                     if split[3] > #mapList then
  105.                                                         split[3] = #mapList
  106.                                                     end
  107.                                                 for k = split[2],split[3],1 do
  108.                                                     print("<J>[&#8226;] Queue: " .. k .. " | Player Name: " .. mapList[k].playerName .. " | Map code: @" .. mapList[k].MAP, name)
  109.                                                 end
  110.                                                 end
  111.                                         end
  112.                                     end
  113.                                 end
  114.                                
  115.                 end
  116.        
  117.         end
  118. end
  119.  
  120.  
  121. function eventPlayerLeft(playerName)
  122.                 player[playerName].inRoom = false
  123. end
  124.  
  125. function eventNewPlayer(playerName)
  126.         if player[playerName] == nil then
  127.                 newPlayer(playerName)
  128.                 print("<J>Welcome to mapcrew testing room, in this room you will be able to show your maps to the public and let the crew evaluate them.    For commands list please type <B>!help</b>. Have fun :)",playerName)
  129.         else
  130.                 player[playerName].inRoom = true
  131.         end
  132. end
  133.  
  134. function getPlayerMap(input,name)
  135. input = tonumber(input)
  136. firstPlacer = true
  137.         if input ~= nil then
  138.                
  139.                 if input > 999 and input < 5000000 then
  140.                        
  141.                         for i=1,2,1 do
  142.                         if player[name].MAPS[i] == nil then
  143.                             player[name].MAPS[i] = {CODE = input}
  144.                             print("<ROSE>[&#8226;] Your map: @" .. input .. " has been add to the list.",name)
  145.                             mapList[#mapList + 1] = { MAP = input , playerName = name , LOAD = false}
  146.                             firstPlacer = false
  147.                             break
  148.                         end
  149.                         end
  150.                        
  151.                         if firstPlacer then
  152.                             for k2,v2 in pairs(player[name].MAPS) do
  153.                                 for k,v in pairs(mapList) do
  154.                                     if mapList[k].playerName == name then
  155.                                         if mapList[k].LOAD then
  156.                                             if player[name].MAPS[k2].CODE == mapList[k].MAP then
  157.                                                 player[name].MAPS[k2].CODE = input
  158.                                                 print("<ROSE>[&#8226;] Your map: @" .. input .. " has been add to the list.",name)
  159.                                                 mapList[#mapList + 1] = { MAP = input , playerName = name , LOAD = false}
  160.                                                 break
  161.                                             end
  162.                                         elseif player[name].MAPS[k2].CODE == mapList[k].MAP then
  163.                                             print("<ROSE>[&#8226;] Map @" .. player[name].MAPS[k2].CODE .. " is still on queue.",name)
  164.                                         end
  165.                                     end
  166.                                 end
  167.                             end
  168.                         end
  169.  
  170.  
  171.                        
  172.                 else
  173.                         print("<R>[&#8226;] Error - Map code length invalid.",name)
  174.                 end
  175.        
  176.         else
  177.                 print("<R>[&#8226;] Error - Invalid map. (!addmap @xxxxxxx)",name)
  178.         end
  179. end
  180.  
  181.  function eventKeyboard(p,k)
  182.     for playerKey, playerName in pairs(admin) do
  183.         if p == playerName then
  184.            
  185.             if k == 77 then
  186.                
  187.                 if mapList[currentMap] ~= nil then
  188.                     newGameLoader(playerName,0)
  189.                 else
  190.                     print("<R>[&#8226;] There are no maps on the list", playerName)
  191.                 end
  192.            
  193.             end
  194.            
  195.             if k == 188 then
  196.  
  197.                 if currentMap ~= 1 then
  198.                     newGameLoader(playerName,-1)
  199.                 else
  200.                 print("<R>[&#8226;] you reached the first map in the list", playerName)
  201.                 end
  202.            
  203.             end
  204.            
  205.             if k == 190 then
  206.  
  207.                 if mapList[currentMap+1] ~= nil then
  208.                     newGameLoader(playerName,1)
  209.                 else
  210.                     print("<R>[&#8226;] There no more maps on the list", playerName)
  211.                 end
  212.             end
  213.        
  214.         end
  215.     end
  216. end
  217.  
  218.  
  219. function string.split(message)
  220.         i = 1
  221.         command = {}
  222.         for split in string.gmatch(message, "[^%s]+") do
  223.                 command[i] = split
  224.                 i = i + 1
  225.         end
  226.         return command
  227. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement