Struct IPlayerPool
This type represents a pointer to an unmanaged open.mp IPlayerPool interface.
[OpenMpApi(new Type[] { typeof(IExtensible), typeof(IReadOnlyPool<IPlayer>) })]
public readonly struct IPlayerPool : IEquatable<IPlayerPool>, IPlayerPool.IManagedInterface, IExtensible.IManagedInterface, IReadOnlyPool<IPlayer>.IManagedInterface, IUnmanagedInterface
- Implements
- Inherited Members
Constructors
IPlayerPool(nint)
Initializes a new instance of the IPlayerPool struct.
public IPlayerPool(nint handle)
Parameters
handlenintA pointer to the unmanaged interface.
Properties
Handle
Gets the handle to the unmanaged interface instance.
public nint Handle { get; }
Property Value
HasValue
Gets a value indicating whether the pointer has a value.
public bool HasValue { get; }
Property Value
Methods
AddExtension<T>(T)
Adds the specified managed extension to this extensible.
public void AddExtension<T>(T extension) where T : Extension
Parameters
extensionTAn instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.
Type Parameters
TThe type of the managed extension.
Remarks
A managed extension can only be added to one extensible.
Exceptions
- ArgumentException
Throw when an instance of the extension type was already added to this extensible.
AllowNickNameCharacter(char, bool)
Allows or disallows the use of a specific character in player names.
public void AllowNickNameCharacter(char character, bool allow)
Parameters
AsPool()
Converts this instance to a read-only player pool.
public IReadOnlyPool<IPlayer> AsPool()
Returns
- IReadOnlyPool<IPlayer>
A read-only player pool.
Bots()
Gets a set of all available bots only.
public FlatPtrHashSet<IPlayer> Bots()
Returns
Bounds(out Pair<Size, Size>)
Retrieves the bounds of the pool.
public void Bounds(out Pair<Size, Size> bounds)
Parameters
boundsPair<Size, Size>The output parameter that will contain the bounds of the pool as a pair of sizes.
BroadcastPacket(SpanLite<byte>, int, IPlayer, bool)
Broadcasts a packet to all players.
public void BroadcastPacket(SpanLite<byte> data, int channel, IPlayer skipFrom = default, bool dispatchEvents = true)
Parameters
dataSpanLite<byte>The data span with the length in bits.
channelintThe channel to use.
skipFromIPlayerThe player to exclude from the broadcast.
dispatchEventsboolWhether to dispatch packet-related events.
BroadcastRPC(int, SpanLite<byte>, int, IPlayer, bool)
Broadcasts an RPC to all players.
public void BroadcastRPC(int id, SpanLite<byte> data, int channel, IPlayer skipFrom = default, bool dispatchEvents = true)
Parameters
idintThe RPC ID.
dataSpanLite<byte>The data span with the length in bits.
channelintThe channel to use.
skipFromIPlayerThe player to exclude from the broadcast.
dispatchEventsboolWhether to dispatch RPC-related events.
CreateExplosionForAll(Vector3, int, float)
Creates an explosion for all players.
public void CreateExplosionForAll(Vector3 vec, int type, float radius)
Parameters
vecVector3The position of the explosion.
typeintThe type of explosion.
radiusfloatThe radius of the explosion.
Entries()
Gets a set of all available players and bots (anything in the pool).
public FlatPtrHashSet<IPlayer> Entries()
Returns
Equals(IPlayerPool)
public bool Equals(IPlayerPool other)
Parameters
otherIPlayerPool
Returns
Equals(object?)
public override bool Equals(object? other)
Parameters
otherobject
Returns
Get(int)
Gets the element at the specified index from the pool.
public IPlayer Get(int index)
Parameters
indexintThe index of the element to retrieve.
Returns
- IPlayer
The element at the specified index.
GetDefaultColour(int)
Gets the default colour assigned to a player ID when they first connect.
public Colour GetDefaultColour(int pid)
Parameters
pidintThe player ID.
Returns
- Colour
The default colour.
GetExtension(UID)
Gets the extension with the specified id.
public IExtension GetExtension(UID id)
Parameters
idUIDThe identifier of the extension type.
Returns
- IExtension
The extension or null if the extension could not be found.
GetExtension<T>()
Gets the specified managed extension from this extensible.
public T GetExtension<T>() where T : Extension
Returns
- T
An instance of the extension with type
T.
Type Parameters
TThe type of the managed extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
GetHashCode()
public override int GetHashCode()
Returns
GetPlayerChangeDispatcher()
Gets a dispatcher for player data change events.
public IEventDispatcher<IPlayerChangeEventHandler> GetPlayerChangeDispatcher()
Returns
GetPlayerCheckDispatcher()
Gets a dispatcher for player client check response events.
public IEventDispatcher<IPlayerCheckEventHandler> GetPlayerCheckDispatcher()
Returns
GetPlayerClickDispatcher()
Gets a dispatcher for player clicking events.
public IEventDispatcher<IPlayerClickEventHandler> GetPlayerClickDispatcher()
Returns
GetPlayerConnectDispatcher()
Gets a dispatcher for player connection events.
public IEventDispatcher<IPlayerConnectEventHandler> GetPlayerConnectDispatcher()
Returns
GetPlayerDamageDispatcher()
Gets a dispatcher for player damage and death events.
public IEventDispatcher<IPlayerDamageEventHandler> GetPlayerDamageDispatcher()
Returns
GetPlayerShotDispatcher()
Gets a dispatcher for player shooting events.
public IEventDispatcher<IPlayerShotEventHandler> GetPlayerShotDispatcher()
Returns
GetPlayerSpawnDispatcher()
Gets a dispatcher for player spawn events.
public IEventDispatcher<IPlayerSpawnEventHandler> GetPlayerSpawnDispatcher()
Returns
GetPlayerStreamDispatcher()
Gets a dispatcher for player streaming events.
public IEventDispatcher<IPlayerStreamEventHandler> GetPlayerStreamDispatcher()
Returns
GetPlayerTextDispatcher()
Gets a dispatcher for player text and command events.
public IEventDispatcher<IPlayerTextEventHandler> GetPlayerTextDispatcher()
Returns
GetPlayerUpdateDispatcher()
Gets a dispatcher for player update events.
public IEventDispatcher<IPlayerUpdateEventHandler> GetPlayerUpdateDispatcher()
Returns
GetPoolEventDispatcher()
Gets a dispatcher for player pool events.
public IEventDispatcher<IPoolEventHandler<IPlayer>> GetPoolEventDispatcher()
Returns
HideGameTextForAll(int)
Hides a game text message for all players.
public void HideGameTextForAll(int style)
Parameters
styleintThe style of the message to hide.
IsNameTaken(string, IPlayer)
Checks if a name is taken by any player, excluding a specific player.
public bool IsNameTaken(string name, IPlayer skip)
Parameters
Returns
- bool
trueif the name is taken; otherwise,false.
IsNameValid(string)
Checks if a player name is valid.
public bool IsNameValid(string name)
Parameters
namestringThe name to validate.
Returns
- bool
trueif the name is valid; otherwise,false.
IsNickNameCharacterAllowed(char)
Checks if a specific character is allowed in player names.
public bool IsNickNameCharacterAllowed(char character)
Parameters
charactercharThe character to check.
Returns
- bool
trueif the character is allowed; otherwise,false.
Players()
Gets a set of all available players only.
public FlatPtrHashSet<IPlayer> Players()
Returns
QueryExtension<T>()
Gets the specified unmanaged extension from this extensible.
public T QueryExtension<T>() where T : unmanaged, IExtension.IManagedInterface
Returns
- T
The unmanaged extension or null if the extension could not be found.
Type Parameters
TThe type of the unmanaged extension.
RemoveExtension(IExtension)
Removes the specified extension from this extensible.
public void RemoveExtension(IExtension extension)
Parameters
extensionIExtensionThe extension to remove.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
RemoveExtension(UID)
Removes the extension with the specified id from this extensible.
public void RemoveExtension(UID id)
Parameters
idUIDThe identifier of the extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
RemoveExtension<T>(T)
Removes the specified managed extension from this extensible.
public void RemoveExtension<T>(T extension) where T : Extension
Parameters
extensionTThe managed extension to remove.
Type Parameters
TThe type of the managed extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
RequestPlayer(ref PeerNetworkData, ref PeerRequestParams)
Requests a new player with the given network parameters.
public (NewConnectionResult, IPlayer) RequestPlayer(ref PeerNetworkData netData, ref PeerRequestParams parms)
Parameters
netDataPeerNetworkDataThe network data for the player.
parmsPeerRequestParamsThe request parameters.
Returns
- (NewConnectionResult, IPlayer)
A tuple containing the result of the connection and the player instance.
SendChatMessageToAll(IPlayer, string)
Sends a chat message to all players.
public void SendChatMessageToAll(IPlayer from, string message)
Parameters
SendClientMessageToAll(ref Colour, string)
Sends a client message to all players.
public void SendClientMessageToAll(ref Colour colour, string message)
Parameters
SendDeathMessageToAll(IPlayer, IPlayer, int)
Sends a death message to all players.
public void SendDeathMessageToAll(IPlayer killer, IPlayer killee, int weapon)
Parameters
killerIPlayerThe player who killed.
killeeIPlayerThe player who was killed.
weaponintThe weapon used.
SendEmptyDeathMessageToAll()
Sends an empty death message to all players.
public void SendEmptyDeathMessageToAll()
SendGameTextToAll(string, TimeSpan, int)
Sends a game text message to all players.
public void SendGameTextToAll(string message, TimeSpan time, int style)
Parameters
messagestringThe message to display.
timeTimeSpanThe duration to display the message.
styleintThe style of the message.
TryGetExtension<T>()
Tries to get the specified managed extension from this extensible.
public T? TryGetExtension<T>() where T : Extension
Returns
- T
An instance of the extension with type
Tor null if no extension with the specified type could be found.
Type Parameters
TThe type of the managed extension.
TryQueryExtension<T>(out T)
Tries to get the specified unmanaged extension from this extensible.
public bool TryQueryExtension<T>(out T extension) where T : unmanaged, IExtension.IManagedInterface
Parameters
extensionTThe extension if found, otherwise null.
Returns
Type Parameters
TThe type of the unmanaged extension.
Operators
operator ==(IPlayerPool, object?)
Determines whether the specified values are equal.
public static bool operator ==(IPlayerPool lhs, object? rhs)
Parameters
lhsIPlayerPoolThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are equal; otherwise,false.
explicit operator IPlayerPool(IExtensible)
Casts the IExtensible to a IPlayerPool.
public static explicit operator IPlayerPool(IExtensible value)
Parameters
valueIExtensibleThe IExtensible to cast.
Returns
- IPlayerPool
The converted IPlayerPool.
explicit operator IExtensible(IPlayerPool)
Casts the IPlayerPool to a IExtensible.
public static explicit operator IExtensible(IPlayerPool value)
Parameters
valueIPlayerPoolThe IPlayerPool to cast.
Returns
- IExtensible
The converted IExtensible.
explicit operator IReadOnlyPool<IPlayer>(IPlayerPool)
Casts the IPlayerPool to a IReadOnlyPool<T>.
public static explicit operator IReadOnlyPool<IPlayer>(IPlayerPool value)
Parameters
valueIPlayerPoolThe IPlayerPool to cast.
Returns
- IReadOnlyPool<IPlayer>
The converted IReadOnlyPool<T>.
explicit operator IPlayerPool(IReadOnlyPool<IPlayer>)
Casts the IReadOnlyPool<T> to a IPlayerPool.
public static explicit operator IPlayerPool(IReadOnlyPool<IPlayer> value)
Parameters
valueIReadOnlyPool<IPlayer>The IReadOnlyPool<T> to cast.
Returns
- IPlayerPool
The converted IPlayerPool.
operator !=(IPlayerPool, object?)
Determines whether the specified values are not equal.
public static bool operator !=(IPlayerPool lhs, object? rhs)
Parameters
lhsIPlayerPoolThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are not equal; otherwise,false.