Scripting/Squirrel/Functions/Players/Pos
From VC-MP Wiki
This instance variable returns or sets player's position.
Syntax
Vector player.Pos player.Pos = newPos
Example 1. Returning
This command tells player's location when someone types '/c loc playername'.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "loc" ) { local plr = FindPlayer( text ); if ( !plr ) MessagePlayer( "Error: Player '" + text + "' is not online.", player ); else { local pos = plr.Pos; MessagePlayer( plr.Name + "'s location: " + GetDistrictName( pos.x, pos.y ), player ); } } }
Notes
The functions MessagePlayer, FindPlayer, player.Name, GetDistrictName and call onPlayerCommand were used in in this example. More info about them in corresponding pages.
Example 2. Setting
This command teleports the player to another player when they type '/c goto playername'.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "goto" ) { local plr = FindPlayer( text ); if ( !plr ) MessagePlayer( "Error: Player '" + text + "' is not online.", player ); else player.Pos = plr.Pos; } }
Notes
The functions MessagePlayer, FindPlayer, player.Name 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
