Class Player
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
entityProviderIOmpEntityProviderplayerIPlayer
Properties
Angle
Gets or sets the facing angle of this player.
public virtual float Angle { get; set; }
Property Value
AnimationIndex
Gets the animation index of the animation this player is currently playing.
public virtual int AnimationIndex { get; }
Property Value
AreWeaponsAllowed
Gets or sets a value indicating whether this player is allowed to use weapons.
public virtual bool AreWeaponsAllowed { get; set; }
Property Value
Armour
Gets or sets the armor of this player.
public virtual float Armour { get; set; }
Property Value
AspectCameraRatio
Gets the aspect ratio of this player's camera.
public virtual float AspectCameraRatio { get; }
Property Value
BytesReceived
Gets the number of bytes received from this player.
public virtual int BytesReceived { get; }
Property Value
BytesSent
Gets the number of bytes sent to this player.
public virtual int BytesSent { get; }
Property Value
CameraFrontVector
Gets the front Vector3 of this player's camera.
public virtual Vector3 CameraFrontVector { get; }
Property Value
CameraMode
Gets the CameraMode of this player's camera.
public virtual CameraMode CameraMode { get; }
Property Value
CameraPosition
Gets or sets the position of the camera of this player as a Vector3.
public virtual Vector3 CameraPosition { get; set; }
Property Value
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
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
CameraTargetGlobalObject
Gets the GlobalObject the camera of this player is pointing at.
public virtual GlobalObject? CameraTargetGlobalObject { get; }
Property Value
CameraTargetPlayer
Gets the Player the camera of this player is pointing at.
public virtual Player? CameraTargetPlayer { get; }
Property Value
CameraTargetPlayerObject
Gets the PlayerObject the camera of this player is pointing at.
public virtual PlayerObject? CameraTargetPlayerObject { get; }
Property Value
CameraTargetVehicle
Gets the Vehicle the camera of this player is pointing at.
public virtual Vehicle? CameraTargetVehicle { get; }
Property Value
CameraZoom
Gets the game camera zoom level for this player.
public virtual float CameraZoom { get; }
Property Value
ClientVersion
Gets this player's ClientVersion.
public virtual ClientVersion ClientVersion { get; }
Property Value
ClientVersionName
Gets this player's client version name.
public virtual string ClientVersionName { get; }
Property Value
Color
Gets or sets the Color of this player.
public virtual Color Color { get; set; }
Property Value
ConnectedTime
Gets the TimeSpan this player has been connected to the server.
public virtual TimeSpan ConnectedTime { get; }
Property Value
ConnectionStatus
Gets the ConnectionStatus of this player.
public virtual ConnectionStatus ConnectionStatus { get; }
Property Value
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
DrunkLevel
Gets or sets the drunkenness level of this player.
public virtual int DrunkLevel { get; set; }
Property Value
EndPoint
Gets the end point (IPAddress and port) of this player.
public virtual IPEndPoint EndPoint { get; }
Property Value
FightStyle
Gets or sets the FightStyle of this player.
public virtual FightStyle FightStyle { get; set; }
Property Value
Gpci
Gets this player's global computer identifier string.
public virtual string Gpci { get; }
Property Value
Gravity
Gets or sets this player's gravity.
public virtual float Gravity { get; set; }
Property Value
HasWidescreen
Gets or sets a value indicating whether widescreen mode is enabled for this player.
public virtual bool HasWidescreen { get; set; }
Property Value
Health
Gets or sets the health of this player.
public virtual float Health { get; set; }
Property Value
InAnyVehicle
Gets a value indicating whether this player is currently in any vehicle.
public virtual bool InAnyVehicle { get; }
Property Value
InCheckpoint
Gets a value indicating whether this player is in a checkpoint.
public virtual bool InCheckpoint { get; }
Property Value
InRaceCheckpoint
Gets a value indicating whether this player is in a race checkpoint.
public virtual bool InRaceCheckpoint { get; }
Property Value
Interior
Gets or sets the interior of this player.
public virtual int Interior { get; set; }
Property Value
Ip
Gets the IP of this player as a string.
public virtual string Ip { get; }
Property Value
IpAddress
Gets the IPAddress of this player.
public virtual IPAddress IpAddress { get; }
Property Value
IsAdmin
Gets a value indicating whether this player is logged into RCON.
public virtual bool IsAdmin { get; }
Property Value
IsAlive
Gets a value indicating whether this player is alive.
public virtual bool IsAlive { get; }
Property Value
IsBeingKicked
Gets a value indicating whether this player is in the process of being kicked.
public virtual bool IsBeingKicked { get; }
Property Value
IsGhostModeEnabled
Gets or sets a value indicating whether ghost mode is enabled for this player.
public virtual bool IsGhostModeEnabled { get; set; }
Property Value
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
IsOmpEntityDestroyed
Gets a value indicating whether the open.mp entity counterpart has been destroyed.
protected bool IsOmpEntityDestroyed { get; }
Property Value
IsSelectingTextDraw
Gets a value indicating whether this player is selecting a text draw.
public virtual bool IsSelectingTextDraw { get; }
Property Value
IsTeleportAllowed
Gets or sets a value indicating whether map-click teleporting is allowed for this player.
public virtual bool IsTeleportAllowed { get; set; }
Property Value
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
IsUsingOmp
Gets a value indicating whether this player is using the open.mp client.
public virtual bool IsUsingOmp { get; }
Property Value
Menu
Gets the Menu this player is currently in.
public virtual Menu? Menu { get; }
Property Value
MessagesReceived
Gets the number of messages received from this player.
public virtual int MessagesReceived { get; }
Property Value
MessagesReceivedPerSecond
Gets the number of messages received from this player per second.
public virtual int MessagesReceivedPerSecond { get; }
Property Value
MessagesSent
Gets the number of messages sent to this player.
public virtual int MessagesSent { get; }
Property Value
Money
Gets or sets the money of this player.
public virtual int Money { get; set; }
Property Value
Name
Gets or sets the name of this player.
public virtual string Name { get; set; }
Property Value
Ping
Gets the ping of this player.
public virtual int Ping { get; }
Property Value
Score
Gets or sets the score of this player.
public virtual int Score { get; set; }
Property Value
Skin
Gets or sets the skin of this player.
public virtual int Skin { get; set; }
Property Value
SpecialAction
Gets or sets the SpecialAction of this player.
public virtual SpecialAction SpecialAction { get; set; }
Property Value
State
Gets the PlayerState of this player.
public virtual PlayerState State { get; }
Property Value
StreamedForPlayers
Gets a lazy sequence of players for whom this player is currently streamed in.
public virtual IEnumerable<Player> StreamedForPlayers { get; }
Property Value
SurfingEntity
Gets the Component (object or vehicle) that this player is surfing.
public virtual Component? SurfingEntity { get; }
Property Value
TargetActor
Gets the Actor this player is aiming at.
public virtual Actor? TargetActor { get; }
Property Value
TargetPlayer
Gets the Player this player is aiming at.
public virtual Player? TargetPlayer { get; }
Property Value
Team
Gets or sets the team this player is in.
public virtual int Team { get; set; }
Property Value
Vehicle
Gets the Vehicle this player is currently in.
public virtual Vehicle? Vehicle { get; }
Property Value
VehicleSeat
Gets the vehicle seat this player is occupying.
public virtual int VehicleSeat { get; }
Property Value
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
WantedLevel
Gets or sets the wanted level of this player.
public virtual int WantedLevel { get; set; }
Property Value
Weapon
Gets the Weapon this player is currently holding.
public virtual Weapon Weapon { get; }
Property Value
WeaponAmmo
Gets the ammunition of the Weapon this player is currently holding.
public virtual int WeaponAmmo { get; }
Property Value
WeaponState
Gets the WeaponState of the Weapon this player is currently holding.
public virtual WeaponState WeaponState { get; }
Property Value
Weather
Gets or sets the current weather for this player.
public virtual int Weather { get; set; }
Property Value
WorldBounds
Gets or sets the world bounds for this player as (maxX, minX, maxY, minY).
public virtual Vector4 WorldBounds { get; set; }
Property Value
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
animationLibrarystringThe name of the animation library.
animationNamestringThe name of the animation within the library.
fDeltafloatThe animation speed (typically 4.1).
loopboollockXboolIf false, the player returns to their original X position after the animation completes (for moving animations). If true, the opposite occurs.
lockYboolIf false, the player returns to their original Y position after the animation completes (for moving animations). If true, the opposite occurs.
freezebooltrue to freeze the player in position after the animation finishes.
timeintThe 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
animationLibrarystringThe name of the animation library.
animationNamestringThe name of the animation within the library.
fDeltafloatThe animation speed (typically 4.1).
loopboollockXboolIf false, the player returns to their original X position after the animation completes (for moving animations). If true, the opposite occurs.
lockYboolIf false, the player returns to their original Y position after the animation completes (for moving animations). If true, the opposite occurs.
freezebooltrue to freeze the player in position after the animation finishes.
timeintThe animation duration. Use Zero for an infinite loop.
forceSyncbool
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
animationLibrarystringThe name of the animation library.
animationNamestringThe name of the animation within the library.
fDeltafloatThe animation speed (typically 4.1).
loopboollockXboolIf false, the player returns to their original X position after the animation completes (for moving animations). If true, the opposite occurs.
lockYboolIf false, the player returns to their original Y position after the animation completes (for moving animations). If true, the opposite occurs.
freezebooltrue to freeze the player in position after the animation finishes.
timeTimeSpanThe animation duration. Use Zero for an infinite loop.
syncTypePlayerAnimationSyncTypeThe 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
objectGlobalObjectThe GlobalObject to attach the camera to.
AttachCameraToObject(PlayerObject)
Attaches this player's camera to a PlayerObject.
public virtual void AttachCameraToObject(PlayerObject @object)
Parameters
objectPlayerObjectThe 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
reasonstringThe 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
syncTypePlayerAnimationSyncTypeThe 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
forceSyncboolSpecifies 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
syncTypePlayerAnimationSyncTypeThe 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
positionVector3The explosion position as a Vector3.
typeExplosionTypeThe ExplosionType.
radiusfloatThe 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
DoEditAttachedObject(int)
Enables edit mode for an attached object.
public virtual bool DoEditAttachedObject(int index)
Parameters
indexintThe attachment slot index to edit.
Returns
Edit(GlobalObject)
Enables edit mode for a GlobalObject so this player can modify it.
public virtual void Edit(GlobalObject @object)
Parameters
objectGlobalObjectThe GlobalObject to edit.
Edit(PlayerObject)
Enables edit mode for a PlayerObject so this player can modify it.
public virtual void Edit(PlayerObject @object)
Parameters
objectPlayerObjectThe PlayerObject to edit.
EnablePlayerCameraTarget(bool)
Enables or disables camera targeting functionality for this player.
public virtual void EnablePlayerCameraTarget(bool enable)
Parameters
EnableStuntBonus(bool)
Enables or disables stunt bonuses for this player.
public virtual void EnableStuntBonus(bool enable)
Parameters
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
textstringThe text to be displayed.
timeintThe duration of the text being shown in milliseconds.
styleintThe 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
textstringThe text to display.
timeTimeSpanThe display duration as a TimeSpan.
styleGameTextStyleThe 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
animationLibrarystringThe animation library name, passed by reference.
animationNamestringThe animation name, passed by reference.
Returns
GetDistanceFromPoint(Vector3)
Calculates the distance between this player and a specified point.
public virtual float GetDistanceFromPoint(Vector3 point)
Parameters
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
styleintThe style/slot of the game text to retrieve.
messagestringWhen this method returns, contains the message text, or null if no game text is shown.
timeTimeSpanWhen this method returns, contains the duration the text was scheduled to display.
remainingTimeSpanWhen this method returns, contains the remaining display time.
Returns
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
keysKeysThe keys this player is pressing, passed by reference.
upDownintThe up/down direction value, passed by reference.
leftRightintThe 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
originVector3The bullet origin position as a Vector3, passed by reference.
hitPositionVector3The 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
hourintThe current
hour, passed by reference.minutesintThe 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
slotintThe weapon slot index (0-12).
weaponWeaponThe Weapon in the slot, passed by reference.
ammointThe ammunition in the slot, passed by reference.
GiveMoney(int)
Gives money to this player.
public virtual void GiveMoney(int money)
Parameters
moneyintThe 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
weaponWeaponThe weapon to give to this player.
ammointThe 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
styleintThe style/slot of the game text to check.
Returns
HideGameText(int)
Hides the game text in the specified style/slot for this player.
public virtual void HideGameText(int style)
Parameters
styleintThe 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
fromVector3The starting look-at position.
toVector3The ending look-at position.
timeintThe interpolation duration as a TimeSpan.
cutCameraCutThe 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
fromVector3The starting look-at position.
toVector3The ending look-at position.
timeTimeSpanThe interpolation duration as a TimeSpan.
cutCameraCutThe 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
fromVector3The starting position.
toVector3The ending position.
timeintThe interpolation duration as a TimeSpan.
cutCameraCutThe 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
fromVector3The starting position.
toVector3The ending position.
timeTimeSpanThe interpolation duration as a TimeSpan.
cutCameraCutThe 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
indexintThe attachment slot index to check.
Returns
IsInRangeOfPoint(float, Vector3)
Determines whether this player is in range of a specified point.
public virtual bool IsInRangeOfPoint(float range, Vector3 point)
Parameters
rangefloatThe maximum distance this player can be from the point to be in range.
pointVector3The point to check the range to.
Returns
IsInVehicle(Vehicle)
Determines whether this player is in a specific Vehicle.
public virtual bool IsInVehicle(Vehicle vehicle)
Parameters
Returns
IsPlayerStreamedIn(Player)
Determines whether the specified player is streamed in on this player's client.
public virtual bool IsPlayerStreamedIn(Player player)
Parameters
Returns
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
urlstringThe 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
urlstringThe URL to stream. Valid formats are MP3 and OGG/Vorbis. A link to a .pls file will play that playlist.
positionVector3The position from which the audio should be heard as a Vector3.
distancefloatThe 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
suspectPlayerThe suspect Player to be described in the report.
crimeintThe crime ID, which will be reported as a 10-code (e.g., 10-16 for crime ID 16).
Returns
PlaySound(int)
Plays the specified soundId for this player.
public virtual void PlaySound(int soundId)
Parameters
soundIdintThe 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
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
PutInVehicle(Vehicle, int)
Puts this player in a vehicle as a Vehicle.
public virtual void PutInVehicle(Vehicle vehicle, int seatId)
Parameters
RemoveAttachedObject(int)
Removes an attached object from this player.
public virtual bool RemoveAttachedObject(int index)
Parameters
indexintThe attachment slot index (set via SetAttachedObject(int, int, Bone, Vector3, Vector3, Vector3, Color, Color)).
Returns
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
modelIdintThe model identifier.
positionVector3The position at which to remove the model.
radiusfloatThe 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
modelIdintThe model ID to remove.
positionVector3The center position where the model should be removed as a Vector3.
radiusfloatThe removal radius.
RemoveFromVehicle(bool)
Removes/ejects this player from their Vehicle.
public virtual void RemoveFromVehicle(bool force = false)
Parameters
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
iconIdintThe icon ID to remove.
RemoveWeapon(Weapon)
Removes a single weapon from this player.
public virtual void RemoveWeapon(Weapon weapon)
Parameters
weaponWeaponThe 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
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
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
colorColorThe message Color.
messageFormatstringThe composite format string (max 144 characters).
argsobject[]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
messagestringThe 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
messageFormatstringThe composite format string (max 144 characters).
argsobject[]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
messagestringThe 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
killerPlayerThe Player who caused the death.
playerPlayerThe Player who was killed.
weaponWeaponThe Weapon used.
SendDownloadUrl(string)
Sends a download URL to this player for resolving custom model assets.
public virtual void SendDownloadUrl(string url)
Parameters
urlstringThe 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
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
SetArmedWeapon(Weapon)
Sets the armed weapon of this player.
public virtual void SetArmedWeapon(Weapon weapon)
Parameters
weaponWeaponThe 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
indexintThe attachment slot index (0-9).
modelIdintThe model ID of the object to attach.
boneBoneThe bone to attach the object to.
offsetVector3The offset of the object from the
boneas a Vector3.rotationVector3The rotation of the attached object as a Vector3.
scaleVector3The scale of the attached object as a Vector3.
materialColor1ColorThe primary object Color.
materialColor2ColorThe secondary object Color.
Returns
SetCameraLookAt(Vector3)
Sets the direction this player's camera looks at. Use in combination with CameraPosition.
public virtual void SetCameraLookAt(Vector3 point)
Parameters
pointVector3The 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
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
textstringThe text to display.
colorColorThe text color.
drawDistancefloatThe distance from where players are able to see the chat bubble.
expireTimeintThe 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
textstringThe text to display.
colorColorThe text color.
drawDistancefloatThe distance from where players are able to see the chat bubble.
expireTimeTimeSpanThe 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
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
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
iconIdintThe icon ID for this player (0-99). Maximum 100 icons per Player.
positionVector3The icon position as a Vector3.
typeMapIconThe MapIcon type.
colorColorThe marker Color.
styleMapIconTypeThe 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
namestringThe new player name.
Exceptions
- InvalidPlayerNameException
Thrown if the
nameis 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
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
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
typeCheckpointTypeThe CheckpointType.
pointVector3The checkpoint position as a Vector3.
nextPositionVector3The position of the next checkpoint as a Vector3, used for arrow direction.
sizefloatThe 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
SetSkillLevel(WeaponSkill, int)
Sets the skill level of a specific Weapon for this player.
public virtual void SetSkillLevel(WeaponSkill skill, int level)
Parameters
skillWeaponSkillThe WeaponSkill to set.
levelintThe 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
spawnDataPlayerSpawnDataThe 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
teamintThe team ID for this player.
skinintThe skin this player will spawn with.
positionVector3The spawn position as a Vector3.
rotationfloatThe facing direction after spawning.
weapon1WeaponThe first spawn Weapon.
weapon1AmmointThe ammunition for the first
weapon1.weapon2WeaponThe second spawn Weapon.
weapon2AmmointThe ammunition for the second
weapon2.weapon3WeaponThe third spawn Weapon.
weapon3AmmointThe 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
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
weatherintThe 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
xMaxfloatThe maximum X coordinate.
xMinfloatThe minimum X coordinate.
yMaxfloatThe maximum Y coordinate.
yMinfloatThe 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
timeTimeSpanThe 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
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
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
targetPlayerPlayerThe Player to spectate.
modeSpectateModeThe 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
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
targetVehicleVehicleThe Vehicle to spectate.
modeSpectateModeThe 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
recordingTypePlayerRecordingTypeThe PlayerRecordingType.
recordingNamestringThe 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
targetPlayerThe 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
targetPlayerThe player for whom this player should be streamed out.
ToString()
public override string ToString()
Returns
ToggleClock(bool)
Toggles the visibility of the in-game clock (top right corner) for this player.
public virtual void ToggleClock(bool toggle)
Parameters
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
ToggleSpectating(bool)
Toggles spectating mode for this player.
public virtual void ToggleSpectating(bool toggle)
Parameters
Remarks
When spectating is disabled, the OnPlayerSpawn event is automatically triggered.
Operators
implicit operator IPlayer(Player?)
public static implicit operator IPlayer(Player? player)
Parameters
playerPlayer