Scripting/Squirrel/Functions/Players/Vehicle
From VC-MP Wiki
This instance variable returns or sets the vehicle player is driving.
Syntax
vehicle player.Vehicle player.Vehicle = newVehicle
Example 1. Returning
This command gives the vehicle player is driving when someone types '/c car playername'.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "car" ) { local plr = FindPlayer( text ); if ( !plr ) MessagePlayer( "Error: Player '" + text + "' is not online.", player ); else MessagePlayer( plr.Name + "'s vehicle: " + plr.Vehicle, player ); } }
Notes
The functions MessagePlayer, FindPlayer, player.Name and call onPlayerCommand were used in in this example. More info about them in corresponding pages.
Example 2. Setting
This command puts the player into a car when they type '/c gimmeacar'.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "gimmeacar" ) { player.Vehicle = FindVehicle( 1 ); } }
Notes
The function onPlayerCommand and call onPlayerCommand were used in in this example. More info about them in the corresponding pages.
Related Functions
- FindPlayer
- Player.Angle
- Player.Armour
- Player.Cash
- Player.Class
- Player.DrivebyAbility
- Player.GetSpectating
- Player.GetSyncBlockedTo
- Player.Health
- Player.ID
- Player.IP
- Player.IsAdmin
- Player.IsFrozen
- Player.IsIgnoredBy
- Player.IsMuted
- Player.IsPassenger
- Player.IsSpawned
- Player.IsSyncBlocked
- Player.IsWeaponSyncBlocked
- Player.Keys
- Player.Name
- Player.Ping
- Player.Pos
- Player.RemoveLocalMarker
- Player.RemoveMarker
- Player.ResetGameSettings
- Player.Score
- Player.Seat
- Player.SetAnim
- Player.SetDrunkLevel
- Player.SetIgnoredBy
- Player.SetInterior
- Player.SetLocalMarker
- Player.SetMarker
- Player.SetSyncBlockedTo
- Player.WantedLevel
- Player.SetWeapon
- Player.Skin
- Player.SpawnPos
- Player.Team
- Player.Vehicle
- Player.Weapon
- Player.ShootInAir
- Player.StuntMode
- Player.Spikes
