Advertisement
Combreal

AntiCampOLD.lua

Feb 8th, 2014
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.94 KB | None | 0 0
  1. --[[ Name : Anti-Camping
  2.          Version : 1.01
  3.          Created by : Idea by «§H»Kennan{Leader}, mostly wrote by Aelite Prime (Thanks both of them)
  4.                       Short modifications by combre
  5. ]]--
  6.  
  7. players = {}
  8.  
  9. coords = {}
  10. coords_to_move = 10 -- How many coords do they have to move in 30 seconds to be considered camping.
  11.                         -- If you walk in a stright line for 30 seconds, you can move around 30-40 coords.
  12.                         -- Also the radius of the circle they must get out of in 30 seconds before they are considered camping.
  13.                         -- Would want to make this smaller as the map gets small.
  14.  
  15. punishment = "moove" -- What do you want to do to the "campers", methods :
  16.                      -- "kill"  : Kill them
  17.                      -- "hurt"  : Hurt them (20% of their health, on the 5th time, it will kill them)
  18.                      -- "moove" : Moove them back to teir spawn position
  19.  
  20.  
  21. -- Don't touch below this line --
  22. coords = {}
  23. countercamp = 0
  24.  
  25. function GetRequiredVersion()
  26.     return 200
  27. end
  28.  
  29. function OnScriptLoad(processId, game, persistent)
  30.     timer = registertimer(10000, "CoordCheck") -- 30000 or 30 sec, time between each coords checks
  31. end
  32.  
  33. function OnGameEnd(stage)
  34.     if stage == 1 then
  35.         removetimer(timer)
  36.     end
  37. end
  38.  
  39. function OnPlayerJoin(player)
  40.     coords[gethash(player)] = readfloat(getplayer(player) + 0xF8)
  41. end
  42.  
  43. function CoordCheck(id, count)
  44.     for player = 0,15 do
  45.         if getplayer(player) then
  46.             local hash = gethash(player)
  47.             local m_objectId = getplayerobjectid(player)
  48.             local x_diff = (coords[hash] + coords_to_move)
  49.             coords[hash] = readfloat(getplayer(player) + 0xF8)
  50.             if not isinvehicle(player) then
  51.                 if m_objectId and coords[hash] ~= nil and coords[hash] <= x_diff then
  52.                     --if countercamp == 0 then
  53.                     countercamp = countercamp + 1
  54.                     privatesay(player, "You cannot stand here.")
  55.                     --elseif countercamp == 3 then
  56.                         --countercamp = 0
  57.                         --privatesay(player, "You cannot stand here.")
  58.                     --end
  59.                     if countercamp == 2 and isNotHoldingFlag(player) then
  60.                         if punishment == "kill" then
  61.                             countercamp = 0
  62.                             kill(player)
  63.                             privatesay(player, "You were killed for camping!")
  64.                         elseif punishment == "hurt" then
  65.                             local m_object = getobject(m_objectId)
  66.                             local health = readfloat(m_object + 0xE0)
  67.                             if health <= 0.21 then
  68.                                 countercamp = 0
  69.                                 kill(player)
  70.                                 privatesay(player, "20% of your Health was damaged for camping, thus resulting in your death!")
  71.                             else
  72.                                 countercamp = 0
  73.                                 writefloat(m_object + 0xE0, health - 0.20)
  74.                                 privatesay(player, "20% of your Health was damaged for camping!")
  75.                             end
  76.                         elseif punishment == "moove" then
  77.                             if (m_objectId ~= nil) then
  78.                                 countercamp = 0
  79.                                 movobjectcoords(m_objectId, players[hash].spawns[1], players[hash].spawns[2], players[hash].spawns[3])
  80.                                 privatesay(player, "You were mooved for camping!")
  81.                             --else
  82.                                 --countercamp = 0
  83.                                 --kill(player)
  84.                                 --privatesay(player, "You were killed for camping!")
  85.                             end
  86.                         end
  87.                     end
  88.                 end
  89.             end
  90.         end
  91.     end
  92.     return true
  93. end
  94.  
  95. function OnPlayerSpawnEnd(player)
  96.     coords[gethash(player)] = readfloat(getplayer(player) + 0xF8)
  97.     local playerobjId = getplayerobjectid(player)
  98.     local x, y, z = getobjectcoords(playerobjId)
  99.     local hash = gethash(player)
  100.     players[hash] = players[hash] or {}
  101.     players[hash].spawns = players[hash].spawns or {}
  102.     players[hash].spawns[1] = x
  103.     players[hash].spawns[2] = y
  104.     players[hash].spawns[3] = z
  105. end
  106.  
  107. function isNotHoldingFlag(player)
  108.     local redflag = readdword(0x639B98 + 0x0)
  109.     local blueflag = readdword(0x639B98 + 0x4)
  110.     local m_object = getobject(getplayerobjectid(player))
  111.     for i = 0,3 do
  112.         local weapId = readdword(m_object + 0x2F8 + i*4)
  113.         if weapId == redflag or weapId == blueflag then
  114.             return false
  115.         end
  116.     end
  117.     return true
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement