Skip to content

Natives

Phil25 edited this page Jan 4, 2024 · 12 revisions

Contents

Client Interaction ^

Name Description
RTD2_GetClientPerk Returns player's current RTDPerk. Can be used to check if the player is in roll.
RTD2_GetClientPerkTime Returns time in seconds the player has left to the perk end.
RTD2_AddClientPerkTime Adds time to client's current roll.
RTD2_Force Forces a perk on a player.
RTD2_Roll Rolls a perk with given data.
RTD2_Remove Removes current perk from the client.

Perk Queries ^

Name Description
RTD2_FindPerk Finds a perk by token or ID, where token is prioritized.
RTD2_FindPerks Finds perks by token, ID or tags.

External Perk Management ^

Name Description
RTD2_ObtainPerk Gets a perk by token, or registers one if not found.
RTD2_DisableModulePerks Disables all the perks that were registered by the plugin this native is called from, and sets all overriden core perks back to the default state.
RTD2_IsRegOpen Returns whether perks can be registered.
RTD2_CanPlayerBeHurt A miscellaneous native which returns whether the client can be hurt.

Used by RTDPerk Class ^

Instead of using any of these, you should prefer the ones provided by RTDPerk Class instead.

Name Description
RTD2_GetPerkAny Gets perk property of type any or Handle.
RTD2_SetPerkAny Sets perk property of type any.
RTD2_GetPerkString Gets perk property of type char[].
RTD2_SetPerkString Sets perk property of type char[].
RTD2_SetPerkCall Set the function to call when perk should operate on client.
RTD2_GetPerkPrefCell Gets perk setting of type cell.
RTD2_GetPerkPrefFloat Gets perk setting of type float.
RTD2_GetPerkPrefString Gets perk setting of type char[].
RTD2_SetPerkPref Sets perk property of type char[].
RTD2_Format Format specific perk properties into a buffer.

Deprecated ^

Do not use these ever or your computer will explode.

Name Description Replaced By
RTD2_GetClientPerkId Returns player's current perk index. Meant to check if player is using RTD. RTD_GetClientPerk
RTD2_ForcePerk Forces a perk on a player. RTD2_Force
RTD2_RollPerk Rolls a perk with given data. RTD2_Roll
RTD2_RemovePerk Removes current perk from the client. RTD2_Remove
RTD2_GetPerkOfString Gets the perk's index by either the actual index, perk's token or a single tag. RTD2_FindPerk
RTD2_RegisterPerk Registers a perk from a different plugin to the core. RTD2_ObtainPerk
RTD2_SetPerkByToken Enables/disables perk by token. RTD2_SetPerk*
RTD2_SetPerkById Enables/disables perk by ID. RTD2_SetPerk*
RTD2_DefaultCorePerk Set back perk's call to default one. RTD2_SetPerk*


RTD2_GetClientPerk ^

Returns player's current RTDPerk. Can be used to check if the player is in roll.

RTDPerk.Valid is false if client was not in roll.

RTDPerk RTD2_GetClientPerk(int client)

Parameters

  • int client — Client index.

Returns RTDPerk object.


RTD2_GetClientPerkTime ^

Returns time in seconds the player has left to the perk end.

int RTD2_GetClientPerkTime(int client)

Parameters

  • int client — Client index.

Returns time in seconds if client is using RTD, -1 otherwise.


RTD2_AddClientPerkTime ^

Adds time to client's current roll.

int RTD2_AddClientPerkTime(int client, int iAddedTime)

Parameters

  • int client — Client index.
  • int iAddedTime — Additional time in seconds, can be negative to subtract.

Returns the new remaining perk time, or non-positive if client was not in roll or perk is about to be removed because of this call.


RTD2_Force ^

Forces a perk on a player.

RTDForceResult RTD2_Force(int client, const char[] sQuery, int iTime=-1, int iInitiator=0)

Parameters

  • int client — Client index.
  • const char[] sQuery — Query string, containing id, token or a tag. If invalid a roll will occur.
  • int iTime — Custom perk's time. -1 = use default.
  • int iInitiator — Entity which initiated forcing the perk.

Returns RTDForceResult enum value.


RTD2_Roll ^

Rolls a perk with given data.

This does not apply the perk to the client.

RTDPerk.Valid is false if no applicable perks are found.

RTDPerk RTD2_Roll(int client, int iRollFlags=ROLLFLAG_NONE, const char[] sFilter="")

Parameters

  • int client — Client index.
  • int iRollFlagsRoll flag definitions.
  • const char[] sFilter — Query by which to filter the applicable perks.

Returns RTDPerk object.


RTD2_Remove ^

Removes current perk from the client.

RTDPerk.Valid is false if client was not in roll.

RTDPerk RTD2_Remove(int client, RTDRemoveReason reason=RTDRemove_WearOff, const char[] sReason="", bool bForce=false, int iInitiator=0)

Parameters

  • int client — Client index.
  • RTDRemoveReason reasonRTDRemoveReason enum.
  • const char[] sReason — Print custom message if reason=RTDRemove_Custom.
  • bool bForce — Forced removals are treated as loggable actions, whereas non-forced are "natural" reasons. No distinction other than what is logged.
  • int iInitiator — Client who initiated the removal. Used only when bForce=true.

Returns RTDPerk object.



RTD2_FindPerk ^

Finds a perk by token or ID, where token is prioritized.

RTDPerk.Valid is false if no perk was found.

RTDPerk RTD2_FindPerk(const char[] sQuery="")

Parameters

  • const char[] sQuery — Query to search by.

Returns RTDPerk object.


RTD2_FindPerks ^

Finds perks by token, ID or tags.

Will never be null, but might be empty.

Must be freed via delete or CloseHandle().

RTDPerkList RTD2_FindPerks(const char[] sQuery="")

Parameters

  • const char[] sQuery — Query to search by.

Returns RTDPerkList object.



RTD2_ObtainPerk ^

Gets a perk by token, or registers one if not found.

Perks cannot be unregistered, disable them instead.

If a perk is registered, a new ID is automatically assigned.

This sets External to true on that perk.

RTDPerk RTD2_ObtainPerk(const char[] sToken)

Parameters

  • const char[] sToken — Unique token used for addressing the perk.

Returns RTDPerk object.


RTD2_DisableModulePerks ^

Disables all the perks that were registered by the plugin this native is called from, and sets all overriden core perks back to the default state.

If registering perks, this must be called in the OnPluginEnd. This will make sure perks registered by the module will be properly disposed on clients who currently are using them, by calling the RTDCall function that disables them.

void RTD2_DisableModulePerks()

No parameters

No return.


RTD2_IsRegOpen ^

Registering a perk via external plugin is possible only after all the core ones were registered. You can register new perks in OnPluginStart() when this native returns true (if late-loaded). Otherwise, register them in the RTD2_OnRegOpen() forward.

bool RTD2_IsRegOpen()

No parameters

Returns true if registering is open, false otherwise.


RTD2_CanPlayerBeHurt ^

A miscellaneous native which returns whether the client can be hurt.

Optionally, hurt by whom.

It is adived to use this as it checks if the client is in Friendly Mode.

bool RTD2_CanPlayerBeHurt(int client, int by=0)

Parameters

  • int client — Can this client be hurt...
  • int by — ...by this client?

Returns true if client can be hurt under the conditions, false otherwise.