Table of Contents

Class Player

Namespace
SampSharp.Entities.SAMP
Assembly
SampSharp.OpenMp.Entities.dll

Represents a component which provides the data and functionality of a player.

public class Player : WorldEntity
Inheritance
Player
Inherited Members

Constructors

Player(IOmpEntityProvider, IPlayer)

Constructs an instance of Player, should be used internally.

protected Player(IOmpEntityProvider entityProvider, IPlayer player)

Parameters

entityProvider IOmpEntityProvider
player IPlayer

Properties

Angle

Gets or sets the facing angle of this player.

public virtual float Angle { get; set; }

Property Value

float

AnimationIndex

Gets the animation index of the animation this player is currently playing.

public virtual int AnimationIndex { get; }

Property Value

int

AreWeaponsAllowed

Gets or sets a value indicating whether this player is allowed to use weapons.

public virtual bool AreWeaponsAllowed { get; set; }

Property Value

bool

Armour

Gets or sets the armor of this player.

public virtual float Armour { get; set; }

Property Value

float

AspectCameraRatio

Gets the aspect ratio of this player's camera.

public virtual float AspectCameraRatio { get; }

Property Value

float

BytesReceived

Gets the number of bytes received from this player.

public virtual int BytesReceived { get; }

Property Value

int

BytesSent

Gets the number of bytes sent to this player.

public virtual int BytesSent { get; }

Property Value

int

CameraFrontVector

Gets the front Vector3 of this player's camera.

public virtual Vector3 CameraFrontVector { get; }

Property Value

Vector3

CameraMode

Gets the CameraMode of this player's camera.

public virtual CameraMode CameraMode { get; }

Property Value

CameraMode

CameraPosition

Gets or sets the position of the camera of this player as a Vector3.

public virtual Vector3 CameraPosition { get; set; }

Property Value

Vector3

Remarks

The getter prefers the real-time client-reported camera position (aimData.camPos) and only falls back to getCameraPosition() (the last value explicitly set via setCameraPosition) when aim data hasn't arrived yet. open.mp's getCameraPosition returns (0,0,0) when the camera is in default 3rd-person mode (i.e. never explicitly set), which is what legacy SampSharp users would not expect — they need the actual visual camera location, not the last server intent.

CameraTargetActor

Gets the Actor the camera of this player is pointing at.

public virtual Actor? CameraTargetActor { get; }

Property Value

Actor

CameraTargetEntity

Gets the entity (Player, PlayerObject, object, Vehicle or Actor) the camera of this player is pointing at.

public virtual Component? CameraTargetEntity { get; }

Property Value

Component

CameraTargetGlobalObject

Gets the GlobalObject the camera of this player is pointing at.

public virtual GlobalObject? CameraTargetGlobalObject { get; }

Property Value

GlobalObject

CameraTargetPlayer

Gets the Player the camera of this player is pointing at.

public virtual Player? CameraTargetPlayer { get; }

Property Value

Player

CameraTargetPlayerObject

Gets the PlayerObject the camera of this player is pointing at.

public virtual PlayerObject? CameraTargetPlayerObject { get; }

Property Value

PlayerObject

CameraTargetVehicle

Gets the Vehicle the camera of this player is pointing at.

public virtual Vehicle? CameraTargetVehicle { get; }

Property Value

Vehicle

CameraZoom

Gets the game camera zoom level for this player.

public virtual float CameraZoom { get; }

Property Value

float

ClientVersion

Gets this player's ClientVersion.

public virtual ClientVersion ClientVersion { get; }

Property Value

ClientVersion

ClientVersionName

Gets this player's client version name.

public virtual string ClientVersionName { get; }

Property Value

string

Color

Gets or sets the Color of this player.

public virtual Color Color { get; set; }

Property Value

Color

ConnectedTime

Gets the TimeSpan this player has been connected to the server.

public virtual TimeSpan ConnectedTime { get; }

Property Value

TimeSpan

ConnectionStatus

Gets the ConnectionStatus of this player.

public virtual ConnectionStatus ConnectionStatus { get; }

Property Value

ConnectionStatus

CustomSkin

Gets or sets the active custom skin model ID for this player, or null if no custom skin is set.

public virtual uint? CustomSkin { get; set; }

Property Value

uint?

DefaultObjectsRemoved

Gets the number of default world objects that have been removed for this player.

public virtual int DefaultObjectsRemoved { get; }

Property Value

int

DrunkLevel

Gets or sets the drunkenness level of this player.

public virtual int DrunkLevel { get; set; }

Property Value

int

EndPoint

Gets the end point (IPAddress and port) of this player.

public virtual IPEndPoint EndPoint { get; }

Property Value

IPEndPoint

FightStyle

Gets or sets the FightStyle of this player.

public virtual FightStyle FightStyle { get; set; }

Property Value

FightStyle

Gpci

Gets this player's global computer identifier string.

public virtual string Gpci { get; }

Property Value

string

Gravity

Gets or sets this player's gravity.

public virtual float Gravity { get; set; }

Property Value

float

HasWidescreen

Gets or sets a value indicating whether widescreen mode is enabled for this player.

public virtual bool HasWidescreen { get; set; }

Property Value

bool

Health

Gets or sets the health of this player.

public virtual float Health { get; set; }

Property Value

float

InAnyVehicle

Gets a value indicating whether this player is currently in any vehicle.

public virtual bool InAnyVehicle { get; }

Property Value

bool

InCheckpoint

Gets a value indicating whether this player is in a checkpoint.

public virtual bool InCheckpoint { get; }

Property Value

bool

InRaceCheckpoint

Gets a value indicating whether this player is in a race checkpoint.

public virtual bool InRaceCheckpoint { get; }

Property Value

bool

Interior

Gets or sets the interior of this player.

public virtual int Interior { get; set; }

Property Value

int

Ip

Gets the IP of this player as a string.

public virtual string Ip { get; }

Property Value

string

IpAddress

Gets the IPAddress of this player.

public virtual IPAddress IpAddress { get; }

Property Value

IPAddress

IsAdmin

Gets a value indicating whether this player is logged into RCON.

public virtual bool IsAdmin { get; }

Property Value

bool

IsAlive

Gets a value indicating whether this player is alive.

public virtual bool IsAlive { get; }

Property Value

bool

IsBeingKicked

Gets a value indicating whether this player is in the process of being kicked.

public virtual bool IsBeingKicked { get; }

Property Value

bool

IsGhostModeEnabled

Gets or sets a value indicating whether ghost mode is enabled for this player.

public virtual bool IsGhostModeEnabled { get; set; }

Property Value

bool

Remarks

When enabled, other players will pass through this player as if they were not there.

IsNpc

Gets a value indicating whether this player is a bot (NPC).

public virtual bool IsNpc { get; }

Property Value

bool

IsOmpEntityDestroyed

Gets a value indicating whether the open.mp entity counterpart has been destroyed.

protected bool IsOmpEntityDestroyed { get; }

Property Value

bool

IsSelectingTextDraw

Gets a value indicating whether this player is selecting a text draw.

public virtual bool IsSelectingTextDraw { get; }

Property Value

bool

IsTeleportAllowed

Gets or sets a value indicating whether map-click teleporting is allowed for this player.

public virtual bool IsTeleportAllowed { get; set; }

Property Value

bool

IsUsingOfficialClient

Gets a value indicating whether this player is using the official Rockstar/SA-MP client (as opposed to open.mp, mobile/PSP, or an unofficial fork).

public virtual bool IsUsingOfficialClient { get; }

Property Value

bool

IsUsingOmp

Gets a value indicating whether this player is using the open.mp client.

public virtual bool IsUsingOmp { get; }

Property Value

bool

Menu

Gets the Menu this player is currently in.

public virtual Menu? Menu { get; }

Property Value

Menu

MessagesReceived

Gets the number of messages received from this player.

public virtual int MessagesReceived { get; }

Property Value

int

MessagesReceivedPerSecond

Gets the number of messages received from this player per second.

public virtual int MessagesReceivedPerSecond { get; }

Property Value

int

MessagesSent

Gets the number of messages sent to this player.

public virtual int MessagesSent { get; }

Property Value

int

Money

Gets or sets the money of this player.

public virtual int Money { get; set; }

Property Value

int

Name

Gets or sets the name of this player.

public virtual string Name { get; set; }

Property Value

string

Ping

Gets the ping of this player.

public virtual int Ping { get; }

Property Value

int

Score

Gets or sets the score of this player.

public virtual int Score { get; set; }

Property Value

int

Skin

Gets or sets the skin of this player.

public virtual int Skin { get; set; }

Property Value

int

SpecialAction

Gets or sets the SpecialAction of this player.

public virtual SpecialAction SpecialAction { get; set; }

Property Value

SpecialAction

State

Gets the PlayerState of this player.

public virtual PlayerState State { get; }

Property Value

PlayerState

StreamedForPlayers

Gets a lazy sequence of players for whom this player is currently streamed in.

public virtual IEnumerable<Player> StreamedForPlayers { get; }

Property Value

IEnumerable<Player>

SurfingEntity

Gets the Component (object or vehicle) that this player is surfing.

public virtual Component? SurfingEntity { get; }

Property Value

Component

TargetActor

Gets the Actor this player is aiming at.

public virtual Actor? TargetActor { get; }

Property Value

Actor

TargetPlayer

Gets the Player this player is aiming at.

public virtual Player? TargetPlayer { get; }

Property Value

Player

Team

Gets or sets the team this player is in.

public virtual int Team { get; set; }

Property Value

int

Vehicle

Gets the Vehicle this player is currently in.

public virtual Vehicle? Vehicle { get; }

Property Value

Vehicle

VehicleSeat

Gets the vehicle seat this player is occupying.

public virtual int VehicleSeat { get; }

Property Value

int

Remarks

Returns -1 if the player is not in a vehicle.

Velocity

Gets or sets the Vector3 velocity of this player.

public virtual Vector3 Velocity { get; set; }

Property Value

Vector3

WantedLevel

Gets or sets the wanted level of this player.

public virtual int WantedLevel { get; set; }

Property Value

int

Weapon

Gets the Weapon this player is currently holding.

public virtual Weapon Weapon { get; }

Property Value

Weapon

WeaponAmmo

Gets the ammunition of the Weapon this player is currently holding.

public virtual int WeaponAmmo { get; }

Property Value

int

WeaponState

Gets the WeaponState of the Weapon this player is currently holding.

public virtual WeaponState WeaponState { get; }

Property Value

WeaponState

Weather

Gets or sets the current weather for this player.

public virtual int Weather { get; set; }

Property Value

int

WorldBounds

Gets or sets the world bounds for this player as (maxX, minX, maxY, minY).

public virtual Vector4 WorldBounds { get; set; }

Property Value

Vector4

Methods

ApplyAnimation(string, string, float, bool, bool, bool, bool, int)

Applies an animation to this player.

[Obsolete("Use ApplyAnimation(string, string, float, bool, bool, bool, bool, TimeSpan, PlayerAnimationSyncType) instead.")]
public virtual void ApplyAnimation(string animationLibrary, string animationName, float fDelta, bool loop, bool lockX, bool lockY, bool freeze, int time)

Parameters

animationLibrary string

The name of the animation library.

animationName string

The name of the animation within the library.

fDelta float

The animation speed (typically 4.1).

loop bool

true to loop the animation; false to play it once.

lockX bool

If false, the player returns to their original X position after the animation completes (for moving animations). If true, the opposite occurs.

lockY bool

If false, the player returns to their original Y position after the animation completes (for moving animations). If true, the opposite occurs.

freeze bool

true to freeze the player in position after the animation finishes.

time int

The animation duration. Use Zero for an infinite loop.

ApplyAnimation(string, string, float, bool, bool, bool, bool, int, bool)

Applies an animation to this player.

[Obsolete("Use ApplyAnimation(string, string, float, bool, bool, bool, bool, TimeSpan, PlayerAnimationSyncType) instead.")]
public virtual void ApplyAnimation(string animationLibrary, string animationName, float fDelta, bool loop, bool lockX, bool lockY, bool freeze, int time, bool forceSync)

Parameters

animationLibrary string

The name of the animation library.

animationName string

The name of the animation within the library.

fDelta float

The animation speed (typically 4.1).

loop bool

true to loop the animation; false to play it once.

lockX bool

If false, the player returns to their original X position after the animation completes (for moving animations). If true, the opposite occurs.

lockY bool

If false, the player returns to their original Y position after the animation completes (for moving animations). If true, the opposite occurs.

freeze bool

true to freeze the player in position after the animation finishes.

time int

The animation duration. Use Zero for an infinite loop.

forceSync bool

ApplyAnimation(string, string, float, bool, bool, bool, bool, TimeSpan, PlayerAnimationSyncType)

Applies an animation to this player.

public virtual void ApplyAnimation(string animationLibrary, string animationName, float fDelta, bool loop, bool lockX, bool lockY, bool freeze, TimeSpan time, PlayerAnimationSyncType syncType = PlayerAnimationSyncType.NoSync)

Parameters

animationLibrary string

The name of the animation library.

animationName string

The name of the animation within the library.

fDelta float

The animation speed (typically 4.1).

loop bool

true to loop the animation; false to play it once.

lockX bool

If false, the player returns to their original X position after the animation completes (for moving animations). If true, the opposite occurs.

lockY bool

If false, the player returns to their original Y position after the animation completes (for moving animations). If true, the opposite occurs.

freeze bool

true to freeze the player in position after the animation finishes.

time TimeSpan

The animation duration. Use Zero for an infinite loop.

syncType PlayerAnimationSyncType

The synchronization type to apply to the animation. NoSync (default) - No synchronization; the player animates themselves. Sync - Forces the server to sync the animation with all other players in streaming radius. Useful when the player cannot sync the animation themselves (for example, if they are paused). SyncOthers - Same as Sync, but will ONLY apply the animation to streamed-in players, NOT the actual player being animated. Useful for NPC animations and persistent animations when players are being streamed.

AttachCameraToObject(GlobalObject)

Attaches this player's camera to a GlobalObject.

public virtual void AttachCameraToObject(GlobalObject @object)

Parameters

object GlobalObject

The GlobalObject to attach the camera to.

AttachCameraToObject(PlayerObject)

Attaches this player's camera to a PlayerObject.

public virtual void AttachCameraToObject(PlayerObject @object)

Parameters

object PlayerObject

The PlayerObject to attach the camera to.

Ban()

Bans this player. The ban is IP-based and saved in the samp.ban file in the server's root directory.

public virtual void Ban()

Ban(string)

Bans this player with a reason. The ban is IP-based and saved in the samp.ban file.

public virtual void Ban(string reason)

Parameters

reason string

The reason for the ban.

CancelEdit()

Cancels object editing mode for this player.

public virtual void CancelEdit()

CancelSelectTextDraw()

Cancels text draw selection mode for this player.

public virtual void CancelSelectTextDraw()

ClearAnimations(PlayerAnimationSyncType)

Clears all animations for this player.

public virtual void ClearAnimations(PlayerAnimationSyncType syncType = PlayerAnimationSyncType.NoSync)

Parameters

syncType PlayerAnimationSyncType

The synchronization type to apply to the animation. NoSync (default) - No synchronization; the player animates themselves. Sync - Forces the server to sync the animation with all other players in streaming radius. Useful when the player cannot sync the animation themselves (for example, if they are paused). SyncOthers - Same as Sync, but will ONLY apply the animation to streamed-in players, NOT the actual player being animated. Useful for NPC animations and persistent animations when players are being streamed.

ClearAnimations(bool)

Clears all animations for this player.

[Obsolete("Use ClearAnimations(PlayerAnimationSyncType) instead")]
public virtual void ClearAnimations(bool forceSync)

Parameters

forceSync bool

Specifies whether the animation should be shown to streamed in players.

ClearTasks(PlayerAnimationSyncType)

Clears all tasks for this player.

public virtual void ClearTasks(PlayerAnimationSyncType syncType)

Parameters

syncType PlayerAnimationSyncType

The synchronization type to apply to the animation. NoSync (default) - No synchronization; the player animates themselves. Sync - Forces the server to sync the animation with all other players in streaming radius. Useful when the player cannot sync the animation themselves (for example, if they are paused). SyncOthers - Same as Sync, but will ONLY apply the animation to streamed-in players, NOT the actual player being animated. Useful for NPC animations and persistent animations when players are being streamed.

Remarks

This is lower-level function related to animation clearing. Generally you should use ClearAnimations(PlayerAnimationSyncType) instead.

CreateExplosion(Vector3, ExplosionType, float)

Creates an explosion for this player. Only this player sees and is affected by the explosion.

public virtual void CreateExplosion(Vector3 position, ExplosionType type, float radius)

Parameters

position Vector3

The explosion position as a Vector3.

type ExplosionType

The ExplosionType.

radius float

The explosion radius.

Remarks

This is useful for isolating explosions to specific players or limiting them to specific virtual worlds.

DisableCheckpoint()

Disables the current checkpoint for this player.

public virtual void DisableCheckpoint()

DisableRaceCheckpoint()

Disables the current race checkpoint for this player.

public virtual void DisableRaceCheckpoint()

DisableRemoteVehicleCollisions(bool)

Disables or enables Vehicle collisions for this player.

public virtual void DisableRemoteVehicleCollisions(bool disable)

Parameters

disable bool

If true, Vehicle collisions are disabled; if false, they are enabled.

DoEditAttachedObject(int)

Enables edit mode for an attached object.

public virtual bool DoEditAttachedObject(int index)

Parameters

index int

The attachment slot index to edit.

Returns

bool

true on success; otherwise, false.

Edit(GlobalObject)

Enables edit mode for a GlobalObject so this player can modify it.

public virtual void Edit(GlobalObject @object)

Parameters

object GlobalObject

The GlobalObject to edit.

Edit(PlayerObject)

Enables edit mode for a PlayerObject so this player can modify it.

public virtual void Edit(PlayerObject @object)

Parameters

object PlayerObject

The PlayerObject to edit.

EnablePlayerCameraTarget(bool)

Enables or disables camera targeting functionality for this player.

public virtual void EnablePlayerCameraTarget(bool enable)

Parameters

enable bool

If true, the functionality is enabled; if false, it is disabled.

EnableStuntBonus(bool)

Enables or disables stunt bonuses for this player.

public virtual void EnableStuntBonus(bool enable)

Parameters

enable bool

true to enable stunt bonuses; false to disable them.

ForceClassSelection()

Forces this player to go back to class selection.

public virtual void ForceClassSelection()

Remarks

The player will not return to class selection until they re-spawn. This can be achieved with ToggleSpectating(bool)

GameText(string, int, int)

Shows 'game text' (on-screen text) for a certain length of time for this player.

[Obsolete("Obsolete. Use GameText(string,TimeSpan,GameTextStyle) instead.")]
public virtual void GameText(string text, int time, int style)

Parameters

text string

The text to be displayed.

time int

The duration of the text being shown in milliseconds.

style int

The style of text to be displayed.

GameText(string, TimeSpan, GameTextStyle)

Displays on-screen text (game text) for a specified duration.

public virtual void GameText(string text, TimeSpan time, GameTextStyle style)

Parameters

text string

The text to display.

time TimeSpan

The display duration as a TimeSpan.

style GameTextStyle

The text style.

GetAnimationName(out string?, out string?)

Gets the library and name of the animation this player is currently playing.

public virtual bool GetAnimationName(out string? animationLibrary, out string? animationName)

Parameters

animationLibrary string

The animation library name, passed by reference.

animationName string

The animation name, passed by reference.

Returns

bool

true on success; otherwise, false.

GetDistanceFromPoint(Vector3)

Calculates the distance between this player and a specified point.

public virtual float GetDistanceFromPoint(Vector3 point)

Parameters

point Vector3

The point to calculate the distance from as a Vector3.

Returns

float

The distance between this player and the point.

GetGameText(int, out string?, out TimeSpan, out TimeSpan)

Retrieves the currently displayed game text for this player in the specified style/slot.

public virtual bool GetGameText(int style, out string? message, out TimeSpan time, out TimeSpan remaining)

Parameters

style int

The style/slot of the game text to retrieve.

message string

When this method returns, contains the message text, or null if no game text is shown.

time TimeSpan

When this method returns, contains the duration the text was scheduled to display.

remaining TimeSpan

When this method returns, contains the remaining display time.

Returns

bool

true if game text is currently shown; otherwise false.

GetKeys(out Keys, out int, out int)

Retrieves the keys this player is currently pressing.

public virtual void GetKeys(out Keys keys, out int upDown, out int leftRight)

Parameters

keys Keys

The keys this player is pressing, passed by reference.

upDown int

The up/down direction value, passed by reference.

leftRight int

The left/right direction value, passed by reference.

Remarks

Only the function of keys can be detected, not the actual physical keys. For example, you cannot detect if the player presses space, but you can detect if they press sprint (which can be mapped to any key, defaulting to space).

GetLastShot(out Vector3, out Vector3)

Gets the start and end (hit) position of the last bullet this player fired.

public virtual void GetLastShot(out Vector3 origin, out Vector3 hitPosition)

Parameters

origin Vector3

The bullet origin position as a Vector3, passed by reference.

hitPosition Vector3

The bullet hit position as a Vector3, passed by reference.

GetNetworkStats()

Gets the network statistics for this player.

public NetworkStats GetNetworkStats()

Returns

NetworkStats

A NetworkStats object containing the player's network statistics.

GetSpawnInfo()

Retrieves the spawn information for the player based on the current class data.

public virtual PlayerSpawnData GetSpawnInfo()

Returns

PlayerSpawnData

A PlayerSpawnData instance containing the player's spawn position, orientation, and related data.

GetTime(out int, out int)

Gets the current game time for this player.

public virtual void GetTime(out int hour, out int minutes)

Parameters

hour int

The current hour, passed by reference.

minutes int

The current minutes, passed by reference.

Remarks

The time is set by SetWorldTime(int) or can be overridden per-player with SetTime(int, int).

GetWeaponData(int, out Weapon, out int)

Gets the Weapon and ammunition in this player's weapon slot.

public virtual void GetWeaponData(int slot, out Weapon weapon, out int ammo)

Parameters

slot int

The weapon slot index (0-12).

weapon Weapon

The Weapon in the slot, passed by reference.

ammo int

The ammunition in the slot, passed by reference.

GiveMoney(int)

Gives money to this player.

public virtual void GiveMoney(int money)

Parameters

money int

The amount of money to give. Use a negative value to take money.

GiveWeapon(Weapon, int)

Gives this player a weapon with a specified amount of ammunition.

public virtual void GiveWeapon(Weapon weapon, int ammo)

Parameters

weapon Weapon

The weapon to give to this player.

ammo int

The amount of ammunition to give with the weapon.

HasGameText(int)

Gets a value indicating whether the game text in the specified style/slot is currently displayed for this player.

public virtual bool HasGameText(int style)

Parameters

style int

The style/slot of the game text to check.

Returns

bool

true if game text is displayed; otherwise false.

HideGameText(int)

Hides the game text in the specified style/slot for this player.

public virtual void HideGameText(int style)

Parameters

style int

The style/slot of the game text to hide.

InterpolateCameraLookAt(Vector3, Vector3, int, CameraCut)

Interpolates this player's camera's look-at point between two positions over a specified duration.

[Obsolete("Use the TimeSpan overload. This int-milliseconds variant is kept for source compatibility and will be removed.")]
public virtual void InterpolateCameraLookAt(Vector3 from, Vector3 to, int time, CameraCut cut)

Parameters

from Vector3

The starting look-at position.

to Vector3

The ending look-at position.

time int

The interpolation duration as a TimeSpan.

cut CameraCut

The CameraCut transition style. Set to Move for smooth interpolation.

InterpolateCameraLookAt(Vector3, Vector3, TimeSpan, CameraCut)

Interpolates this player's camera's look-at point between two positions over a specified duration.

public virtual void InterpolateCameraLookAt(Vector3 from, Vector3 to, TimeSpan time, CameraCut cut)

Parameters

from Vector3

The starting look-at position.

to Vector3

The ending look-at position.

time TimeSpan

The interpolation duration as a TimeSpan.

cut CameraCut

The CameraCut transition style. Set to Move for smooth interpolation.

InterpolateCameraPosition(Vector3, Vector3, int, CameraCut)

Interpolates this player's camera position between two points over a specified duration.

[Obsolete("Use the TimeSpan overload. This int-milliseconds variant is kept for source compatibility and will be removed.")]
public virtual void InterpolateCameraPosition(Vector3 from, Vector3 to, int time, CameraCut cut)

Parameters

from Vector3

The starting position.

to Vector3

The ending position.

time int

The interpolation duration as a TimeSpan.

cut CameraCut

The CameraCut transition style. Set to Move for smooth movement.

InterpolateCameraPosition(Vector3, Vector3, TimeSpan, CameraCut)

Interpolates this player's camera position between two points over a specified duration.

public virtual void InterpolateCameraPosition(Vector3 from, Vector3 to, TimeSpan time, CameraCut cut)

Parameters

from Vector3

The starting position.

to Vector3

The ending position.

time TimeSpan

The interpolation duration as a TimeSpan.

cut CameraCut

The CameraCut transition style. Set to Move for smooth movement.

IsAttachedObjectSlotUsed(int)

Determines whether this player has an object attached in the specified index.

public virtual bool IsAttachedObjectSlotUsed(int index)

Parameters

index int

The attachment slot index to check.

Returns

bool

true if the slot is occupied; otherwise, false.

IsInRangeOfPoint(float, Vector3)

Determines whether this player is in range of a specified point.

public virtual bool IsInRangeOfPoint(float range, Vector3 point)

Parameters

range float

The maximum distance this player can be from the point to be in range.

point Vector3

The point to check the range to.

Returns

bool

true if this player is in range of the point; otherwise, false.

IsInVehicle(Vehicle)

Determines whether this player is in a specific Vehicle.

public virtual bool IsInVehicle(Vehicle vehicle)

Parameters

vehicle Vehicle

The Vehicle to check.

Returns

bool

true if the player is in the vehicle; otherwise, false.

IsPlayerStreamedIn(Player)

Determines whether the specified player is streamed in on this player's client.

public virtual bool IsPlayerStreamedIn(Player player)

Parameters

player Player

The Player to check.

Returns

bool

true if the specified player is streamed in for this player; otherwise, false.

Remarks

Players are not streamed in on their own client. If this player is the same as the player, this method returns false. Players stream out if they are more than 150 meters away (configurable via server.cfg stream_distance).

Kick()

Kicks this player from the server.

public virtual void Kick()

OnDestroyComponent()

This method is invoked before this component is destroyed and removed from its entity.

protected override void OnDestroyComponent()

PlayAudioStream(string)

Plays an audio stream for this player. Standard audio files (such as MP3) are also supported.

public virtual void PlayAudioStream(string url)

Parameters

url string

The URL to stream. Valid formats are MP3 and OGG/Vorbis. A link to a .pls file will play that playlist.

PlayAudioStream(string, Vector3, float)

Plays an audio stream for this player. Standard audio files (such as MP3) are also supported.

public virtual void PlayAudioStream(string url, Vector3 position, float distance)

Parameters

url string

The URL to stream. Valid formats are MP3 and OGG/Vorbis. A link to a .pls file will play that playlist.

position Vector3

The position from which the audio should be heard as a Vector3.

distance float

The distance over which the audio will be audible.

PlayCrimeReport(Player, int)

Plays a crime report for this player with the specified suspect and crime, similar to single-player when committing a crime.

public virtual bool PlayCrimeReport(Player suspect, int crime)

Parameters

suspect Player

The suspect Player to be described in the report.

crime int

The crime ID, which will be reported as a 10-code (e.g., 10-16 for crime ID 16).

Returns

bool

true if the suspect is in a state for which a crime report could be played; otherwise false.

PlaySound(int)

Plays the specified soundId for this player.

public virtual void PlaySound(int soundId)

Parameters

soundId int

The sound to play.

PlaySound(int, Vector3)

Plays the specified soundId for this player at a specific point.

public virtual void PlaySound(int soundId, Vector3 point)

Parameters

soundId int

The sound to play.

point Vector3

Point for the sound to play at as a Vector3.

PutCameraBehindPlayer()

Restores the camera to the default position behind the player after manual camera positioning.

public virtual void PutCameraBehindPlayer()

PutInVehicle(Vehicle)

Puts this player in a Vehicle as driver.

public virtual void PutInVehicle(Vehicle vehicle)

Parameters

vehicle Vehicle

The Vehicle to put the player in.

PutInVehicle(Vehicle, int)

Puts this player in a vehicle as a Vehicle.

public virtual void PutInVehicle(Vehicle vehicle, int seatId)

Parameters

vehicle Vehicle

The Vehicle to put the player in.

seatId int

The seat index (0 = driver).

RemoveAttachedObject(int)

Removes an attached object from this player.

public virtual bool RemoveAttachedObject(int index)

Parameters

index int

The attachment slot index (set via SetAttachedObject(int, int, Bone, Vector3, Vector3, Vector3, Color, Color)).

Returns

bool

true on success; otherwise, false.

RemoveBuilding(int, Vector3, float)

Removes a standard San Andreas model for this player within a specified range.

[Obsolete("Deprecated. Use 'RemoveDefaultObjects' instead.")]
public virtual void RemoveBuilding(int modelId, Vector3 position, float radius)

Parameters

modelId int

The model identifier.

position Vector3

The position at which to remove the model.

radius float

The radius in which to remove the model.

RemoveDefaultObjects(int, Vector3, float)

Removes a standard San Andreas model for this player within a specified range.

public virtual void RemoveDefaultObjects(int modelId, Vector3 position, float radius)

Parameters

modelId int

The model ID to remove.

position Vector3

The center position where the model should be removed as a Vector3.

radius float

The removal radius.

RemoveFromVehicle(bool)

Removes/ejects this player from their Vehicle.

public virtual void RemoveFromVehicle(bool force = false)

Parameters

force bool

Force the removal of the player when set to true.

Remarks

The exiting animation is not synced for other players. This function will not work when used in the OnPlayerEnterVehicle event, because the player isn't in the vehicle when the callback is called. Use the OnPlayerStateChanged event instead.

RemoveMapIcon(int)

Removes a map icon that was previously set for this player.

public virtual void RemoveMapIcon(int iconId)

Parameters

iconId int

The icon ID to remove.

RemoveWeapon(Weapon)

Removes a single weapon from this player.

public virtual void RemoveWeapon(Weapon weapon)

Parameters

weapon Weapon

The weapon to remove.

ResetMoney()

Resets this player's money to zero.

public virtual void ResetMoney()

ResetWeapons()

Removes all weapons from this player.

public virtual void ResetWeapons()

Select()

Enables object selection mode for this player.

public virtual void Select()

SelectTextDraw(Color)

Displays the text draw selection cursor and enables this player to select a text draw.

public virtual void SelectTextDraw(Color hoverColor)

Parameters

hoverColor Color

The Color to display when hovering over a text draw.

SendClientMessage(Color, string)

Sends a message to this player in the chat with a specified Color.

public virtual void SendClientMessage(Color color, string message)

Parameters

color Color

The message Color.

message string

The message text.

Remarks

The entire message will be displayed in the specified color unless color embedding is used. Messages longer than 144 characters are automatically split.

SendClientMessage(Color, string, params object[])

Sends a formatted message to this player in the chat with a specified Color.

public virtual void SendClientMessage(Color color, string messageFormat, params object[] args)

Parameters

color Color

The message Color.

messageFormat string

The composite format string (max 144 characters).

args object[]

The objects to format.

Remarks

The entire message will be displayed in the specified color unless color embedding is used. Messages longer than 144 characters are automatically split.

SendClientMessage(string)

Sends a message to this player in the chat in white.

public virtual void SendClientMessage(string message)

Parameters

message string

The message text.

Remarks

Messages longer than 144 characters are automatically split. Color embedding can be used to add colored text.

SendClientMessage(string, params object[])

Sends a formatted message to this player in the chat in white.

public virtual void SendClientMessage(string messageFormat, params object[] args)

Parameters

messageFormat string

The composite format string (max 144 characters).

args object[]

The objects to format.

Remarks

Messages longer than 144 characters are automatically split. Color embedding can be used to add colored text.

SendCommand(string)

Sends a command on behalf of this player as if they had typed it themselves.

public virtual void SendCommand(string message)

Parameters

message string

The command line, including the leading slash.

SendDeathMessage(Player, Player, Weapon)

Adds a death message to the kill feed on the right side of the screen.

public virtual void SendDeathMessage(Player killer, Player player, Weapon weapon)

Parameters

killer Player

The Player who caused the death.

player Player

The Player who was killed.

weapon Weapon

The Weapon used.

SendDownloadUrl(string)

Sends a download URL to this player for resolving custom model assets.

public virtual void SendDownloadUrl(string url)

Parameters

url string

The URL.

SendPlayerMessageToPlayer(Player, string)

Sends a message in the name of another Player to this player.

public virtual void SendPlayerMessageToPlayer(Player sender, string message)

Parameters

sender Player

The Player sending the message.

message string

The message text.

Remarks

The message appears in the chat box and can only be seen by this player. It starts with the sender's name in their Color, followed by the message in white.

SetAmmo(Weapon, int)

Sets the ammunition for this player's weapon.

public virtual void SetAmmo(Weapon weapon, int ammo)

Parameters

weapon Weapon

The weapon to set ammunition for.

ammo int

The amount of ammunition to set.

SetArmedWeapon(Weapon)

Sets the armed weapon of this player.

public virtual void SetArmedWeapon(Weapon weapon)

Parameters

weapon Weapon

The weapon that the player should be armed with.

SetAttachedObject(int, int, Bone, Vector3, Vector3, Vector3, Color, Color)

Attaches an object to a specific bone on this player.

public virtual bool SetAttachedObject(int index, int modelId, Bone bone, Vector3 offset, Vector3 rotation, Vector3 scale, Color materialColor1, Color materialColor2)

Parameters

index int

The attachment slot index (0-9).

modelId int

The model ID of the object to attach.

bone Bone

The bone to attach the object to.

offset Vector3

The offset of the object from the bone as a Vector3.

rotation Vector3

The rotation of the attached object as a Vector3.

scale Vector3

The scale of the attached object as a Vector3.

materialColor1 Color

The primary object Color.

materialColor2 Color

The secondary object Color.

Returns

bool

true on success; otherwise, false.

SetCameraLookAt(Vector3)

Sets the direction this player's camera looks at. Use in combination with CameraPosition.

public virtual void SetCameraLookAt(Vector3 point)

Parameters

point Vector3

The point the camera should look at.

SetCameraLookAt(Vector3, CameraCut)

Sets the direction this player's camera looks at. Use in combination with CameraPosition.

public virtual void SetCameraLookAt(Vector3 point, CameraCut cut)

Parameters

point Vector3

The point the camera should look at.

cut CameraCut

The CameraCut transition style.

SetChatBubble(string, Color, float, int)

Creates a chat bubble above this player's name tag.

[Obsolete("Use SetChatBubble(string,Color,float,TimeSpan) instead")]
public virtual void SetChatBubble(string text, Color color, float drawDistance, int expireTime)

Parameters

text string

The text to display.

color Color

The text color.

drawDistance float

The distance from where players are able to see the chat bubble.

expireTime int

The time in milliseconds the bubble should be displayed for.

SetChatBubble(string, Color, float, TimeSpan)

Creates a chat bubble above this player's name tag.

public virtual void SetChatBubble(string text, Color color, float drawDistance, TimeSpan expireTime)

Parameters

text string

The text to display.

color Color

The text color.

drawDistance float

The distance from where players are able to see the chat bubble.

expireTime TimeSpan

The time the bubble should be displayed for.

SetCheckpoint(Vector3, float)

Sets a checkpoint (red circle) for this player and displays a red blip on the radar.

public virtual void SetCheckpoint(Vector3 point, float size)

Parameters

point Vector3

The checkpoint position as a Vector3.

size float

The checkpoint radius.

Remarks

Checkpoints created on server-created objects will appear on the ground but will still function correctly. There is no workaround for this issue.

SetConsoleAccessibility(bool)

Grants or revokes RCON (console) access for this player at runtime.

public virtual void SetConsoleAccessibility(bool enable)

Parameters

enable bool

true to grant access; false to revoke.

SetMapIcon(int, Vector3, MapIcon, Color, MapIconType)

Places an icon/marker on this player's map.

public virtual void SetMapIcon(int iconId, Vector3 position, MapIcon type, Color color, MapIconType style)

Parameters

iconId int

The icon ID for this player (0-99). Maximum 100 icons per Player.

position Vector3

The icon position as a Vector3.

type MapIcon

The MapIcon type.

color Color

The marker Color.

style MapIconType

The MapIconType style.

Remarks

This can be used to mark locations such as banks and hospitals.

SetName(string)

Sets the name of this player.

public virtual void SetName(string name)

Parameters

name string

The new player name.

Exceptions

InvalidPlayerNameException

Thrown if the name is invalid or already in use.

SetPlayerMarker(Player, Color)

Changes the color of the specified player's name tag and radar blip for this player.

public virtual void SetPlayerMarker(Player player, Color color)

Parameters

player Player

The Player whose marker color will be changed.

color Color

The new marker Color.

SetPositionFindZ(Vector3)

Sets this player's position and adjusts the Z-coordinate to the nearest solid ground beneath the position.

public virtual void SetPositionFindZ(Vector3 position)

Parameters

position Vector3

The position to move this player to as a Vector3.

SetRaceCheckpoint(CheckpointType, Vector3, Vector3, float)

Sets a race checkpoint for this player. The OnPlayerEnterCheckpoint is triggered when the player enters.

public virtual void SetRaceCheckpoint(CheckpointType type, Vector3 point, Vector3 nextPosition, float size)

Parameters

type CheckpointType

The CheckpointType.

point Vector3

The checkpoint position as a Vector3.

nextPosition Vector3

The position of the next checkpoint as a Vector3, used for arrow direction.

size float

The checkpoint radius (diameter).

SetShopName(string)

Loads or unloads an interior script for this player (for example, the Ammunation shop menu).

public virtual void SetShopName(string shopName)

Parameters

shopName string

The name of the shop. See ShopName for available shop names.

SetSkillLevel(WeaponSkill, int)

Sets the skill level of a specific Weapon for this player.

public virtual void SetSkillLevel(WeaponSkill skill, int level)

Parameters

skill WeaponSkill

The WeaponSkill to set.

level int

The skill level (0-999). Values outside this range will be clamped.

Remarks

The skill parameter is a weapon skill type, not a weapon ID.

SetSpawnInfo(PlayerSpawnData)

Sets the spawn information for the player using the specified spawn data.

public virtual void SetSpawnInfo(PlayerSpawnData spawnData)

Parameters

spawnData PlayerSpawnData

The spawn data that defines the player's initial position, orientation, and other spawn-related settings.

SetSpawnInfo(int, int, Vector3, float, Weapon, int, Weapon, int, Weapon, int)

Configures spawn information for this player, including team, skin, position, and weapons.

public virtual void SetSpawnInfo(int team, int skin, Vector3 position, float rotation, Weapon weapon1 = Weapon.None, int weapon1Ammo = 0, Weapon weapon2 = Weapon.None, int weapon2Ammo = 0, Weapon weapon3 = Weapon.None, int weapon3Ammo = 0)

Parameters

team int

The team ID for this player.

skin int

The skin this player will spawn with.

position Vector3

The spawn position as a Vector3.

rotation float

The facing direction after spawning.

weapon1 Weapon

The first spawn Weapon.

weapon1Ammo int

The ammunition for the first weapon1.

weapon2 Weapon

The second spawn Weapon.

weapon2Ammo int

The ammunition for the second weapon2.

weapon3 Weapon

The third spawn Weapon.

weapon3Ammo int

The ammunition for the third weapon3.

SetTime(int, int)

Sets the game clock for this player to a specific time. This also changes the daytime visuals.

public virtual void SetTime(int hour, int minutes)

Parameters

hour int

The hour to set (0-23).

minutes int

The minutes to set (0-59).

SetWeather(int)

Sets the weather for this player. If the clock is enabled, weather changes will interpolate gradually; otherwise they change instantly.

[Obsolete("Use Weather property instead.")]
public virtual void SetWeather(int weather)

Parameters

weather int

The weather ID to set.

SetWorldBounds(float, float, float, float)

Sets the world boundaries for this player. The player cannot travel outside these boundaries.

[Obsolete("Use WorldBounds property instead. Pass values as Vector4(xMax, xMin, yMax, yMin).")]
public virtual void SetWorldBounds(float xMax, float xMin, float yMax, float yMin)

Parameters

xMax float

The maximum X coordinate.

xMin float

The minimum X coordinate.

yMax float

The maximum Y coordinate.

yMin float

The minimum Y coordinate.

Remarks

To reset to default boundaries, set all parameters to their default values: xMax=20000, xMin=-20000, yMax=20000, yMin=-20000.

SetWorldTime(TimeSpan)

Sets the in-game world time (hours-only resolution on the native side) for this player.

public virtual void SetWorldTime(TimeSpan time)

Parameters

time TimeSpan

The world time to set; only the whole-hour portion is applied.

ShowNameTagForPlayer(Player, bool)

Shows or hides the name tag, health bar, and armor bar for another Player.

public virtual void ShowNameTagForPlayer(Player player, bool show)

Parameters

player Player

The Player whose name tag will be shown or hidden.

show bool

true to show the name tag; false to hide it.

Remarks

ShowNameTags(bool) must be enabled for name tags to be visible with this method.

Spawn()

(Re)Spawns a player.

public virtual void Spawn()

SpectatePlayer(Player)

Makes this player spectate another Player.

public virtual void SpectatePlayer(Player targetPlayer)

Parameters

targetPlayer Player

The Player to spectate.

Remarks

Call ToggleSpectating(bool) before using this method.

SpectatePlayer(Player, SpectateMode)

Makes this player spectate another Player.

public virtual void SpectatePlayer(Player targetPlayer, SpectateMode mode)

Parameters

targetPlayer Player

The Player to spectate.

mode SpectateMode

The SpectateMode to use.

Remarks

Call ToggleSpectating(bool) before using this method.

SpectateVehicle(Vehicle)

Makes this player spectate a Vehicle (see what its driver sees).

public virtual void SpectateVehicle(Vehicle targetVehicle)

Parameters

targetVehicle Vehicle

The Vehicle to spectate.

Remarks

Call ToggleSpectating(bool) before using this method.

SpectateVehicle(Vehicle, SpectateMode)

Makes this player spectate a Vehicle (see what its driver sees).

public virtual void SpectateVehicle(Vehicle targetVehicle, SpectateMode mode)

Parameters

targetVehicle Vehicle

The Vehicle to spectate.

mode SpectateMode

The SpectateMode to use.

Remarks

Call ToggleSpectating(bool) before using this method.

StartRecordingPlayerData(PlayerRecordingType, string)

Starts recording this player's movements to a file, which can be reproduced by an NPC.

public virtual void StartRecordingPlayerData(PlayerRecordingType recordingType, string recordingName)

Parameters

recordingType PlayerRecordingType

The PlayerRecordingType.

recordingName string

The name of the file to save the recording to. The file will be saved in the scriptfiles folder with a .rec extension added automatically.

StopAudioStream()

Stops the current audio stream for this player.

public virtual void StopAudioStream()

StopRecordingPlayerData()

Stops all player data recordings for this player.

public virtual void StopRecordingPlayerData()

StreamInForPlayer(Player)

Forces this player to be streamed in for the specified target player.

public virtual void StreamInForPlayer(Player target)

Parameters

target Player

The player for whom this player should be streamed in.

StreamOutForPlayer(Player)

Forces this player to be streamed out for the specified target player.

public virtual void StreamOutForPlayer(Player target)

Parameters

target Player

The player for whom this player should be streamed out.

ToString()

public override string ToString()

Returns

string

ToggleClock(bool)

Toggles the visibility of the in-game clock (top right corner) for this player.

public virtual void ToggleClock(bool toggle)

Parameters

toggle bool

true to show the clock; false to hide it.

Remarks

Time is not synced with other players.

ToggleControllable(bool)

Freezes or unfreezes this player, preventing or allowing player control.

public virtual void ToggleControllable(bool toggle)

Parameters

toggle bool

true to unfreeze the player; false to freeze them.

ToggleSpectating(bool)

Toggles spectating mode for this player.

public virtual void ToggleSpectating(bool toggle)

Parameters

toggle bool

true to enable spectating; false to disable.

Remarks

When spectating is disabled, the OnPlayerSpawn event is automatically triggered.

Operators

implicit operator IPlayer(Player?)

Performs an implicit conversion from Player to IPlayer.

public static implicit operator IPlayer(Player? player)

Parameters

player Player

Returns

IPlayer