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 = {}
- players.haveflag = nil
- weapons = {}
- coords = {}
- coords_to_move = 8 -- 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 = "move" -- 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(60000, "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 == 1 then
- countercamp = countercamp + 1
- privatesay(player, "Last warning.")
- elseif countercamp == 2 and players[hash].haveflag == false 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 == "move" 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 moved for camping!")
- end
- end
- else
- countercamp = 0
- privatesay(player, "Stop camping...")
- 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
- players[hash].haveflag = false
- end
- function OnWeaponPickup(player, weapId, slot, mapId)
- local hash = gethash(player)
- local tagname = gettaginfo(mapId)
- if tagname == "weapons\\flag\\flag" then
- players[hash].haveflag = true
- end
- end
- function OnWeaponDrop(player, weapId, slot, mapId)
- local hash = gethash(player)
- local tagname = gettaginfo(mapId)
- if tagname == "weapons\\flag\\flag" then
- players[hash].haveflag = false
- end
- end
- registertimer(10, "WeaponMonitor")
- function WeaponMonitor(id, count)
- for player = 0,15 do
- weapons[player] = weapons[player] or {}
- local m_player = getplayer(player)
- if m_player then
- local temp = {} --?
- local objId = readdword(m_player, 0x34)
- local m_object = getobject(objId)
- if m_object then
- for i = 0,3 do
- local weapId = readdword(m_object, 0x2F8 + (i * 4))
- local m_weapon = getobject(weapId)
- if m_weapon then
- local mapId = readdword(m_weapon)
- if weapons[player][i] then
- if weapons[player][i].weapId ~= weapId then
- OnWeaponDrop(player, weapons[player][i].weapId, i, weapons[player][i].mapId)
- weapons[player][i] = {}
- weapons[player][i].weapId = weapId
- weapons[player][i].mapId = mapId
- OnWeaponPickup(player, weapId, i, mapId)
- end
- else
- weapons[player][i] = {}
- weapons[player][i].weapId = weapId
- weapons[player][i].mapId = mapId
- OnWeaponPickup(player, weapId, i, mapId)
- end
- else
- if weapons[player][i] then
- OnWeaponDrop(player, weapons[player][i].weapId, i, weapons[player][i].mapId)
- weapons[player][i] = nil
- end
- end
- end
- else
- for i = 0,3 do
- if weapons[player][i] then
- OnWeaponDrop(player, weapons[player][i].weapId, i, weapons[player][i].mapId)
- weapons[player][i] = nil
- end
- end
- end
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement