Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local admins = {"Nickname"}
- local maps = {"@код", "@код", "@код"}
- --[[
- PageUp - следующая карта
- PageDown - предыдущая карта
- Insert - добавить карту
- Delete - удалить карту
- End - вывести список карт
- ]]--
- local maxnMaps = table.maxn(maps) -- количество карт
- print("<VP>Количество карт:<N>"..maxnMaps)
- local nextMap = false -- флаг что нужно переключить карту
- local delete = false -- флаг что карту хотят удалить
- local timeMap = 3 -- нельзя менять карты первые три секунды
- local Map = 1 -- текущая карта
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAfkDeath(true)
- local keyCode = {33, 34, 35, 45, 46}
- for _,name in pairs(admins) do
- for __, k in pairs(keyCode) do
- tfm.exec.bindKeyboard(name, k, true, true)
- end
- end
- local oldNewGame = eventNewGame
- function next_map()
- if maxnMaps == 0 then
- print("<R>Карты закончились!")
- tfm.exec.disableAutoNewGame(false)
- eventNewGame = oldNewGame
- tfm.exec.newGame()
- return
- end
- if Map > maxnMaps then
- Map = 1
- elseif Map < 1 then
- Map = maxnMaps
- end
- tfm.exec.newGame(maps[Map])
- end
- function eventLoop(a, timeLeft)
- timeMap = timeMap-0.5
- if timeMap <= 0 and nextMap == true then
- nextMap = false
- delete = false
- timeMap = 3
- next_map()
- end
- end
- function newEventNewGame()
- delete = false
- nextMap = false
- timeMap = 3
- print("<N>===================")
- print("<VP>Карта:<J>@"..tfm.get.room.xmlMapInfo.mapCode)
- print("<J>P"..tfm.get.room.xmlMapInfo.permCode)
- print("<VP>Номер карты в списке:<J>"..Map)
- print("<N>===================")
- end
- eventNewGame = newEventNewGame
- function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
- if maxnMaps > 0 then
- if keyCode==33 and nextMap == false then
- nextMap=true
- Map=Map+1
- elseif keyCode==34 and nextMap == false then
- nextMap=true
- Map=Map-1
- elseif keyCode == 46 and delete == false then
- delete = true
- ui.addPopup(2, 1, "Действительно удалить карту?", playerName, 300, 200, 200, true)
- elseif keyCode==35 then
- ui.addPopup(3, 0, "maps={"..table.concat(maps,",").."}", playerName, 300, 150, 200, false)
- local maps_list = "\nmaps={\n"
- for i=1, maxnMaps do
- maps_list = maps_list..maps[i]..",\n"
- end
- maps_list = maps_list.."}\n Не забудьте убрать ## из таблицы"
- print(maps_list)
- end
- end
- if keyCode == 45 then
- ui.addPopup(1, 2, "Введите номер карты", playerName, 350, 200, 140, true)
- end
- end
- function eventPopupAnswer(popupId, playerName, answer)
- if answer ~= "" then
- if popupId == 1 then
- table.insert(maps, answer)
- maxnMaps = table.maxn(maps)
- print("<VP>Карта добавлена")
- if maxnMaps == 1 then
- tfm.exec.disableAutoNewGame(true)
- eventNewGame = newEventNewGame
- nextMap=true
- end
- elseif popupId == 2 then
- if answer == "yes" then
- table.remove(maps,Map)
- print("<R>Карта номер: <J>"..Map.." удалена")
- delete=true
- maxnMaps=table.maxn(maps)
- nextMap = true
- else
- delete = false
- end
- end
- end
- end
- next_map()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement