Advertisement
Guest User

[Mapcheck] 1.1 (Smgxxx)

a guest
May 3rd, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.47 KB | None | 0 0
  1. local admins = {"Nickname"}
  2. local maps = {"@код", "@код", "@код"}
  3. --[[
  4. PageUp - следующая карта
  5. PageDown - предыдущая карта
  6. Insert - добавить карту
  7. Delete - удалить карту
  8. End - вывести список карт
  9. ]]--
  10.  
  11. local maxnMaps = table.maxn(maps) -- количество карт
  12. print("<VP>Количество карт:<N>"..maxnMaps)
  13.  
  14. local nextMap = false -- флаг что нужно переключить карту
  15. local delete = false -- флаг что карту хотят удалить
  16. local timeMap = 3 -- нельзя менять карты первые три секунды
  17. local Map = 1 -- текущая карта
  18.  
  19. tfm.exec.disableAutoNewGame(true)
  20. tfm.exec.disableAfkDeath(true)
  21.  
  22. local keyCode = {33, 34, 35, 45, 46}
  23. for _,name in pairs(admins) do
  24.         for __, k in pairs(keyCode) do
  25.                 tfm.exec.bindKeyboard(name, k, true, true)
  26.         end
  27. end
  28. local oldNewGame = eventNewGame
  29. function next_map()
  30.         if maxnMaps == 0 then
  31.                 print("<R>Карты закончились!")
  32.                 tfm.exec.disableAutoNewGame(false)
  33.                 eventNewGame = oldNewGame
  34.                 tfm.exec.newGame()
  35.                 return
  36.         end
  37.         if Map > maxnMaps then
  38.                 Map = 1
  39.         elseif Map < 1 then
  40.                 Map = maxnMaps
  41.         end
  42.         tfm.exec.newGame(maps[Map])
  43. end
  44. function eventLoop(a, timeLeft)
  45.         timeMap = timeMap-0.5
  46.         if timeMap <= 0 and nextMap == true then
  47.                 nextMap = false
  48.                 delete = false
  49.                 timeMap = 3
  50.                 next_map()
  51.         end
  52. end
  53. function newEventNewGame()
  54.         delete = false
  55.         nextMap = false
  56.         timeMap = 3
  57.         print("<N>===================")
  58.         print("<VP>Карта:<J>@"..tfm.get.room.xmlMapInfo.mapCode)
  59.         print("<J>P"..tfm.get.room.xmlMapInfo.permCode)
  60.         print("<VP>Номер карты в списке:<J>"..Map)
  61.         print("<N>===================")
  62. end
  63. eventNewGame = newEventNewGame
  64.  
  65. function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
  66.         if maxnMaps > 0 then
  67.                 if keyCode==33 and nextMap == false then
  68.                         nextMap=true
  69.                         Map=Map+1
  70.                 elseif keyCode==34 and nextMap == false then
  71.                         nextMap=true
  72.                         Map=Map-1
  73.                 elseif keyCode == 46 and delete == false then
  74.                         delete = true
  75.                         ui.addPopup(2, 1, "Действительно удалить карту?", playerName, 300, 200, 200, true)
  76.                 elseif keyCode==35 then
  77.                         ui.addPopup(3, 0, "maps={"..table.concat(maps,",").."}", playerName, 300, 150, 200, false)
  78.                         local maps_list = "\nmaps={\n"
  79.                
  80.                         for i=1, maxnMaps do
  81.                                 maps_list = maps_list..maps[i]..",\n"
  82.                         end
  83.                         maps_list = maps_list.."}\n Не забудьте убрать ## из таблицы"
  84.                         print(maps_list)
  85.                 end
  86.         end
  87.         if keyCode == 45 then
  88.                 ui.addPopup(1, 2, "Введите номер карты", playerName, 350, 200, 140, true)
  89.         end
  90. end
  91. function eventPopupAnswer(popupId, playerName, answer)
  92.         if answer ~= "" then
  93.                 if popupId == 1 then
  94.                         table.insert(maps, answer)
  95.                         maxnMaps = table.maxn(maps)
  96.                         print("<VP>Карта добавлена")
  97.                         if maxnMaps == 1 then
  98.                                 tfm.exec.disableAutoNewGame(true)
  99.                                 eventNewGame = newEventNewGame
  100.                                 nextMap=true
  101.                         end
  102.                 elseif popupId == 2 then
  103.                         if answer == "yes" then
  104.                                 table.remove(maps,Map)
  105.                                 print("<R>Карта номер: <J>"..Map.." удалена")
  106.                                 delete=true
  107.                                 maxnMaps=table.maxn(maps)
  108.                                 nextMap = true
  109.                         else
  110.                                 delete = false
  111.                         end
  112.                 end
  113.         end
  114. end
  115. next_map()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement