Jump to content

Teleport command problem


Recommended Posts

hi i have a problem whit my teleport cmd.

i wanna teleport with my car but i can execute the cmd if i stay in a vehicle =S.

this is the cmd.

function drift ( hitPlayer, commandName, posX, posY, posZ, player ) 
    
        setElementPosition ( hitPlayer,-759.8561,-240.8489,51.8462) 
         
end 
addCommandHandler ( "drift", drift  ) 

if i dont have vehicle run perfectly they have no erros.

why is the problem?

bye and sorry for my english :P

Link to comment

Try this:

function drift ( hitPlayer, commandName) 
    if isPlayerInVehicle (hitPlayer) then 
        setElementPosition (getPlayerOccupiedVehicle (hitPlayer),-759.8561,-240.8489,51.8462) 
    else 
        setElementPosition ( hitPlayer,-759.8561,-240.8489,51.8462) 
    end 
end 
addCommandHandler ( "drift", drift  ) 

I didn't test it, but it looks like fine to me. As you can see, script checks if player is driving, if he is, then vehicle he is in is put into that place. Also, I removed posX, posY, posZ, player arguments from the function because they're unused :)

Link to comment
Try this:

function drift ( hitPlayer, commandName) 
    if isPlayerInVehicle (hitPlayer) then 
        setElementPosition (getPlayerOccupiedVehicle (hitPlayer),-759.8561,-240.8489,51.8462) 
    else 
        setElementPosition ( hitPlayer,-759.8561,-240.8489,51.8462) 
    end 
end 
addCommandHandler ( "drift", drift  ) 

I didn't test it, but it looks like fine to me. As you can see, script checks if player is driving, if he is, then vehicle he is in is put into that place. Also, I removed posX, posY, posZ, player arguments from the function because they're unused :)

Thanks man Works!

the problem is if you are in a bike you fall but y know how fix setting player un nokable off bike.

relly man you save my life :D

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