Skip to content

RTDPerk Class

Filip Tomaszewski edited this page Apr 18, 2020 · 18 revisions

Object oriented wrapper for perk management.

Methods

Name Description
RTDPerk Specifies a perk. The perk is defined by the perk's ID. Defines getters and setters for accessing all of the perk's properties.
GetName Gets name of the perk.
SetName Sets name of the perk.
SetGood Sets whether the perk is good.
GetSound Gets sound path of the perk.
SetSound Sets sound path of the perk.
GetToken Gets token of the perk.
SetTime Sets custom time of the perk.
SetClasses Sets class flags the perk is applicable to.
SetWeaponClasses Sets weapon classes the perk is applicable to.
SetTags Set search tags of the perk.
GetPrefCell Gets perk setting of type cell.
GetPrefFloat Gets perk setting of type float.
GetPrefString Gets perk setting of type char[].
SetPref Sets settings of the perk.
GetInternalCall Get internal call function name assigned to the perk.
SetInternalCall Set internal call of the perk.
SetEnabled Sets whether the perk is enabled
SetExternal Sets whether the perk should call an external function.
SetCall Sets external call of the perk.
Format Formats specific perk properties into a buffer.

Properties

Name Type Description
Valid bool Check if the perk is valid.
Good bool Retrieves or sets whether the perk is good.
Time int Retrieves or sets custom time of the perk.
Classes int Retrieves perk class flags.
WeaponClasses ArrayList Retrieves ArrayList of weapon classes the perk is applicable to.
Tags ArrayList Retrieves ArrayList of perk's tags.
Enabled bool Retrieves or sets whether the perk is enabled.
External bool Retrieves or sets whether the perk should call an external function.


RTDPerk ^

Specifies a perk. The perk is defined by the perk's ID. Defines getters and setters for accessing all of the perk's properties.

RTDPerk methodmap would most of the times be obtained through other natives or passed as an argument in a forward. You probably don't want to call this constructor at all.

For creating perks, use RTD2_ObtainPerk(). For finding perks, use RTD2_FindPerk() and RTD2_FindPerks().

RTDPerk is a cell under the hood, therefor doesn't need to be freed with delete or CloseHandle().

public RTDPerk(const char[] sToken)

Parameters

  • const char[] sToken — Token to bind the ID of.

Returns RTDPerk object.


GetName ^

Get name of the perk.

public void GetName(char[] sBuffer, int iBufferLen)

Parameters

  • char[] sBuffer — Buffer to store the value.
  • int iBufferLen — Maximum size of string buffer.

No return.


SetName ^

Set name of the perk.

public RTDPerk SetName(const char[] sName)

Parameters

  • const char[] sName — String to set the name to.

Returns same RTDPerk object.


SetGood ^

Sets whether the perk is good.

Prefer to use Good property if not chaining methods.

public RTDPerk SetGood(bool bGood)

Parameters

  • bool bGood — Value to determine whether the perk is good.

Returns same RTDPerk object.


GetSound ^

Get sound path of the perk.

public void GetSound(char[] sBuffer, int iBufferLen)

Parameters

  • char[] sBuffer — Buffer to store the value.
  • int iBufferLen — Maximum size of string buffer.

No return.


SetSound ^

Set sound path of the perk.

public RTDPerk SetSound(const char[] sSound)

Parameters

  • const char[] sSound — String to set the sound path to.

Returns same RTDPerk object.


GetToken ^

Get token of the perk.

public void GetToken(char[] sBuffer, int iBufferLen)

Parameters

  • char[] sBuffer — Buffer to store the value.
  • int iBufferLen — Maximum size of string buffer.

No return.


SetTime ^

Sets custom time of the perk.

Prefer to use Time property if not chaining methods.

public RTDPerk SetTime(int iTime)

Parameters

  • int iTime — Value to set the time to.

Returns same RTDPerk object.


SetClasses ^

Set class flags the perk is applicable to.

This string is parsed the same way its config equivalent is.

public RTDPerk SetClasses(const char[] sClasses)

Parameters

  • const char[] sClasses — String with digits representing classes.

Returns same RTDPerk object.


SetWeaponClasses ^

Set weapon classes the perk is applicable to.

Prefer the property if not chaining methods. Manually pushing classes is faster.

This string is parsed the same way its config equivalent is.

This will destroy and create the Weapon Classes ArrayList Handle.

public RTDPerk SetWeaponClasses(const char[] sWeaponClasses)

Parameters

  • const char[] sWeaponClasses — String representing weapon classes or parts of them, separated by comma.

Returns same RTDPerk object.


SetTags ^

Set search tags of the perk.

Prefer the property if not chaining methods. Manually pushing tags is faster.

This string is parsed the same way its config equivalent is.

This will destroy and create the Tags ArrayList Handle.

public RTDPerk SetTags(const char[] sTags)

Parameters

  • const char[] sTags — String representing tags, separated by comma.

Returns same RTDPerk object.


GetPrefCell ^

Gets perk setting of type cell.

This is just a wrapper for rounding the float type setting.

public int GetPrefCell(const char[] sKey)

Parameters

  • const char[] sKey — Setting's key.

Setting's value.


GetPrefFloat ^

Gets perk setting of type float.

public float GetPrefFloat(const char[] sKey)

Parameters

  • const char[] sKey — Setting's key.

Setting's value.


GetPrefString ^

Gets perk setting of type char[].

public void GetPrefString(const char[] sKey, char[] sBuffer, int iBufferLen)

Parameters

  • const char[] sKey — Setting's key.
  • char[] sBuffer — char[] buffer to store the result in.
  • int iBufferLen — Length of the buffer.

No return.


SetPref ^

Sets setting of the perk.

This will silently fail if sKey is prefixed with m_.

public RTDPerk SetPref(const char[] sKey, const char[] sValue)

Parameters

  • const char[] sKey — Setting's key.
  • const char[] sValue — Value to set the setting to.

Returns same RTDPerk object.


GetInternalCall ^

Get internal call function name assigned to the perk.

public void GetInternalCall(char[] sBuffer, int iBufferLen)

Parameters

  • char[] sBuffer — Buffer to store the value.
  • int iBufferLen — Maximum size of string buffer.

No return.


SetInternalCall ^

Set internal call of the perk.

public RTDPerk SetInternalCall(const char[] sName)

Parameters

  • const char[] sName — Name of the function to call during perk's execution.

Returns same RTDPerk object.


SetEnabled ^

Sets whether the perk is enabled.

Prefer to use Enabled property if not chaining methods.

Perk is automatically enabled on registration.

public RTDPerk SetEnabled(bool bEnabled)

Parameters

  • bool bEnabled — Value to determine whether the perk is enabled.

Returns same RTDPerk object.


SetExternal ^

Sets whether the perk should call an external function.

Prefer to use External property if not chaining methods.

Perk is automatically set to call an external function on registration.

public RTDPerk SetExternal(bool bExternal)

Parameters

  • bool bExternal — Value to determine whether the perk should call an external function.

Returns same RTDPerk object.


SetCall ^

Set external call of the perk.

This also sets Enable and External to true.

public RTDPerk SetCall(RTDCall func)

Parameters

  • bool bExternalRTDCall callback function.

Returns same RTDPerk object.


Format ^

Format specific perk properties into a buffer.

Available specifiers: $Id$, $Name$, $Good$, $Sound$, $Token$, $Time$, $Tags$, $Class$, $WeaponClass$, $Settings$.

Format example: "Perk: $Id$ - $Name$"

Mind the capitalization.

public RTDPerk Format(char[] sBuffer, int iBufferLen, const char[] sFormat)

Parameters

  • char[] sBuffer — Buffer to store the result in.
  • int iBufferLen — Length of the buffer.
  • const char[] sFormat — Formatting rules.

Returns same RTDPerk object.

Example Usage

char sBuffer[1024];
RTD2_ObtainPerk("myperktoken")
    .SetName("Super Perk")
    .SetGood(true)
    .SetPref("damage", "5.0")
    .SetPref("rate", "2.0")
    .SetTags("my,super,perk,whatever")
    .Format(sBuffer, sizeof(sBuffer), "$Token$: $Name$\nGood: $Good$\nSettings: $Settings$\nTags: $Tags$ ");
PrintToServer(sBuffer)

Will print:

myperktoken: Super Perk
Good: true
Settings: {damage: 5.00, rate: 2.00}
Tags: [my, super, perk, whatever]


Valid ^

Check if the perk is valid. This should be called after RTD2_FindPerk().

Usage

Type bool
Getter Yes
Setter No

Good ^

Retrieves or sets whether the perk is good.

Usage

Type bool
Getter Yes
Setter Yes

Time ^

Retrieves or sets custom time of the perk.

Usage

Type int
Getter Yes
Setter Yes

Classes ^

Retrieves perk class flags.

Usage

Type int
Getter Yes
Setter No

WeaponClasses ^

Retrieves ArrayList of weapon classes the perk is applicable to.

This is never null and is not cloned.

WeaponClasses is an array of strings of blocksize 127.

Usage

Type ArrayList
Getter Yes
Setter No

Tags ^

Retrieves ArrayList of perk's tags.

This is never null and is not cloned.

Tags is an array of strings of blocksize 32.

Usage

Type ArrayList
Getter Yes
Setter No

Enabled ^

Retrieves or sets whether the perk is enabled.

Usage

Type bool
Getter Yes
Setter Yes

External ^

Retrieves or sets whether the perk should call an external function.

Usage

Type bool
Getter Yes
Setter Yes