Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Block Objective Holders from Driving/Gunning for SAPP
- -- by H® Shaft
- -- Script will eject Flag & Oddball (skull) holders (objective holders) if they enter driver or gunner seat of a vehicle
- -- Game-Type editable options allow you to control how it behaves in CTF vs. Odd ball
- -- Addresses these issues:
- -- Oddball/Skull holders: players who enter a driver or gunner seat do not gain time when in these seats: eject them
- -- CTF: Flag holders sometimes get in driver/gunner seat and then don't return to their base to score: eject them
- -- Pro: enforces team-effort and individual efforts are more difficult
- -- Con: Makes it difficult for an individual to get away with flag:
- -- Con Solution: increase DELAY_TIME to 7-15 seconds (default = 2.5) to give them a head start to escape enemy area
- -- Should the script eject flag/oddball holders if they enter the DRIVER seat?
- -- true = eject, false = don't eject
- EJECT_DRIVER = true
- -- Should the script eject flag/oddball holders if they enter the GUNNER seat?
- -- true = eject, false = don't eject
- EJECT_GUNNER = true
- -- What game-types should this be applied to?
- -- 1 = CTF game-type only
- -- 2 = Oddball game-type only
- -- 3 = Both CTF and Oddball game-types
- APPLY_TO = 3
- -- Amount of time (in seconds) to delay before ejecting flag/oddball holders if entering driver/gunner seat
- -- MINIMUM DELAY_TIME = 2.5 seconds (this is the fastest a player can be ejected)
- -- The longer the delay time, the longer the player remains in the driver/gunner seat
- DELAY_TIME = 2.5
- -- end configuration
- api_version = "1.9.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_VEHICLE_ENTER'], "OnVehicleEnter")
- end
- function OnVehicleEnter(PlayerIndex, Seat)
- local seat = tonumber(Seat)
- local gametype = get_var(0, "$gt")
- if (APPLY_TO == nil) then return end
- if (DELAY_TIME == nil) or (DELAY_TIME < 2.5) then DELAY_TIME = 2.5 end
- -- both CTF and Oddball
- if (APPLY_TO == 3) then
- if (gametype == "ctf") or (gametype == "oddball") then
- if (seat == 0) then
- if (Has_Objective(PlayerIndex) == true) then
- if (EJECT_DRIVER == true) then
- timer(DELAY_TIME * 1000, "Eject_Holder", PlayerIndex, seat)
- end
- end
- elseif (seat == 2) then
- if (Has_Objective(PlayerIndex) == true) then
- if (EJECT_DRIVER == true) then
- timer(DELAY_TIME * 1000, "Eject_Holder", PlayerIndex, seat)
- end
- end
- end
- end
- -- CTF only
- elseif (APPLY_TO == 1) then
- if (gametype == "ctf") then
- if (seat == 0) then
- if (Has_Objective(PlayerIndex) == true) then
- if (EJECT_DRIVER == true) then
- timer(DELAY_TIME * 1000, "Eject_Holder", PlayerIndex, seat)
- end
- end
- elseif (seat == 2) then
- if (Has_Objective(PlayerIndex) == true) then
- if (EJECT_DRIVER == true) then
- timer(DELAY_TIME * 1000, "Eject_Holder", PlayerIndex, seat)
- end
- end
- end
- end
- -- Oddball only
- elseif (APPLY_TO == 2) then
- if (gametype == "oddball") then
- if (seat == 0) then
- if (Has_Objective(PlayerIndex) == true) then
- if (EJECT_DRIVER == true) then
- timer(DELAY_TIME * 1000, "Eject_Holder", PlayerIndex, seat)
- end
- end
- elseif (seat == 2) then
- if (Has_Objective(PlayerIndex) == true) then
- if (EJECT_DRIVER == true) then
- timer(DELAY_TIME * 1000, "Eject_Holder", PlayerIndex, seat)
- end
- end
- end
- end
- end
- end
- function Eject_Holder(PlayerIndex, seat)
- local seat = tonumber(seat)
- if not player_alive(PlayerIndex) then return end
- if isinvehicle(PlayerIndex) and (seat ~= nil) then
- if (seat == 0) then
- exit_vehicle(PlayerIndex)
- say(PlayerIndex, " |*EJECTED!*| You cannot drive while holding oddball or flag!")
- elseif (seat == 2) then
- exit_vehicle(PlayerIndex)
- say(PlayerIndex, " |*EJECTED!*| You cannot use gunner seat while holding oddball or flag!")
- end
- end
- return false
- end
- -- iterates thru all players weapons, returns true if they have flag or oddball, if not, returns false
- -- this is specifically checking the 'must be readied' flag of each of their weapons
- function Has_Objective(PlayerIndex)
- local response = false
- if get_var(0, "$gt") ~= "n/a" then
- if (get_var(0, "$gt") == "ctf") or (get_var(0, "$gt") == "oddball") then
- local player_object = get_dynamic_player(PlayerIndex)
- for w=0,3 do
- local weap_id = read_dword(player_object + 0x2F8 + 0x4 * w)
- if (weap_id ~= 0xFFFFFFFF) then
- local weap_obj = get_object_memory(weap_id)
- if (weap_obj ~= 0) then
- local obj_type = read_byte(weap_obj + 0xB4)
- local tag_address = read_word(weap_obj)
- local tagdata = read_dword(read_dword(0x40440000) + tag_address * 0x20 + 0x14)
- if (read_bit(tagdata + 0x308,3) == 1) then
- response = true
- end
- end
- end
- end
- end
- end
- return response
- end
- function isinvehicle(PlayerIndex)
- local player_object = get_dynamic_player(PlayerIndex)
- if player_object ~= 0 then
- local vehicleId = read_dword(player_object + 0x11C)
- if vehicleId == 0xFFFFFFFF then
- return false
- else
- return true
- end
- else
- return false
- end
- end
- function OnScriptUnload() end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
- -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
- -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement