Jump to content

Warp player instantly into a vehicle


Vivalavido

Recommended Posts

Hey guys, ive been trying to warp a player instantly in a car when he does a command

Ive looked at the tutorial on the wiki

function createstartvehicles ( playerSource, commandName, car, x, y, z ) -- the function allows specification of your car, and the position 
  
    local racevehicle = createVehicle ( car, x, y, z )                   -- create a vehicle at the position specified by the startrace command 
    warpPlayerIntoVehicle ( playerSource, racevehicle )                  -- warp them straight into the vehicle 
end 
  
  
addCommandHandler ( "startrace", createstartvehicles )                   -- add a command to start race 

It also states at above:

This function is deprecated. This means it does not exist any more but there should be an alternative (usually more generic) way of performing what it once did.

Ive tried the script, get a bad argument @ createVehicle AND warpPlayerIntoVehicle.

Are there alternatives off warping a player into a vehicle by command?

Link to comment
Hey guys, ive been trying to warp a player instantly in a car when he does a command

Ive looked at the tutorial on the wiki

function createstartvehicles ( playerSource, commandName, car, x, y, z ) -- the function allows specification of your car, and the position 
  
    local racevehicle = createVehicle ( car, x, y, z )                   -- create a vehicle at the position specified by the startrace command 
    warpPlayerIntoVehicle ( playerSource, racevehicle )                  -- warp them straight into the vehicle 
end 
  
  
addCommandHandler ( "startrace", createstartvehicles )                   -- add a command to start race 

It also states at above:

This function is deprecated. This means it does not exist any more but there should be an alternative (usually more generic) way of performing what it once did.

Ive tried the script, get a bad argument @ createVehicle AND warpPlayerIntoVehicle.

Are there alternatives off warping a player into a vehicle by command?

Which mta are you using? DP2? nightly's?

Link to comment
Which mta are you using? DP2? nightly's?
It also states at above:

This function is deprecated. This means it does not exist any more but there should be an alternative (usually more generic) way of performing what it once did.

Scar and Vivalavido, both guesses are wrong. I'll show the line which shows it.

Ive tried the script, get a bad argument @ createVehicle AND warpPlayerIntoVehicle.

If there's a bad argument in createVehicle, ofcourse then no vehicle is created. Simple as that. :P

So ehm, I see you're using parameters "car, x, y, z". Are you filling in ALL of them? And are you aware of car has to be a NUMBER value? Not a name.

So what command are you using? Could help us a lot helping you. ;)

Link to comment

function createstartvehicles ( playerSource, commandName, car, x, y, z ) -- the function allows specification of your car, and the position 
  
    local racevehicle = createVehicle ( car, x, y, z )                   -- create a vehicle at the position specified by the startrace command 
    warpPlayerIntoVehicle ( playerSource, racevehicle )                  -- warp them straight into the vehicle 
end 
  
  
addCommandHandler ( "startrace", createstartvehicles )                   -- add a command to start race 

All the values passed to the function (createVehicle) must be numbers, arguments from command are all string, so? So, convert the values from the command to numbers:

createVehicle( tonumber( car ), tonumber( x ), tonumber( y ), tonumber( z ) ) 

Link to comment
Welll, basicly. I want to warp a player into a vehicle instantly by typing a command. But all my try's are fails. :(

What do you type when you see get that warnings about bad arguments? Post the entire text that you type before you press Enter.

Link to comment

All the values passed to the function (createVehicle) must be numbers, arguments from command are all string, so? So, convert the values from the command to numbers:

createVehicle( tonumber( car ), tonumber( x ), tonumber( y ), tonumber( z ) ) 

Exactly. So you've gotta change that in your script and try again, but filling your command regularly. Example:

/startrace 522 0 0 0 

This would create a vehicle on the middle of SA map (x = 0, y = 0, z = 0).

Try it and say us did it work.

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