Advertisement
glitchdetector

atc/server.lua

Aug 5th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. activeBlips = {}
  2.  
  3. function hashPos(pos)
  4.     x = math.floor(pos.x) * 2^12
  5.     y = math.floor(pos.y) * 2^6
  6.     z = math.floor(pos.z)
  7.    
  8.     return x+y+z
  9. end
  10.  
  11. RegisterServerEvent("atc:flashingBlip")
  12. AddEventHandler("atc:flashingBlip", function(posv, blipid, time, col)
  13.     TriggerClientEvent("atc:startFlashingBlip", -1, posv, blipid, time, col)
  14.  
  15.     local pos = hashPos(posv)
  16.  
  17.     if activeBlips[pos] == nil then
  18.         activeBlips[pos] = 0
  19.     elseif activeBlips[pos] > 0 then
  20.         TriggerClientEvent("atc:warning", source)
  21.         print("[ATC] warning player "..source.." for calling out at "..pos)
  22.  
  23.         print("[ATC] current state:")
  24.         for k,v in next, activeBlips do
  25.             print(k.." = "..v)
  26.         end
  27.     end
  28.  
  29.     activeBlips[pos] = activeBlips[pos] + 1
  30.     --print("[atc] added blip   "..pos.." = "..activeBlips[pos])
  31.     SetTimeout(time * 1000, function()
  32.         activeBlips[pos] = activeBlips[pos] - 1
  33.         --print("[atc] removed blip "..pos.." = "..activeBlips[pos])
  34.  
  35.         if activeBlips[pos] < 0 then
  36.             print("[ATC] Bug or race condition detected... Resetting.")
  37.             activeBlips[pos] = 0
  38.         end
  39.     end)
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement