Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Vehicle Anticamp v1.1.1
- -- created by 002 for SAPP
- -- converted from SAPP to Phasor by H® Shaft for Phasor v2+
- -- This script will monitor, warn and take action on players camping in vehicles. If players remain too long in one area, the script takes the selected action.
- -- These are the lists of vehicles to monitor, separated by commas. They do not have to be present in all of the maps.
- VEHICLES_TO_MONITOR = {
- "vehicles\\scorpion\\scorpion_mp",
- "vehicles\\rwarthog\\rwarthog",
- "vehicles\\warthog\\mp_warthog",
- "vehicles\\ghost\\ghost_mp"
- }
- -- Interval in which this script scans players for camping. This is in seconds.
- CYCLE_TIME = 5
- -- The player must have moved this many world units since the last cycle, or else they are still camping.
- UNCAMP_THRESHOLD = 10
- -- Time until the player is warned to move. Set it to 0 to emit no warning.
- CAMP_WARN_TIME = 15
- -- This message is sent to the player upon warning. Set it to "" to emit no message.
- CAMP_WARN_MESSAGE = "Move! or you will be killed/ejected for camping."
- -- Time until action is taken
- CAMP_ACTION_TIME = 25
- -- This message is sent to the player upon action being taken.
- CAMP_ACTION_MESSAGE = "You were killed (or) ejected for camping."
- -- Actions to take on the player.
- -- 1 = Remove the player from the vehicle.
- -- 2 = Kill the player.
- -- 3 = Kill the player without a death message.
- CAMP_ACTION_PLAYER = 3
- -- Respawn the vehicle as well. Please note that this requires that vehicle respawning be enabled in the gametype.
- CAMP_ACTION_RESPAWN_VEHICLE = true
- -- Ignore players that are admins? true = ignore, false = take action
- -- if an admin is a vehicle driver, passengers/gunners will not be warned/killed if driver is not moving
- IGNORE_ADMIN = false
- -- Overrides VEHICLES_TO_MONITOR and monitors every single vehicle (including stationary turrets = bad) AND admin players too.
- MONITOR_ALL_VEHICLES = false
- -- {CampTime, X, Y, Z, Warned}
- last_position = {}
- respawn_queue = {}
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- oncycle = registertimer(1000 * CYCLE_TIME, "OnCycle")
- ontick = registertimer(33.333333, "OnTick")
- for i=0,15 do
- if getplayer(i) then
- last_position[i] = nil
- respawn_queue[i] = {}
- end
- end
- end
- function OnPlayerJoin(player)
- if getplayer(player) then
- last_position[player] = nil
- respawn_queue[player] = {}
- end
- end
- function OnPlayerLeave(player)
- if getplayer(player) then
- last_position[player] = nil
- respawn_queue[player] = nil
- end
- end
- function OnTick()
- for i=0,15 do
- if getplayer(i) then
- if (respawn_queue[i] ~= nil) then
- local respawn_vehicle = false
- if not player_alive(i) then
- respawn_vehicle = true
- else
- if isinvehicle(i) then
- local m_player = getplayer(i)
- local m_objectId = readdword(m_player + 0x34)
- local m_object = getobject(m_objectId)
- if m_object then
- local m_vehicleId = readdword(m_object + 0x11C)
- local m_vehicle = getobject(m_vehicleId)
- if not m_vehicle then respawn_vehicle = true end
- end
- if respawn_vehicle then
- writedword(respawn_queue[i] + 0x5ac, readdword(respawn_queue[i] + 0x5ac) - 0x100000)
- respawn_queue[i] = nil
- end
- end
- end
- end
- end
- end
- return true
- end
- function PlayerInsideMonitoredVehicle(player)
- local bool = false
- if getplayer(player) then
- if isadmin(player) then bool = true end
- if IGNORE_ADMIN and bool then return false end
- if player_alive(player) then
- if isinvehicle(player) then
- local m_player = getplayer(player)
- local m_objectId = readdword(m_player + 0x34)
- local m_object = getobject(m_objectId)
- if m_object then
- local m_vehicleId = readdword(m_object + 0x11C)
- local m_vehicle = getobject(m_vehicleId)
- local vehname = gettaginfo(readdword(m_vehicle))
- if m_vehicle then
- local tablesize = #VEHICLES_TO_MONITOR
- for v=1,tablesize do
- if VEHICLES_TO_MONITOR[v] == vehname then return true end
- end
- else
- return false
- end
- end
- else
- return false
- end
- else
- return false
- end
- if MONITOR_ALL_VEHICLES and bool then
- return false
- elseif MONITOR_ALL_VEHICLES and not bool then
- return true
- end
- end
- return false
- end
- function Distance(x1,y1,z1,x2,y2,z2)
- return math.sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2 + (z1 - z2) ^ 2)
- end
- function KillPlayerSilently(player)
- if getplayer(player) then
- local m_player = getplayer(player)
- local old_value = readword(m_player + 0xD4)
- writeword(m_player + 0xD4, 0xFFFF)
- kill(player)
- writeword(m_player + 0xD4, old_value)
- end
- end
- function getdriverplayer(m_vehicle)
- local obj_id = readdword(m_vehicle + 0x324)
- if obj_id and obj_id ~= 0xFFFFFFFF then return objectidtoplayer(obj_id) end
- end
- function player_alive(player)
- if getplayer(player) then
- local m_objectId = getplayerobjectid(player)
- if m_objectId then
- local m_object = getobject(m_objectId)
- if m_object then
- return true
- else
- return false
- end
- end
- end
- end
- function OnPlayerKill(killer, victim, mode)
- if getplayer(victim) then
- last_position[victim] = nil
- end
- end
- function OnVehicleEntry(player, m_vehicleId, seat, mapid, relevant)
- if player then
- local m_player = getplayer(player)
- if m_player and player_alive then
- local m_objectId = readdword(m_player + 0x34)
- if m_objectId then
- local time = os.clock()
- local x,y,z = getobjectcoords(m_objectId)
- last_position[player] = {}
- last_position[player][1] = time
- last_position[player][2] = x
- last_position[player][3] = y
- last_position[player][4] = z
- last_position[player][5] = false
- end
- local m_vehicle = getobject(m_vehicleId)
- if IGNORE_ADMIN and isadmin(player) then last_position[player] = nil end
- local driver = readdword(m_vehicle + 0x324)
- if seat ~= 0 and IGNORE_ADMIN then
- if driver ~= 0xFFFFFFFF then
- local m_vehicle = getobject(m_vehicleId)
- local driverplayer = getdriverplayer(m_vehicle)
- if isadmin(driverplayer) then
- last_position[player] = nil
- end
- end
- end
- end
- end
- return nil
- end
- function OnVehicleEject(player, relevant)
- if getplayer(player) then
- last_position[player] = nil
- end
- return nil
- end
- function OnCycle()
- local time = os.clock()
- for i=0,15 do
- if getplayer(i) then
- if PlayerInsideMonitoredVehicle(i) then
- local m_player = getplayer(i)
- local m_objectId = readdword(m_player + 0x34)
- if m_objectId then
- local m_object = getobject(m_objectId)
- if m_object then
- local x,y,z = getobjectcoords(m_objectId)
- local m_vehicleId = readdword(getobject(m_objectId) + 0x11C)
- local m_vehicle = getobject(m_vehicleId)
- local driver = readdword(m_vehicle + 0x324)
- if last_position[i] == nil then
- last_position[i] = {}
- last_position[i][1] = time
- last_position[i][2] = x
- last_position[i][3] = y
- last_position[i][4] = z
- last_position[i][5] = false
- elseif Distance(last_position[i][2],last_position[i][3],last_position[i][4],x,y,z) >= UNCAMP_THRESHOLD then
- last_position[i] = nil
- elseif IGNORE_ADMIN and isadmin(i) then
- last_position[i] = nil
- elseif IGNORE_ADMIN and driver ~= 0xFFFFFFFF then
- local driverplayer = getdriverplayer(m_vehicle)
- if isadmin(driverplayer) then
- last_position[i] = nil
- end
- else
- last_position[i][2] = x
- last_position[i][3] = y
- last_position[i][4] = z
- if time > (last_position[i][1] + CAMP_WARN_TIME) and (last_position[i][5] == false) then
- privatesay(i, getname(i).. " " .. CAMP_WARN_MESSAGE)
- last_position[i][5] = true
- elseif time > (last_position[i][1] + CAMP_ACTION_TIME) and (last_position[i][5] == true) then
- if CAMP_ACTION_RESPAWN_VEHICLE then
- local m_vehicleId = readdword(getobject(m_objectId) + 0x11C)
- local m_object = getobject(m_vehicleId)
- respawn_queue[i] = m_object
- end
- if CAMP_ACTION_PLAYER == 1 then
- exitvehicle(i)
- elseif CAMP_ACTION_PLAYER == 2 then
- kill(i)
- elseif CAMP_ACTION_PLAYER == 3 then
- KillPlayerSilently(i)
- end
- privatesay(i, getname(i).. " " .. CAMP_ACTION_MESSAGE)
- end
- end
- end
- end
- else
- last_position[i] = nil
- end
- end
- end
- return true
- end
- -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
- -- Visit http://halorace.org/forum/index.php?topic=514.0 or
- -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment