Jump to content

Warp player into car


GhostXoP

Recommended Posts

Posted

I have tried to use

warpPedIntoVehicle(source, VEHICLE) 

and this does not seem to be working

How can i spawn the player into a vehicle otherwise?(This is server side within an event handler triggered by the player)

Posted
  
function SpawnPlayerInCar(Vehicle) 
    warpPedIntoVehicle(source,Vehicle) 
  
end 
  
addEvent("Server,PutMeInMyCar", true) 
addEventHandler("Server.PutMeInMyCar", getRootElement(), SpawnPlayerInCar) 

SERVERSIDE

--spawn the vehicle where player is but spawn player within it 
  
local x,y,z = getElementPosition(getLocalPlayer()) 
  
local spawnedVehicle = createVehicle(Item.ID, x,y,z, 0, 0, 0, Item.LIC) 
  
triggerServerEvent("Server.PutMeInMyCar", getLocalPlayer(), spawnedVehicle) 

CLIENTSIDE

Posted

The vehicle doesn't exist on the server. It was created by the client and only exists on the client. You can't pass elements or other userdata if they do not exist on the other side.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...