Table of Contents

Struct IPlayerPool

Namespace
SampSharp.OpenMp.Core.Api
Assembly
SampSharp.OpenMp.Core.dll

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

handle nint

A pointer to the unmanaged interface.

Properties

Handle

Gets the handle to the unmanaged interface instance.

public nint Handle { get; }

Property Value

nint

HasValue

Gets a value indicating whether the pointer has a value.

public bool HasValue { get; }

Property Value

bool

Methods

AddExtension<T>(T)

Adds the specified managed extension to this extensible.

public void AddExtension<T>(T extension) where T : Extension

Parameters

extension T

An instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.

Type Parameters

T

The 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

character char

The character to allow or disallow.

allow bool

Whether to allow the character.

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

FlatPtrHashSet<IPlayer>

Bounds(out Pair<Size, Size>)

Retrieves the bounds of the pool.

public void Bounds(out Pair<Size, Size> bounds)

Parameters

bounds Pair<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

data SpanLite<byte>

The data span with the length in bits.

channel int

The channel to use.

skipFrom IPlayer

The player to exclude from the broadcast.

dispatchEvents bool

Whether 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

id int

The RPC ID.

data SpanLite<byte>

The data span with the length in bits.

channel int

The channel to use.

skipFrom IPlayer

The player to exclude from the broadcast.

dispatchEvents bool

Whether 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

vec Vector3

The position of the explosion.

type int

The type of explosion.

radius float

The radius of the explosion.

Entries()

Gets a set of all available players and bots (anything in the pool).

public FlatPtrHashSet<IPlayer> Entries()

Returns

FlatPtrHashSet<IPlayer>

Equals(IPlayerPool)

public bool Equals(IPlayerPool other)

Parameters

other IPlayerPool

Returns

bool

Equals(object?)

public override bool Equals(object? other)

Parameters

other object

Returns

bool

Get(int)

Gets the element at the specified index from the pool.

public IPlayer Get(int index)

Parameters

index int

The 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

pid int

The player ID.

Returns

Colour

The default colour.

GetExtension(UID)

Gets the extension with the specified id.

public IExtension GetExtension(UID id)

Parameters

id UID

The 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

T

The type of the managed extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

GetHashCode()

public override int GetHashCode()

Returns

int

GetPlayerChangeDispatcher()

Gets a dispatcher for player data change events.

public IEventDispatcher<IPlayerChangeEventHandler> GetPlayerChangeDispatcher()

Returns

IEventDispatcher<IPlayerChangeEventHandler>

GetPlayerCheckDispatcher()

Gets a dispatcher for player client check response events.

public IEventDispatcher<IPlayerCheckEventHandler> GetPlayerCheckDispatcher()

Returns

IEventDispatcher<IPlayerCheckEventHandler>

GetPlayerClickDispatcher()

Gets a dispatcher for player clicking events.

public IEventDispatcher<IPlayerClickEventHandler> GetPlayerClickDispatcher()

Returns

IEventDispatcher<IPlayerClickEventHandler>

GetPlayerConnectDispatcher()

Gets a dispatcher for player connection events.

public IEventDispatcher<IPlayerConnectEventHandler> GetPlayerConnectDispatcher()

Returns

IEventDispatcher<IPlayerConnectEventHandler>

GetPlayerDamageDispatcher()

Gets a dispatcher for player damage and death events.

public IEventDispatcher<IPlayerDamageEventHandler> GetPlayerDamageDispatcher()

Returns

IEventDispatcher<IPlayerDamageEventHandler>

GetPlayerShotDispatcher()

Gets a dispatcher for player shooting events.

public IEventDispatcher<IPlayerShotEventHandler> GetPlayerShotDispatcher()

Returns

IEventDispatcher<IPlayerShotEventHandler>

GetPlayerSpawnDispatcher()

Gets a dispatcher for player spawn events.

public IEventDispatcher<IPlayerSpawnEventHandler> GetPlayerSpawnDispatcher()

Returns

IEventDispatcher<IPlayerSpawnEventHandler>

GetPlayerStreamDispatcher()

Gets a dispatcher for player streaming events.

public IEventDispatcher<IPlayerStreamEventHandler> GetPlayerStreamDispatcher()

Returns

IEventDispatcher<IPlayerStreamEventHandler>

GetPlayerTextDispatcher()

Gets a dispatcher for player text and command events.

public IEventDispatcher<IPlayerTextEventHandler> GetPlayerTextDispatcher()

Returns

IEventDispatcher<IPlayerTextEventHandler>

GetPlayerUpdateDispatcher()

Gets a dispatcher for player update events.

public IEventDispatcher<IPlayerUpdateEventHandler> GetPlayerUpdateDispatcher()

Returns

IEventDispatcher<IPlayerUpdateEventHandler>

GetPoolEventDispatcher()

Gets a dispatcher for player pool events.

public IEventDispatcher<IPoolEventHandler<IPlayer>> GetPoolEventDispatcher()

Returns

IEventDispatcher<IPoolEventHandler<IPlayer>>

HideGameTextForAll(int)

Hides a game text message for all players.

public void HideGameTextForAll(int style)

Parameters

style int

The 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

name string

The name to check.

skip IPlayer

The player to exclude from the check.

Returns

bool

true if the name is taken; otherwise, false.

IsNameValid(string)

Checks if a player name is valid.

public bool IsNameValid(string name)

Parameters

name string

The name to validate.

Returns

bool

true if the name is valid; otherwise, false.

IsNickNameCharacterAllowed(char)

Checks if a specific character is allowed in player names.

public bool IsNickNameCharacterAllowed(char character)

Parameters

character char

The character to check.

Returns

bool

true if the character is allowed; otherwise, false.

Players()

Gets a set of all available players only.

public FlatPtrHashSet<IPlayer> Players()

Returns

FlatPtrHashSet<IPlayer>

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

T

The type of the unmanaged extension.

RemoveExtension(IExtension)

Removes the specified extension from this extensible.

public void RemoveExtension(IExtension extension)

Parameters

extension IExtension

The 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

id UID

The 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

extension T

The managed extension to remove.

Type Parameters

T

The 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

netData PeerNetworkData

The network data for the player.

parms PeerRequestParams

The 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

from IPlayer

The player sending the message.

message string

The message to send.

SendClientMessageToAll(ref Colour, string)

Sends a client message to all players.

public void SendClientMessageToAll(ref Colour colour, string message)

Parameters

colour Colour

The colour of the message.

message string

The message to send.

SendDeathMessageToAll(IPlayer, IPlayer, int)

Sends a death message to all players.

public void SendDeathMessageToAll(IPlayer killer, IPlayer killee, int weapon)

Parameters

killer IPlayer

The player who killed.

killee IPlayer

The player who was killed.

weapon int

The 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

message string

The message to display.

time TimeSpan

The duration to display the message.

style int

The 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 T or null if no extension with the specified type could be found.

Type Parameters

T

The 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

extension T

The extension if found, otherwise null.

Returns

bool

true if the extension was found; false otherwise.

Type Parameters

T

The 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

lhs IPlayerPool

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are equal; otherwise, false.

explicit operator IPlayerPool(IExtensible)

Casts the IExtensible to a IPlayerPool.

public static explicit operator IPlayerPool(IExtensible value)

Parameters

value IExtensible

The 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

value IPlayerPool

The 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

value IPlayerPool

The 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

value IReadOnlyPool<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

lhs IPlayerPool

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are not equal; otherwise, false.