-- Vehicle Anticamp by 002 v1.1.2
-- Configuration
-- Writen by Kavawuvi
-- These are the lists of vehicles to monitor, separated by commas. They do not have to be present in all of the maps.
-- Note that two backslashes are required for each backslash, or else the script will fail to work.
VEHICLES_TO_MONITOR = {
"vehicles\\scorpion\\scorpion_mp",
"vehicles\\rwarthog\\rwarthog",
"vehicles\\warthog\\mp_warthog"
}
-- Overrides VEHICLES_TO_MONITOR and just monitors every single vehicle.
MONITOR_ALL_VEHICLES = false
-- 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 = 5
-- Time until the player is warned to move. Set it to 0 to emit no warning.
CAMP_WARN_TIME = 25
-- This message is sent to the player upon warning. Set it to "" to emit no message.
CAMP_WARN_MESSAGE = "Move, or you will be kicked out of your vehicle."
-- Time until action is taken
CAMP_ACTION_TIME = 30
-- This message is sent to the player upon action being taken.
CAMP_ACTION_MESSAGE = "You were kicked out of your vehicle 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 = 1
-- 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 at least this admin level. Set to 5 or more to disable this feature.
-- Refer to xhalo.tk for more information on admin levels.
IGNORE_ADMIN_LEVEL = 5
-- End of configuration
api_version = "1.6.0.0"
-- {CampTime, X, Y, Z, Warned}
last_position = {}
respawn_queue = {}
function OnScriptLoad()
register_callback(cb['EVENT_TICK'],"OnTick")
register_callback(cb['EVENT_LEAVE'],"OnPlayerLeave")
timer(1000 * CYCLE_TIME,"OnCycle")
end
function OnScriptUnload() end
function OnPlayerLeave(PlayerIndex)
last_position[PlayerIndex] = nil
end
function OnTick()
for i=1,16 do
if(respawn_queue[i] ~= nil) then
local respawn_vehicle = false
if(player_alive(i) == false) then
respawn_vehicle = true
else
local player_object = get_dynamic_player(i)
local vehicle_objectid = read_dword(player_object + 0x11C)
local vehicle_object = get_object_memory(vehicle_objectid)
if(vehicle_object == 0) then respawn_vehicle = true end
end
if(respawn_vehicle == true) then
write_dword(respawn_queue[i] + 0x5ac,read_dword(respawn_queue[i] + 0x5ac) - 0x100000)
respawn_queue[i] = nil
end
end
end
end
function PlayerInsideMonitoredVehicle(PlayerIndex)
if(player_alive(PlayerIndex) == false) then return false end
if(tonumber(get_var(PlayerIndex,"$lvl")) >= IGNORE_ADMIN_LEVEL) then return false end
local player_object = get_dynamic_player(PlayerIndex)
local vehicle_objectid = read_dword(player_object + 0x11C)
local vehicle_object = get_object_memory(vehicle_objectid)
if(vehicle_object == 0) then return false end
if(MONITOR_ALL_VEHICLES == true) then return true end
local vehicle_tag_index = read_word(vehicle_object)
local vehicle_tag_entry = read_dword(0x40440000) + 0x20 * vehicle_tag_index
local vehicle_name = read_string(read_dword(vehicle_tag_entry + 0x10))
for q=1,#VEHICLES_TO_MONITOR do
if(VEHICLES_TO_MONITOR[q] == vehicle_name) then return true end
end
return false
end
function Distance(x1,y1,z1,x2,y2,z2)
return math.sqrt(math.pow(x1 - x2,2) + math.pow(y1 - y2,2) + math.pow(z1 - z2,2))
end
function KillPlayerSilently(PlayerIndex)
local player = get_player(PlayerIndex)
-- Silently kill the player
local old_value = read_word(player + 0xD4)
--write_dword(player + 0x30, 30 * UNAUTHORIZED_KICK_TIME - read_dword(gametype_pointer ))
write_word(player + 0xD4, 0xFFFF)
kill(PlayerIndex)
write_word(player + 0xD4, old_value)
end
function OnCycle()
local time = os.clock()
for i=1,16 do
if(PlayerInsideMonitoredVehicle(i) == true) then
local player_object = get_dynamic_player(i)
local vehicle_objectid = read_dword(player_object + 0x11C)
local vehicle_object = get_object_memory(vehicle_objectid)
local x,y,z = read_vector3d(vehicle_object + 0x5C)
if(last_position[i] == nil) then
last_position[i] = {time,x,y,z,CAMP_WARN_TIME == 0}
elseif(Distance(last_position[i][2],last_position[i][3],last_position[i][4],x,y,z) >= UNCAMP_THRESHOLD) then
last_position[i] = nil
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
say(i,CAMP_WARN_MESSAGE)
last_position[i][5] = true
end
if(time > (last_position[i][1] + CAMP_ACTION_TIME)) then
if(CAMP_ACTION_RESPAWN_VEHICLE == true) then
local vehicle_objectid = read_dword(player_object + 0x11C)
local vehicle_object = get_object_memory(vehicle_objectid)
respawn_queue[i] = vehicle_object
end
if(CAMP_ACTION_PLAYER == 1) then
exit_vehicle(i)
elseif(CAMP_ACTION_PLAYER == 2) then
kill(i)
elseif(CAMP_ACTION_PLAYER == 3) then
KillPlayerSilently(i)
end
if(CAMP_ACTION_MESSAGE ~= "") then say(i,CAMP_ACTION_MESSAGE) end
end
end
else
last_position[i] = nil
end
end
return true
end
Comments
0 B
|👍
/👎