Jump to content

SetElementPosition [ Trouble ]


Z4Zy

Recommended Posts

Hello !

         Below code working find without any error !

addEventHandler("onPlayerLogin",root,
function ()
    bindKey(source,"1","down",
    function (p)
        setElementPosition(p,0,0,5)
    end)
end
)

When player login, button 1 will bind to the function. So, when player press 1 key, he will wrap in to the position. But the problem is, when player in a vehicle, he wouldn't wrap into the position... ! There's a way to solve this like if player in a vehicle when he press 1, vehicle will destroy and player wrapped into the position. But,  I want to wrap the player to the position without destroying the vehicle. Are there any way to troubleshoot by problem ? or any alternative way ? Please Help Me !

-------------------------------------------------------------------------------------------------------------------------------------------

heheey ! There's a  function called 'removePedFromVehicle'. That was helped me in this occasion !! Thank You @removePedFromVehicle ..!! :lol:

Edited by DeadthStrock
Problem Resolved !
Link to post
1 hour ago, Dzsozi (h03) said:

Check if the player is in a vehicle and then set the vehicle’s position as well.


local vehicle = getPedOccupiedVehicle(p)
if vehicle then
  setElementPosition(vehicle, 0, 0, 5)
end

 

what if player should wrap to one position and his vehicle to another position ?

Link to post

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