Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Name : Anti-Camping
- Version : 1.01
- Created by : Idea by «§H»Kennan{Leader}, mostly wrote by Aelite Prime (Thanks both of them)
- Short modifications by combre
- ]]--
- players = {}
- coords = {}
- coords_to_move = 10 -- How many coords do they have to move in 30 seconds to be considered camping.
- -- If you walk in a stright line for 30 seconds, you can move around 30-40 coords.
- -- Also the radius of the circle they must get out of in 30 seconds before they are considered camping.
- -- Would want to make this smaller as the map gets small.
- punishment = "moove" -- What do you want to do to the "campers", methods :
- -- "kill" : Kill them
- -- "hurt" : Hurt them (20% of their health, on the 5th time, it will kill them)
- -- "moove" : Moove them back to teir spawn position
- -- Don't touch below this line --
- coords = {}
- countercamp = 0
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(processId, game, persistent)
- timer = registertimer(10000, "CoordCheck") -- 30000 or 30 sec, time between each coords checks
- end
- function OnGameEnd(stage)
- if stage == 1 then
- removetimer(timer)
- end
- end
- function OnPlayerJoin(player)
- coords[gethash(player)] = readfloat(getplayer(player) + 0xF8)
- end
- function CoordCheck(id, count)
- for player = 0,15 do
- if getplayer(player) then
- local hash = gethash(player)
- local m_objectId = getplayerobjectid(player)
- local x_diff = (coords[hash] + coords_to_move)
- coords[hash] = readfloat(getplayer(player) + 0xF8)
- if not isinvehicle(player) then
- if m_objectId and coords[hash] ~= nil and coords[hash] <= x_diff then
- --if countercamp == 0 then
- countercamp = countercamp + 1
- privatesay(player, "You cannot stand here.")
- --elseif countercamp == 3 then
- --countercamp = 0
- --privatesay(player, "You cannot stand here.")
- --end
- if countercamp == 2 and isNotHoldingFlag(player) then
- if punishment == "kill" then
- countercamp = 0
- kill(player)
- privatesay(player, "You were killed for camping!")
- elseif punishment == "hurt" then
- local m_object = getobject(m_objectId)
- local health = readfloat(m_object + 0xE0)
- if health <= 0.21 then
- countercamp = 0
- kill(player)
- privatesay(player, "20% of your Health was damaged for camping, thus resulting in your death!")
- else
- countercamp = 0
- writefloat(m_object + 0xE0, health - 0.20)
- privatesay(player, "20% of your Health was damaged for camping!")
- end
- elseif punishment == "moove" then
- if (m_objectId ~= nil) then
- countercamp = 0
- movobjectcoords(m_objectId, players[hash].spawns[1], players[hash].spawns[2], players[hash].spawns[3])
- privatesay(player, "You were mooved for camping!")
- --else
- --countercamp = 0
- --kill(player)
- --privatesay(player, "You were killed for camping!")
- end
- end
- end
- end
- end
- end
- end
- return true
- end
- function OnPlayerSpawnEnd(player)
- coords[gethash(player)] = readfloat(getplayer(player) + 0xF8)
- local playerobjId = getplayerobjectid(player)
- local x, y, z = getobjectcoords(playerobjId)
- local hash = gethash(player)
- players[hash] = players[hash] or {}
- players[hash].spawns = players[hash].spawns or {}
- players[hash].spawns[1] = x
- players[hash].spawns[2] = y
- players[hash].spawns[3] = z
- end
- function isNotHoldingFlag(player)
- local redflag = readdword(0x639B98 + 0x0)
- local blueflag = readdword(0x639B98 + 0x4)
- local m_object = getobject(getplayerobjectid(player))
- for i = 0,3 do
- local weapId = readdword(m_object + 0x2F8 + i*4)
- if weapId == redflag or weapId == blueflag then
- return false
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement