Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ### Vehicle Leap & Emergency Brake 1.0 ###]]--
- --[[ ### by H® Shaft for SAPP ###]]--
- -- Allows drivers to activate a vehicle leap (brake key/space bar) and will notify them by message: Vehicle Leap Activated!
- -- Allows drivers to activate an emergency brake (crouch key) and will notify them by message: Emergency Brake Activated! this halts forward/reverse and lateral movement
- -- Editable parameters allow admins to enable/disable leap/brake per-map, and velocity of the leap
- -- Emergency Brake: Can cause the appearance of a lag twich if crouch is pressed and held down, but does not cause any lag whatsoever
- -- Supports all stock maps for Halo PC/CE, and you can add your own to the tables below, and should be added to all 3 tables
- -- Designed for movable ground vehicles only! Does not work properly for flying vehicles
- -- If the boolean is true for the map then vehicle leap will be enabled for the map, activated by brake key (space bar)
- -- Enable/Disable Leap Table: ensure each line separated by a comma between each line
- enable_vehicle_leap = {
- beavercreek = false,
- bloodgulch = true,
- boardingaction = true,
- carousel = false,
- chillout = false,
- damnation = false,
- dangercanyon = true,
- deathisland = true,
- gephyrophobia = true,
- hangemhigh = false,
- icefields = true,
- infinity = true,
- longest = false,
- prisoner = false,
- putput = false,
- ratrace = false,
- sidewinder = true,
- timberland = true,
- wizard = false,
- }
- -- Specify the upward leap velocity value for each map that you want
- -- Leap Velocity Table: ensure each line separated by a comma between each line
- vehicle_velocity = {
- beavercreek = 0,
- bloodgulch = 1.85,
- boardingaction = 0,
- carousel = 0,
- chillout = 0,
- damnation = 0,
- dangercanyon = 1.65,
- deathisland = 1.8,
- gephyrophobia = 1.9,
- hangemhigh = 0,
- icefields = 1.8,
- infinity = 1.85,
- longest = 0,
- prisoner = 0,
- putput = 0,
- ratrace = 0,
- sidewinder = 2.2,
- timberland = 1.8,
- wizard = 0,
- }
- -- Specify if you want emergency brake enabled each map, activated by crouch key
- -- Enable/Disable Brake Table: ensure each line separated by a comma between each line
- emergency_brake = {
- beavercreek = false,
- bloodgulch = true,
- boardingaction = false,
- carousel = false,
- chillout = false,
- damnation = false,
- dangercanyon = true,
- deathisland = true,
- gephyrophobia = true,
- hangemhigh = false,
- icefields = true,
- infinity = true,
- longest = false,
- prisoner = false,
- putput = false,
- ratrace = false,
- sidewinder = true,
- timberland = true,
- wizard = false,
- }
- --Note: if your map name has spaces, comma, hyphen, brackets, parenthesis or periods, try enclosing the 'map name' like ["this"] in the above tables:
- --Example: ["Classic Coagulation"] = value,
- -- SAPP api version --
- api_version = "1.8.0.0"
- -- do not touch --
- brakes = {}
- jumps = {}
- function OnScriptLoad()
- register_callback(cb['EVENT_TICK'],"OnTick")
- register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
- register_callback(cb['EVENT_LEAVE'],"OnPlayerLeave")
- register_callback(cb['EVENT_GAME_START'],"NewGame")
- end
- function OnScriptUnload()
- end
- function NewGame()
- map = get_var(1,"$map") or "unknown"
- local mapname = map
- enable_vehicle_leap[mapname] = enable_vehicle_leap[mapname] or false
- vehicle_velocity[mapname] = vehicle_velocity[mapname] or 0
- emergency_brake[mapname] = emergency_brake[mapname] or false
- end
- function OnTick()
- local mapname = map
- for i=1,16 do
- local player_dyn = get_dynamic_player(i)
- if (player_dyn ~= 0) then
- local vehicle_objectid = read_dword(player_dyn + 0x11C)
- local vehicle_object = get_object_memory(vehicle_objectid)
- if (vehicle_object ~= 0) then
- if PlayerIsDriver(i) then
- if brakes[i] > 0 then brakes[i] = brakes[i] - 1 end
- if jumps[i] > 0 then jumps[i] = jumps[i] - 1 end
- if enable_vehicle_leap[mapname] then
- -- activated on brake key/space bar
- if (jumps[i] == 0) and (read_bit(player_dyn + 0x208, 1) == 1) then
- local vel = (vehicle_velocity[mapname] / 10)
- jumps[i] = math.floor(4*30)
- say(i, "Vehicle Leap Activated!")
- write_bit(vehicle_object + 0x10, 5, 1)
- write_float(vehicle_object + 0x70, vel)
- end
- end
- if emergency_brake[mapname] then
- -- activated on crouch key
- if (brakes[i] == 0) and (bit.band(read_dword(player_dyn + 0x208),7) == 1) then
- brakes[i] = math.floor(1.5*30)
- say(i, "Emergency Brake Activated!")
- write_float(vehicle_object + 0x68, read_float(vehicle_object + 0x68)*0.05)
- write_float(vehicle_object + 0x6C, read_float(vehicle_object + 0x6C)*0.05)
- end
- end
- end
- end
- end
- end
- end
- function OnPlayerJoin(PlayerIndex)
- if player_present(PlayerIndex) then
- brakes[PlayerIndex] = 0
- jumps[PlayerIndex] = 0
- end
- end
- function OnPlayerLeave(PlayerIndex)
- if player_present(PlayerIndex) then
- brakes[PlayerIndex] = nil
- jumps[PlayerIndex] = nil
- end
- end
- -- Thanks to 002 for this piece:
- function PlayerIsDriver(PlayerIndex)
- if (player_present(PlayerIndex) == false) then return false end
- local player_object = get_dynamic_player(PlayerIndex)
- local player_object_id = read_dword(get_player(PlayerIndex) + 0x34)
- local vehicleId = read_dword(player_object + 0x11C)
- if (vehicleId == 0xFFFFFFFF) then return false end
- local obj_id = get_object_memory(vehicleId)
- return read_dword(obj_id + 0x324) == player_object_id
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement