it300

seat_mod

May 15th, 2017
284
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Drive as gunner script for Sapp 8.6.2+ ]]--
  2. -- By: Devieth aka Skylace
  3. -- Website: http://pastebin.com/u/it300
  4. -- Version 1.1
  5.  
  6. drive_as_gunner = true -- Lets the gunner drive the hog (if there is no driver)
  7. drive_as_passenger = false -- Lets the passender drive the hog (if there is no driver)
  8. set_passenger_in_driver_seat = false-- Sets the passenger in the driver seat (if there is no driver)
  9. set_passenger_in_gunner_seat = false -- Sets the passenger in gunner seat (if there is a driver)
  10.  
  11. api_version = "1.10.0.0"
  12.  
  13. function OnScriptLoad()
  14.     register_callback(cb['EVENT_VEHICLE_ENTER'], "OnVehicleEnter")
  15. end
  16.  
  17. function OnScriptUnload()end
  18.  
  19. function OnVehicleEnter(PlayerIndex, Seat)
  20.     local m_object = get_dynamic_player(PlayerIndex)
  21.     if m_object ~= 0 then
  22.         local m_vehicleId = read_dword(m_object + 0x11C)
  23.         if m_vehicleId ~= 0 then
  24.             local m_vehicle = get_object_memory(m_vehicleId)
  25.             if m_vehicle ~= 0 then
  26.                 local driver = read_dword(m_vehicle + 0x324)
  27.                 local gunner = read_dword(m_vehicle + 0x328)
  28.                 if Seat == "2" then
  29.                     if drive_as_gunner then
  30.                         if driver == 0xFFFFFFFF then
  31.                             enter_vehicle(m_vehicleId, PlayerIndex, 0)
  32.                             exit_vehicle(PlayerIndex)
  33.                             enter_vehicle(m_vehicleId, PlayerIndex, 0)
  34.                             enter_vehicle(m_vehicleId, PlayerIndex, 2)
  35.                         end
  36.                     end
  37.                 elseif Seat == "1" then
  38.                     if set_passenger_in_driver_seat or set_passenger_in_gunner_seat then
  39.                         if driver == 0xFFFFFFFF then
  40.                             enter_vehicle(m_vehicleId, PlayerIndex, 0)
  41.                         else
  42.                             if gunner == 0xFFFFFFFF then
  43.                                 enter_vehicle(m_vehicleId, PlayerIndex, 2)
  44.                             end
  45.                         end
  46.                     elseif drive_as_passenger and not set_passenger_in_driver_seat then
  47.                         if driver == 0xFFFFFFFF then
  48.                             enter_vehicle(m_vehicleId, PlayerIndex, 0)
  49.                             exit_vehicle(PlayerIndex)
  50.                             enter_vehicle(m_vehicleId, PlayerIndex, 0)
  51.                             enter_vehicle(m_vehicleId, PlayerIndex, 1)
  52.                         end
  53.                     end
  54.                 elseif Seat == "0" then
  55.                     if driver ~= 0xFFFFFFFF then
  56.                         exit_vehicle(PlayerIndex)
  57.                     else
  58.                         say(PlayerIndex, "There is already a driver.")
  59.                     end
  60.                 end
  61.             end
  62.         end
  63.     end
  64.  
  65. end
RAW Paste Data