Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Config
- -- true or false, whether or not to allow entering seats
- ALLOW_DRIVER_SEAT = true
- ALLOW_GUNNER_SEAT = true
- ALLOW_PASSENGER_SEAT = true
- -- true or false, whether or not driver is required before other seats can be entered
- DRIVER_REQUIRED_FOR_PASSENGERS = false
- DRIVER_REQUIRED_FOR_GUNNER = false
- -- End of Config
- api_version = "1.9.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "OnGameStart")
- if(DRIVER_REQUIRED) then
- register_callback(cb['EVENT_TICK'], "OnTick")
- end
- end
- function OnGameStart()
- for i=0,1 do
- local vehicles_count = nil
- local vehicles_data = nil
- local size = nil
- if(i == 0) then
- local globals_tag = lookup_tag("matg", "globals\\globals")
- local globals_data = read_dword(globals_tag + 0x14)
- local mp_info_data = read_dword(globals_data + 0x168)
- vehicles_count = read_dword(mp_info_data + 0x20)
- vehicles_data = read_dword(mp_info_data + 0x24)
- size = 16
- else
- local scenario_tag = read_dword(0x40440000)
- local scenario_data = read_dword(scenario_tag + 0x14)
- vehicles_count = read_dword(scenario_data + 0x24C)
- vehicles_data = read_dword(scenario_data + 0x250)
- size = 48
- end
- for j=0,vehicles_count-1 do
- local vehicle_metaid = read_dword(vehicles_data + j*size + 0xC)
- if(vehicle_metaid ~= 0xFFFFFFFF) then
- local vehicle_tag = lookup_tag(vehicle_metaid)
- local vehicle_data = read_dword(vehicle_tag + 0x14)
- local seats_count = read_dword(vehicle_data + 0x2E4)
- local seats_data = read_dword(vehicle_data + 0x2E8)
- for k=0,seats_count-1 do
- if(read_bit(seats_data + k*284, 2) == 1) then -- if driver seat
- if(not ALLOW_DRIVER_SEAT) then
- write_string(seats_data + k*284 + 0x4, "Perhaps This Isn't A Valid Label")
- end
- elseif(read_bit(seats_data + k*284, 3) == 1) then -- if gunner seat
- if(not ALLOW_GUNNER_SEAT) then
- write_string(seats_data + k*284 + 0x4, "Perhaps This Isn't A Valid Label")
- end
- if(DRIVER_REQUIRED_FOR_GUNNER) then
- write_bit(seats_data + k*284 + 0x1, 1, 1) -- enables 'not valid without driver' flag
- end
- else -- if not driver and/or gunner seat assumed to be passenger seat
- if(not ALLOW_PASSENGER_SEAT) then
- write_string(seats_data + k*284 + 0x4, "Perhaps This Isn't A Valid Label")
- end
- if(DRIVER_REQUIRED_FOR_PASSENGERS) then
- write_bit(seats_data + k*284 + 0x1, 1, 1) -- enables 'not valid without driver' flag
- end
- end
- end
- end
- end
- end
- end
- function OnTick()
- for i=1,16 do
- if(player_alive(i)) then
- local player = get_dynamic_player(i)
- local player_vehicle_objectid = read_dword(player + 0x11C)
- if(player_vehicle_objectid ~= 0xFFFFFFFF) then
- local vehicle = get_object_memory(player_vehicle_objectid)
- local master_objectid = read_dword(vehicle + 0x324)
- local player_objectid = read_dword(get_player(i) + 0x34)
- if(master_objectid == player_objectid and read_byte(player + 0x2A3) == 27) then
- for j=1,16 do
- if(j ~= i and player_alive(j)) then
- local other_player = get_dynamic_player(j)
- local other_player_vehicle_objectid = read_dword(other_player + 0x11C)
- if(other_player_vehicle_objectid == player_vehicle_objectid and read_byte(other_player + 0x2A3) ~= 27) then
- exit_vehicle(j)
- end
- end
- end
- elseif(master_objectid == 0xFFFFFFFF and read_byte(player + 0x2A3) ~= 27) then
- exit_vehicle(i)
- end
- end
- end
- end
- end
- function OnScriptUnload() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement