Jump to content

Spawn car


Recommended Posts

function autoescola()
	triggerServerEvent("TeoriaCompleta", getLocalPlayer())
	local x, y, z = testRoute[1][1], testRoute[1][2], testRoute[1][3]
	blip = createBlip(x, y, z, 0, 2, 0, 255, 0, 255)
	marker = createMarker(x, y, z, "checkpoint", 4, 0, 255, 0, 150) 
	addEventHandler("onClientMarkerHit", marker, comecarautoescola)
	
	outputChatBox("#FF9933You are ready for the practical test. Take a DoL training machine and follow the route..", 255, 194, 14, true)
	
end

I would like that after appearing the message saying that it is ready for the practical test, the player was spawn automatically with a car in this position =(1090.815,-1769.211, 13.352)

How i can do this?

Link to comment
1 hour ago, WorthlessCynomys said:

Hy!


createVehicle()
setElementPosition()
warpPedIntoVehicle()

 

function autoescola()
	triggerServerEvent("TeoriaCompleta", getLocalPlayer())
	local x, y, z = testRoute[1][1], testRoute[1][2], testRoute[1][3]
	blip = createBlip(x, y, z, 0, 2, 0, 255, 0, 255)
	marker = createMarker(x, y, z, "checkpoint", 4, 0, 255, 0, 150) 
	addEventHandler("onClientMarkerHit", marker, comecarautoescola)
	
	outputChatBox("#FF9933You are ready for the practical test. Take a DoL training machine and follow the route..", 255, 194, 14, true)
    local test = createVehicle(410, 1090.815, -1769.211, 13.352)
	warpPedIntoVehicle ( getLocalPlayer, test )	
end

so I used this command and the car is being created but the player is not set in it, remembering that I am in different dimension and interior.

Link to comment
Just now, murilo2929 said:

function autoescola()
	triggerServerEvent("TeoriaCompleta", getLocalPlayer())
	local x, y, z = testRoute[1][1], testRoute[1][2], testRoute[1][3]
	blip = createBlip(x, y, z, 0, 2, 0, 255, 0, 255)
	marker = createMarker(x, y, z, "checkpoint", 4, 0, 255, 0, 150) 
	addEventHandler("onClientMarkerHit", marker, comecarautoescola)
	
	outputChatBox("#FF9933You are ready for the practical test. Take a DoL training machine and follow the route..", 255, 194, 14, true)
    local test = createVehicle(410, 1090.815, -1769.211, 13.352)
	warpPedIntoVehicle ( getLocalPlayer, test )	
end

so I used this command and the car is being created but the player is not set in it, remembering that I am in different dimension and interior.

Then you should set the interior and dimension for the player or the vehicle before you warp the player into the new vehicle.

setElementInterior()
setElementDimension()

-- You can get the interior/dimension of an element with:
getElementInterior()
getElementDimension()

 

Link to comment
2 minutes ago, WorthlessCynomys said:

Then you should set the interior and dimension for the player or the vehicle before you warp the player into the new vehicle.


setElementInterior()
setElementDimension()

-- You can get the interior/dimension of an element with:
getElementInterior()
getElementDimension()

 

function autoescola()
	triggerServerEvent("TeoriaCompleta", getLocalPlayer())
	local x, y, z = testRoute[1][1], testRoute[1][2], testRoute[1][3]
	blip = createBlip(x, y, z, 0, 2, 0, 255, 0, 255)
	marker = createMarker(x, y, z, "checkpoint", 4, 0, 255, 0, 150) 
	addEventHandler("onClientMarkerHit", marker, comecarautoescola)
	
	outputChatBox("#FF9933You are ready for the practical test. Take a DoL training machine and follow the route..", 255, 194, 14, true)
    local test = createVehicle(410, 1090.815, -1769.211, 13.352)
	setElementDimension ( getLocalPlayer, 0 )
	setElementInterior ( getLocalPlayer, 0 )
	warpPedIntoVehicle ( getLocalPlayer, test )
end

 

i make like that, and don't work, what is wrong?

Link to comment
Just now, murilo2929 said:

function autoescola()
	triggerServerEvent("TeoriaCompleta", getLocalPlayer())
	local x, y, z = testRoute[1][1], testRoute[1][2], testRoute[1][3]
	blip = createBlip(x, y, z, 0, 2, 0, 255, 0, 255)
	marker = createMarker(x, y, z, "checkpoint", 4, 0, 255, 0, 150) 
	addEventHandler("onClientMarkerHit", marker, comecarautoescola)
	
	outputChatBox("#FF9933You are ready for the practical test. Take a DoL training machine and follow the route..", 255, 194, 14, true)
    local test = createVehicle(410, 1090.815, -1769.211, 13.352)
	setElementDimension ( getLocalPlayer, 0 )
	setElementInterior ( getLocalPlayer, 0 )
	warpPedIntoVehicle ( getLocalPlayer, test )
end

 

i make like that, and don't work, what is wrong?

The creation of the vehicle, the dimension and interior change and the warp has to happen on server-side!

Link to comment
20 minutes ago, WorthlessCynomys said:

You use the triggerServerEvent as above and catch the call on server-side, then you do the same as on client-side, only that you're on server-side now.

I put only in server-side and work, thanks alot

30 minutes ago, WorthlessCynomys said:

You use the triggerServerEvent as above and catch the call on server-side, then you do the same as on client-side, only that you're on server-side now.

One question, how i can make to when player hit marker the vehicle destroy?

Link to comment
1 hour ago, murilo2929 said:

I put only in server-side and work, thanks alot

One question, how i can make to when player hit marker the vehicle destroy?

Use 

addEventHandler -- "onPlayerMarkerHit"
getPedOccupiedVehicle
destroyElement

 

Link to comment

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...