Class PlayerObject
Represents a component which provides the data and functionality of a player object.
public class PlayerObject : WorldEntity
- Inheritance
-
PlayerObject
- Inherited Members
Constructors
PlayerObject(IOmpEntityProvider, IPlayerObjectData, IPlayerObject)
Initializes a new instance of the PlayerObject class.
protected PlayerObject(IOmpEntityProvider entityProvider, IPlayerObjectData playerObjects, IPlayerObject playerObject)
Parameters
entityProviderIOmpEntityProviderplayerObjectsIPlayerObjectDataplayerObjectIPlayerObject
Properties
AttachedPlayer
public virtual Player? AttachedPlayer { get; }
Property Value
AttachedVehicle
public virtual Vehicle? AttachedVehicle { get; }
Property Value
DrawDistance
Gets the draw distance of this player object.
public virtual float DrawDistance { get; }
Property Value
HasCameraCollision
Gets or sets a value indicating whether this player object collides with the player's camera.
public virtual bool HasCameraCollision { get; set; }
Property Value
IsMoving
Gets a value indicating whether this player object is moving.
public virtual bool IsMoving { get; }
Property Value
IsOmpEntityDestroyed
Gets a value indicating whether the open.mp entity counterpart has been destroyed.
protected bool IsOmpEntityDestroyed { get; }
Property Value
ModelId
Gets the model ID of this player object.
public virtual int ModelId { get; }
Property Value
Methods
AttachTo(Player, Vector3, Vector3)
Attaches this object to the specified target Player.
public virtual void AttachTo(Player target, Vector3 offset, Vector3 rotation)
Parameters
targetPlayerThe player to attach this object to.
offsetVector3The offset position relative to the player.
rotationVector3The rotation to apply to this object.
AttachTo(PlayerObject, Vector3, Vector3)
Attaches this object to the specified target PlayerObject.
public virtual void AttachTo(PlayerObject target, Vector3 offset, Vector3 rotation)
Parameters
targetPlayerObjectThe player object to attach this object to.
offsetVector3The offset position relative to the target object.
rotationVector3The rotation to apply to this object.
AttachTo(Vehicle, Vector3, Vector3)
Attaches this object to the specified target Vehicle.
public virtual void AttachTo(Vehicle target, Vector3 offset, Vector3 rotation)
Parameters
targetVehicleThe vehicle to attach this object to.
offsetVector3The offset position relative to the vehicle.
rotationVector3The rotation to apply to this object.
DisableCameraCollisions()
Disables collisions between players' cameras and this player object.
public virtual void DisableCameraCollisions()
GetMaterialData(int)
Gets the material data for the specified material slot, if any has been set.
public virtual ObjectMaterialData? GetMaterialData(int materialIndex)
Parameters
materialIndexintThe material slot index.
Returns
- ObjectMaterialData
The material data, or null if no material has been set in that slot.
GetMovingData()
Gets the current movement data of this player object.
public virtual ObjectMoveData GetMovingData()
Returns
- ObjectMoveData
The ObjectMoveData describing the current move target.
Move(Vector3, float)
Moves this player object to the specified position with the specified speed.
public virtual TimeSpan Move(Vector3 position, float speed)
Parameters
positionVector3The position to move this player object to as a Vector3.
speedfloatThe speed at which to move this player object.
Returns
- TimeSpan
The time for the object to complete the move.
Move(Vector3, float, Vector3)
Moves this player object to the specified position and rotation with the specified speed.
public virtual TimeSpan Move(Vector3 position, float speed, Vector3 rotation)
Parameters
positionVector3The position to move this player object to as a Vector3.
speedfloatThe speed at which to move this player object.
rotationVector3The rotation to move this player object to as a Vector3.
Returns
- TimeSpan
The time for the object to complete the move.
OnDestroyComponent()
This method is invoked before this component is destroyed and removed from its entity.
protected override void OnDestroyComponent()
ResetAttachment()
Resets any current attachment of this player object (to a player, vehicle, or another object).
public virtual void ResetAttachment()
SetMaterial(int, int, string, string, Color)
Sets the material color of this player object.
public virtual void SetMaterial(int materialIndex, int modelId, string txdName, string textureName, Color materialColor)
Parameters
materialIndexintThe material index on the object to change.
modelIdintThe model ID on which the replacement texture is located. Use 0 for alpha. Use -1 to change the material color without altering the texture.
txdNamestringThe name of the TXD file containing the replacement texture (use "none" if not required).
textureNamestringThe name of the texture to use as the replacement (use "none" if not required).
materialColorColorThe Color of the material to set (use default(Color) to keep the existing material color).
SetMaterialText(int, string, ObjectMaterialSize, string, int, bool, Color, Color, ObjectMaterialTextAlign)
Sets the material text of this player object.
public virtual void SetMaterialText(int materialIndex, string text, ObjectMaterialSize materialSize, string fontface, int fontSize, bool bold, Color foreColor, Color backColor, ObjectMaterialTextAlign textAlignment)
Parameters
materialIndexintThe material index on the object to change.
textstringThe text to display on the object (maximum 2048 characters).
materialSizeObjectMaterialSizeThe object's material size.
fontfacestringThe font to use for the text.
fontSizeintThe size of the text (maximum 255).
boldboolA value indicating whether to write the text in bold.
foreColorColorThe color of the text.
backColorColorThe background color of the text.
textAlignmentObjectMaterialTextAlignThe alignment of the text.
Stop()
Stops this player object from moving.
public virtual void Stop()
ToString()
public override string ToString()
Returns
Operators
implicit operator IPlayerObject(PlayerObject?)
Performs an implicit conversion from PlayerObject to IPlayerObject.
public static implicit operator IPlayerObject(PlayerObject? playerObject)
Parameters
playerObjectPlayerObject