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.
| Property | Type | Access | Description |
|---|---|---|---|
ID | integer | r | The player id (0 to max_players-1). Unique while connected. |
Name | string | r | Nickname. |
IP | string | r | IP address. |
LUID | string | r | Machine 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 / ColoredName | string | r | Same as Name (kept so scripts that read it keep working). |
Platform | integer | r | The 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. |
Ping | integer | r | Latency in ms. |
Spawned | boolean | r | True once they have spawned in the world; false on the class screen. |
Health | float | rw | 0-100. |
Armour | float | rw | 0-100. |
Pos | Vector | rw | World position. Writing teleports the player. |
Angle | float | rw | Heading in degrees. |
Velocity | Vector | rw | Movement speed. Writing flings the player. |
Skin | integer | rw | Ped model id; 200-299 = a custom skin declared with <skin> in Script.xml. |
Score | integer | rw | Score shown on the scoreboard. |
Cash | integer / float | rw | Money. Setting it updates the HUD. With ToggleRealMoney(true) (v0.5.1) it is a float with cents (21.37). |
WantedLevel | integer | rw | 0-6 stars. See the Traffic chapter for how police react. |
Weapon | integer | r | Weapon currently held (WEP_*). |
WeaponAmmo | integer | r | Ammo of the current weapon. |
WeaponClip | integer | r | Rounds left in the CLIP of the current weapon (reported by the client; clients without it give the total ammo). |
Vehicle | Vehicle|null | rw | The vehicle they are in, or null. Set to a vehicle to warp them into the driver seat; set null to throw them out. |
VehicleSeat | integer | r | 0 = driver, 1-8 passengers, -1 on foot. |
Frozen | boolean | rw | Cannot move while true. |
Muted | boolean | rw | v0.2.4+: while true the default chat broadcast is skipped for that player (scripts that handle onPlayerChat themselves should test it). |
ImprovedCarCam | boolean | rw | v0.2.9-r3+: the improved vehicle camera on that players PC client (same as ToggleImprovedCarCam(player, bool)). Android ignores it. |
BlipStyle | integer | rw | v0.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 / ImprovedPlayerBlips | boolean | rw | v0.3.3+: circular radar blips with height chevrons on that player screen (same as ToggleImprovedPlayerBlips(player, bool)). PC and Android. |
DriveBy | boolean | rw | v0.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. |
InfiniteSprint | boolean | rw | Never runs out of breath. |
Team | integer | rw | Team number (your own meaning). |
Colour | integer | rw | Index into the <colour> palette of content.xml (nametag/blip colour). |
Nametag | boolean | rw | Show the name above the head. |
Marker | boolean | rw | false hides this player's radar blip for everybody, whatever MarkerType says. |
MarkerType | integer | rw | How 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). |
Alpha | integer | rw | 0-255 transparency of the player model (255 = opaque). Seen by everybody, also on the player himself. Since 0.3-r4 it really renders transparent. |
AllowVoiceChat | boolean | rw | Default true. false = this player can neither talk nor hear (needs oice_chat on in server.conf). |
VoiceChannel | integer | rw | 0-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. |
VoiceDistance | float | rw | 0-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. |
IsTalking | boolean | r | true while a voice frame from this player was relayed in the last 0.4 s. |
NametagLOS | boolean | rw | Default 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). |
VirtualWorld | integer | rw | Players, vehicles, objects, pickups, spheres and blips only see each other inside the same virtual world. 0 is the main world. |
IsNPC | boolean | r | True for server NPCs. |
Immune | boolean | rw | v0.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.) |
Action | integer | rw | v0.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. |
NoFallAnim | boolean | rw | v0.3-r2+: true = a fall in the air is a plain drop (no fall pose, no fall state). Per session, reset when he reconnects. |
NoStumble | boolean | rw | v0.3-r2+: true = no stagger / knock-down / get-up (the stumble back after jumping into a wall, small hits). Per session. |
DisableJump | boolean | rw | true = 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. |
DisableSprint | boolean | rw | true = the sprint button does nothing on foot. Per session. |
DisableAttack | boolean | rw | true = the attack button (punch and fire) does nothing on foot. Per session. |
AirShoot | boolean | rw | true = 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. |
WeaponAccuracy | integer | rw | 0-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. |
Tag | string | rw | The 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 / TagColor | Colour|integer | rw | Colour of the Tag line: a Colour or 0xRRGGBB. Reading gives the 0xRRGGBB integer. |
Player methods
Methods and functions
- player.SetWeapon – Gives a weapon (WEP_*, ids 0-12) and ammo, and makes it the active weapon.
- player.ClearWeapons – Removes all weapons.
- player.GetWeaponAmmoAtSlot – Ammo the server has recorded for weapon id 0-12.
- player.SetAnim – Plays an animation on the player (and for everyone who sees them).
- player.RemoveLimb – Detaches a body part on every client (BODYPART_*).
- player.RemoveFromVehicle – Forces the player out of their vehicle.
- player.Spawn – Force-spawns the player at their current class.
- player.RespawnAt – (v0.5-rc2+) Like player.Spawn() but at the given position (and heading in degrees, default the current one).
- player.ForceToSpawnScreen – Sends the player back to the class selection screen.
- player.CheckFileHash – Asks the player's game for the CRC32 of a file (path relative to their GTA III folder).
Categories: Server classes