Table of Contents

Struct ICore

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

This type represents a pointer to an unmanaged open.mp ICore interface.

[OpenMpApi(new Type[] { typeof(IExtensible), typeof(ILogger) })]
public readonly struct ICore : IEquatable<ICore>, ICore.IManagedInterface, IExtensible.IManagedInterface, ILogger.IManagedInterface, IUnmanagedInterface
Implements
Inherited Members

Constructors

ICore(nint)

Initializes a new instance of the ICore struct.

public ICore(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.

ConnectBot(string, string)

Attempt to connect a new bot to the server.

public void ConnectBot(string name, string script)

Parameters

name string

The bot name (player name).

script string

The bot script to execute.

Equals(ICore)

public bool Equals(ICore other)

Parameters

other ICore

Returns

bool

Equals(object?)

public override bool Equals(object? other)

Parameters

other object

Returns

bool

GetConfig()

Gets the server configuration.

public IConfig GetConfig()

Returns

IConfig

Yhe server configuration.

GetEventDispatcher()

Gets the core event dispatcher.

public IEventDispatcher<ICoreEventHandler> GetEventDispatcher()

Returns

IEventDispatcher<ICoreEventHandler>

The core event dispatcher.

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.

GetGravity()

Gets the server gravity.

public float GetGravity()

Returns

float

The server gravity.

GetHashCode()

public override int GetHashCode()

Returns

int

GetNetworkBitStreamVersion()

Get the version of the NetworkBitStream class the core was built with.

public int GetNetworkBitStreamVersion()

Returns

int

The version of the NetworkBitStream class.

GetNetworks()

Gets a list of available networks.

public FlatPtrHashSet<INetwork> GetNetworks()

Returns

FlatPtrHashSet<INetwork>

A list of available networks.

GetPlayers()

Gets the player pool

public IPlayerPool GetPlayers()

Returns

IPlayerPool

The player pool.

GetTickCount()

Gets the tick count.

public uint GetTickCount()

Returns

uint

The tick count.

GetVersion()

Gets the version of the open.mp server.

public SemanticVersion GetVersion()

Returns

SemanticVersion

The version of the open.mp server package.

GetVersionHash()

Gets the version hash of the open.mp server.

public string GetVersionHash()

Returns

string

The version hash.

GetWeaponName(PlayerWeapon)

Get the name of a weapon.

public string GetWeaponName(PlayerWeapon weapon)

Parameters

weapon PlayerWeapon

The weapon.

Returns

string

The name of the weapon.

LogLine(LogLevel, string)

Logs a new line to the console with the specified severity level.

public void LogLine(LogLevel level, string msg)

Parameters

level LogLevel

The severity level at which to log the line.

msg string

The message to log.

LogLn(LogLevel, byte*)

Prints a new line to the console with the specified severity level.

public void LogLn(LogLevel level, byte* msg)

Parameters

level LogLevel

The severity level at which to log the line.

msg byte*

The message to log.

LogLnU8(LogLevel, byte*)

Prints a new line to the console of the specified log type in UTF-8 encoding.

public void LogLnU8(LogLevel level, byte* msg)

Parameters

level LogLevel

The severity level at which to log the line.

msg byte*

The message to log.

PrintLine(string)

Prints a new line to the console.

public void PrintLine(string msg)

Parameters

msg string

The message to log.

PrintLn(byte*)

Prints a new line to the console.

public void PrintLn(byte* msg)

Parameters

msg byte*

The message to log.

PrintLnU8(byte*)

Prints a new line to the console in UTF-8 encoding.

public void PrintLnU8(byte* msg)

Parameters

msg byte*

The message to log.

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.

ReloadAll()

Create all entities that appear on GM start.

public void ReloadAll()

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.

ResetAll()

Clear all entities that vanish on GM exit.

public void ResetAll()

SetData(SettableCoreDataType, string)

Sets string data during runtime.

public void SetData(SettableCoreDataType type, string data)

Parameters

type SettableCoreDataType

The type of the data.

data string

The data value.

SetGravity(float)

Sets the server gravity.

public void SetGravity(float gravity)

Parameters

gravity float

The server gravity.

SetThreadSleep(Microseconds)

Sets the sleep value for each main thread update cycle.

public void SetThreadSleep(Microseconds value)

Parameters

value Microseconds

The sleep duration.

SetWeather(int)

Sets the server weather.

public void SetWeather(int weather)

Parameters

weather int

The server weather.

SetWorldTime(TimeSpan)

Sets the server world time.

public void SetWorldTime(TimeSpan time)

Parameters

time TimeSpan

The world time, truncated to whole hours on the native side.

TickRate()

Gets the ticks per second.

public uint TickRate()

Returns

uint

Ticks per second.

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.

UseDynTicks(bool)

Toggle dynamic ticks instead of static duration sleep.

public void UseDynTicks(bool enable)

Parameters

enable bool

true if dynamic ticks should be enabled.

UseStuntBonuses(bool)

Toggles server stunt bonuses.

public void UseStuntBonuses(bool enable)

Parameters

enable bool

true if stunt bonuses should be enabled.

Operators

operator ==(ICore, object?)

Determines whether the specified values are equal.

public static bool operator ==(ICore lhs, object? rhs)

Parameters

lhs ICore

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 IExtensible(ICore)

Casts the ICore to a IExtensible.

public static explicit operator IExtensible(ICore value)

Parameters

value ICore

The ICore to cast.

Returns

IExtensible

The converted IExtensible.

explicit operator ILogger(ICore)

Casts the ICore to a ILogger.

public static explicit operator ILogger(ICore value)

Parameters

value ICore

The ICore to cast.

Returns

ILogger

The converted ILogger.

explicit operator ICore(IExtensible)

Casts the IExtensible to a ICore.

public static explicit operator ICore(IExtensible value)

Parameters

value IExtensible

The IExtensible to cast.

Returns

ICore

The converted ICore.

explicit operator ICore(ILogger)

Casts the ILogger to a ICore.

public static explicit operator ICore(ILogger value)

Parameters

value ILogger

The ILogger to cast.

Returns

ICore

The converted ICore.

operator !=(ICore, object?)

Determines whether the specified values are not equal.

public static bool operator !=(ICore lhs, object? rhs)

Parameters

lhs ICore

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.