Scripting/Server/Classes/Player

A human player (or an NPC - see chapter 6). Everything you do to a player is sent to their game automatically; changes are visible to everybody who can see them.

PropertyTypeAccessDescription
IDintegerrThe player id (0 to max_players-1). Unique while connected.
NamestringrNickname.
IPstringrIP address.
LUIDstringrMachine id of the player (v0.2.3+): the SHA-1 hex digest (40 characters) of the id their game sent - PC: hard-disk serial + SMBIOS system/board/CPU ids, Android: the device id. Stable across renames and IP changes, so it makes a good account/ban key. The server never sees or prints the raw id. Clients older than 0.2.3 send none and get a digest of their IP instead.
ColouredName / ColoredNamestringrSame as Name (kept so scripts that read it keep working).
PlatformintegerrThe game the player joined with (v0.4-beta+): PLATFORM_PC (0) or PLATFORM_ANDROID (1). Older clients read as PC. Use it for things that need a real keyboard, e.g. show a dialog instead of a self-drawn window to phone players.
PingintegerrLatency in ms.
SpawnedbooleanrTrue once they have spawned in the world; false on the class screen.
Healthfloatrw0-100.
Armourfloatrw0-100.
PosVectorrwWorld position. Writing teleports the player.
AnglefloatrwHeading in degrees.
VelocityVectorrwMovement speed. Writing flings the player.
SkinintegerrwPed model id; 200-299 = a custom skin declared with <skin> in Script.xml.
ScoreintegerrwScore shown on the scoreboard.
Cashinteger / floatrwMoney. Setting it updates the HUD. With ToggleRealMoney(true) (v0.5.1) it is a float with cents (21.37).
WantedLevelintegerrw0-6 stars. See the Traffic chapter for how police react.
WeaponintegerrWeapon currently held (WEP_*).
WeaponAmmointegerrAmmo of the current weapon.
WeaponClipintegerrRounds left in the CLIP of the current weapon (reported by the client; clients without it give the total ammo).
VehicleVehicle|nullrwThe vehicle they are in, or null. Set to a vehicle to warp them into the driver seat; set null to throw them out.
VehicleSeatintegerr0 = driver, 1-8 passengers, -1 on foot.
FrozenbooleanrwCannot move while true.
Mutedbooleanrwv0.2.4+: while true the default chat broadcast is skipped for that player (scripts that handle onPlayerChat themselves should test it).
ImprovedCarCambooleanrwv0.2.9-r3+: the improved vehicle camera on that players PC client (same as ToggleImprovedCarCam(player, bool)). Android ignores it.
BlipStyleintegerrwv0.5-beta+: how that player sees the radar blips of the other players: BLIPSTYLE_DEFAULT (0, the stock coloured squares), BLIPSTYLE_IMPROVED (1, circles with height chevrons, = ImprovedBlips) or BLIPSTYLE_CENTRE (2, the arrow of the radar centre (HUD radar_centre) tinted with the player colour and turned the way that player faces). Same as SetPlayerBlipStyle(player, style). PC and Android; an older client shows the circles for style 2.
ImprovedBlips / ImprovedPlayerBlipsbooleanrwv0.3.3+: circular radar blips with height chevrons on that player screen (same as ToggleImprovedPlayerBlips(player, bool)). PC and Android.
DriveBybooleanrwv0.2.4+: native drive-by. While true, that player can shoot from a car with a colt45, uzi, shotgun, ak47 or m16: the camera goes to free mouse look, a crosshair is drawn in the screen centre, and the fire button (left mouse / Ctrl) fires real bullets through the crosshair with the weapon the player holds - peds, traffic, NPCs and players take hits like on foot. No animation. Needs a 0.2.4+ client. Default false; set it in onPlayerSpawn.
InfiniteSprintbooleanrwNever runs out of breath.
TeamintegerrwTeam number (your own meaning).
ColourintegerrwIndex into the <colour> palette of content.xml (nametag/blip colour).
NametagbooleanrwShow the name above the head.
Markerbooleanrwfalse hides this player's radar blip for everybody, whatever MarkerType says.
MarkerTypeintegerrwHow the other players see this player on the radar and in the world: 0 = no radar blip at all, 1 = radar blip only (the default, no in-world arrow), 2 = radar blip plus the in-world arrow marker. Values above 2 are clamped to 2 (the server itself uses 3 for bots: hidden, and not on the TAB scoreboard - a script cannot set it). Marker = false hides the blip whatever the type is. Careful: the constants MARKER_TYPE_BOTH (0), MARKER_TYPE_PLAYER (1) and MARKER_TYPE_VEHICLE (2) carry these numbers, but their names do not describe what the numbers do - go by the meanings above (see A.3).
Alphaintegerrw0-255 transparency of the player model (255 = opaque). Seen by everybody, also on the player himself. Since 0.3-r4 it really renders transparent.
AllowVoiceChatbooleanrwDefault true. false = this player can neither talk nor hear (needs oice_chat on in server.conf).
VoiceChannelintegerrw0-512, default 0. The channel this player talks on and listens to. 0 = everybody hears him; N = only players who are also on channel N hear him. Everybody still hears channel 0 speakers.
VoiceDistancefloatrw0-5000 metres, default 0 (unlimited). How close a listener has to be to hear this player; full volume up to 30 % of the distance, fading to silence at the limit.
IsTalkingbooleanrtrue while a voice frame from this player was relayed in the last 0.4 s.
NametagLOSbooleanrwDefault false. When true, other players do not see this players nametag while a building, vehicle or object is between their camera and him (same line-of-sight test as Text3D.CheckLOS).
VirtualWorldintegerrwPlayers, vehicles, objects, pickups, spheres and blips only see each other inside the same virtual world. 0 is the main world.
IsNPCbooleanrTrue for server NPCs.
Immunebooleanrwv0.3-r2+: while true nothing can hurt that player - bullets, explosions, falls, drowning, fire, vehicles; his health is pinned by his own game. Works on NPCs too. Setting Health from a script still works. (Immunity is an alias.)
Actionintegerrwv0.3-r2+: what the player's ped is doing right now (ACTION_*, see A.12), updated by his game. Writing ACTION_NORMAL cancels a fall / stagger / get-up he is in at that moment. Changes fire onPlayerActionChange.
NoFallAnimbooleanrwv0.3-r2+: true = a fall in the air is a plain drop (no fall pose, no fall state). Per session, reset when he reconnects.
NoStumblebooleanrwv0.3-r2+: true = no stagger / knock-down / get-up (the stumble back after jumping into a wall, small hits). Per session.
DisableJumpbooleanrwtrue = the jump button does nothing for that player while he is on foot (in a vehicle the same buttons are handbrake, accelerate and fire and are not touched). Per session, reset when he reconnects. DisableSprint and DisableAttack work the same way.
DisableSprintbooleanrwtrue = the sprint button does nothing on foot. Per session.
DisableAttackbooleanrwtrue = the attack button (punch and fire) does nothing on foot. Per session.
AirShootbooleanrwtrue = the player can fire the gun he holds while he is jumping or falling (the stock game ignores the fire button in the air). Per session.
WeaponAccuracyintegerrw0-100, default 100 = perfect aim. Lower values bend the bullet line of that player's guns by a random angle (up to about 12 degrees at 0). Applied by his own game.
TagstringrwThe line under the name above the head, drawn by every client (for example a clan tag like [CW]). null removes it. Works on NPC handles too.
TagColour / TagColorColour|integerrwColour of the Tag line: a Colour or 0xRRGGBB. Reading gives the 0xRRGGBB integer.

Player methods

Methods and functions

Categories: Server classes