Jump to content
alt:V Multiplayer Forum
Sign in to follow this  
echo

[JS] SetPlayerToVehicle

Recommended Posts

Hey guys, i haven't found yet a native, that can instantly set a player to a vehicle's driving seat easily, so i made myself one, that i'd like to share with you.

Feel free to use my little script. :)

/*  Client Side Function  */
export function setPlayerToVehicle( vehicle ) {
    if ( vehicle === null || !vehicle.valid ) return;
    
    let interval = alt.setInterval( () => {
        if ( alt.Player.local.vehicle == vehicle ) alt.clearInterval(interval);
		
        native.taskEnterVehicle(alt.Player.local.scriptID, vehicle.scriptID, 100, -1, 2, 16, 0);
    }, 0 );
}

/*  To call it from the server  */
alt.onServer( "setPlayerToVehicle", vehicle => {
    setPlayerToVehicle( vehicle )
});

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...