Scripting/Squirrel/Functions/Players/FindPlayer
From VC-MP Wiki
This find a player from either id or name and returns the pointer.
Syntax
player FindPlayer( string name )
player FindPlayer( int id )
Arguments
- name - The name of the player to find. Can be partial.
- id - The ID of the player to find
Example
This example command will kill a player. Type '/c kill PlayerName/PlayerID'. The killed person will get a message.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "kill" ) { local plr = FindPlayer( text ); if ( !plr ) MessagePlayer( "Error: Player '" + text + "' is not online.", player ); else { plr.Health = 0; MessagePlayer( "You were killed by " + player.Name + "!!!", plr ); } } }
Notes
The functions MessagePlayer, player.Health, player.Name and call onPlayerCommand were used in in this example. More info about them in 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
