Jump to content

[HELP]Teleport Command


JohnLehn

Recommended Posts

Hello! I have the code bellow,  how can i make it to teleport in vehicle? 

function sf (source, thePlayer)
local adminname = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..adminname, aclGetGroup ( "Admin" ) ) then 
	setElementPosition(thePlayer, -1997.923828125, 171.4658203125, 27.6875)
	else
	    outputChatBox("No acces!", thePlayer, 255, 0, 0)
	end
end
addCommandHandler("gotosf", sf)

 

Link to comment

You have to check if the player is in a vehicle, you can use getPedOccupiedVehicle for this.

If he is in a vehicle, you set the vehicle's position instead of the player, which is returned by the function mentioned above.

Also, your function will throw errors, as "thePlayer" value defined in your function is actually the command name that was executed, in this case "gotosf", check addCommandHandler for more info on this topic.

Link to comment
function sf(thePlayer, command)
local adminname = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..adminname, aclGetGroup ( "Admin" ) ) then 
	setElementPosition(thePlayer, -1997.923828125, 171.4658203125, 27.6875)
    warpPedIntoVehicle(thePlayer, theVehicle, 0)
	else
	    outputChatBox("No acces!", thePlayer, 255, 0, 0)
	end
end
addCommandHandler("gotosf", sf)

This is how it should look if you want to teleport the player in a vehicle

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