kusanagy

zone_check

Mar 6th, 2020
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1.  
  2. ZoneCheck = {}
  3.  
  4. ZoneCheckName = "|CFF1CB619[Zone Check System]|r"
  5.  
  6. ZoneCheck.Settings = {
  7.     TimeToTeleport = 3,                                    -- Set 0 to Instant Teleport
  8.     Spell = 9454,
  9. };
  10.  
  11. -- AreaId, ZoneId, MapId
  12. ZoneCheck.ZonesAreas = {
  13.     [1] = { 876, 876, 1}, -- GM Island
  14. };
  15.  
  16. function ZoneCheck.OnEnterZone(event, player, newZone, newArea)
  17.     local PlayerName = player:GetName()
  18.     local newMap = player:GetMapId()
  19.  
  20.     for i, v in ipairs(ZoneCheck.ZonesAreas) do
  21.         if newArea == v[1] and newZone == v[2] and newMap == v[3] and player:IsGM() == false then
  22.             player:AddAura(ZoneCheck.Settings.Spell, player)
  23.             player:SetLuaCooldown(ZoneCheck.Settings.TimeToTeleport, 6)
  24.             player:RegisterEvent(ZoneCheck.CooldownCheck, 1000, player:GetLuaCooldown(6))
  25.             player:SendBroadcastMessage(string.format("%s You not a GameMaster you cant enter this zone!", ZoneCheckName))
  26.             for _, v in pairs(GetPlayersInWorld()) do
  27.                 if v:IsGM() == true then
  28.                    v:SendBroadcastMessage(string.format("%s Player %s Enter Zone %s Area %s Map %s without GM rights", ZoneCheckName, player:GetName(), newZone, newArea, newMap))
  29.                 end
  30.             end
  31.         end
  32.     end
  33. end
  34.  
  35. function ZoneCheck.CooldownCheck(event, delay, repeats, player)
  36.     if player:GetLuaCooldown(6) == 0 then
  37.         player:RemoveEventById(event)
  38.         player:RemoveAura(ZoneCheck.Settings.Spell)
  39.         player:Teleport(530, 2398.07, 6003.91, 148.686, 1.79828)
  40.     elseif player:GetLuaCooldown(6) <= ZoneCheck.Settings.TimeToTeleport then
  41.         player:SendBroadcastMessage(string.format("%s You will teleport in %s seconds!", ZoneCheckName, player:GetLuaCooldown(6)))
  42.         if player:IsGM() == true then
  43.             player:RemoveEventById(event)
  44.             player:RemoveAura(ZoneCheck.Settings.Spell)
  45.         end
  46.     end
  47. end
  48.  
  49. RegisterPlayerEvent(27, ZoneCheck.OnEnterZone)
Add Comment
Please, Sign In to add comment