MaXwEllDeN

Untitled

May 15th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local maps = {
  2.     [1] = { -- Mapa 1
  3.         [1] = 2, -- Vocation 1 cai na cidade 2
  4.         [2] = 5, -- Vocation 2 cai na cidade 5
  5.     },
  6.  
  7.     [2] = { -- Mapa 2
  8.         [1] = 8, -- Vocation 1 cai na cidade 8
  9.         [2] = 6, -- Vocation 2 cai na cidade 6
  10.     }
  11.  
  12. }
  13.  
  14. setGlobalStorageValue(7732, math.random(#maps)) -- Quando servidor inicia ele define o mapa inicial como sendo algum entre os da tabela `maps`
  15.  
  16. function onThink()
  17.     local map = getGlobalStorageValue(7732)
  18.  
  19.     for a = 1, math.huge do
  20.         local mapa_random = math.random(#maps)
  21.  
  22.         if mapa_random ~= map then
  23.             map = mapa_random
  24.             break
  25.         elseif a == 50 then
  26.             map = 1
  27.             break
  28.         end
  29.     end
  30.  
  31.  
  32.     for _, cid in pairs(getPlayersOnline()) do
  33.         local city = maps[map][getPlayerVocation(cid)]
  34.  
  35.         if city then
  36.             doPlayerSendTextMessage(cid, 20, "Agora sua cidade é ".. getTownName(city) .. ".")
  37.             doPlayerSetTown(cid, city)
  38.             doTeleportThing(cid, getTownTemplePosition(city))
  39.         else
  40.             print("Erro, vocação de id ".. getPlayerVocation(cid) .. " não configurada no ChangeMap.")
  41.         end
  42.     end
  43.  
  44.     return true
  45. end
Advertisement
Add Comment
Please, Sign In to add comment