-- This example creates a vehicle and warps the player into the driver's seat
-- Retrieve the player ped
local playerPed = PlayerPedId()
-- Define the vehicle model and check if it exists in the game files
local modelHash = `adder` -- Use Compile-time hashes to get the model hash
if not IsModelInCdimage(modelHash) then
return
end
-- Request the model and wait for it to load
RequestModel(modelHash)
repeat
Wait(0)
until HasModelLoaded(modelHash)
-- Create the vehicle at the player's coordinates with a heading of 0.0
local coordsPlayer, heading = GetEntityCoords(playerPed), 0.0
local vehicle = CreateVehicle(modelHash, coordsPlayer, heading, true, false)
-- Define the seat index for the Ped (e.g., -1 for the driver's seat)
local seatIndex = -1
-- Check if the vehicle exists and the player is alive
if not DoesEntityExist(vehicle) or IsEntityDead(playerPed) then
return
end
-- Warp the Ped into the specified vehicle seat
TaskWarpPedIntoVehicle(playerPed, vehicle, seatIndex)