Skip to content

Add GetSkinProperty ACS function

Trillster requested to merge topic/default/getskinproperty into branch/default

After chatting with Kaminsky and Barrels O' Fun, I decided to create this new MR with solely an alternate implementation of the GetSkinInfo function implemented in !142, now called GetSkinProperty. This MR additionally updates GetPlayerSkin to return a skin index instead of a string and implements modder-defined skin properties. This new interface for GetSkinProperty is intended to be simpler for modders to use, having the same usage whether accessing internal properties or modder-defined properties. The signature of GetSkinProperty is as follows:

mixed GetSkinProperty ( int skinIndex, str propertyKey, bool checkType = false, int index = 0 )

Because this function can return mixed types, modders are intended to use the checkType parameter which modifies the function's behavior from returning the value of a property to returning the type of its value. The type values it can return are listed below. If SPROP_TYPE_UNKNOWN is returned, this indicates that the property does not exist on the skin.

#define SPROP_TYPE_UNKNOWN 0
#define SPROP_TYPE_INT 1
#define SPROP_TYPE_BOOL 2
#define SPROP_TYPE_FLOAT 3
#define SPROP_TYPE_STRING 4

Modder-defined properties are allowed to take the form of a list by using the syntax below:

{
  name = "Skin"
  sprite = PLY1
  customproperty = "test", 5
}

Modders can use the index parameter of GetSkinProperty to access these properties as well as their type.

GetSkinProperty(0, "customproperty", true, 0); // returns SPROP_TYPE_STRING
GetSkinProperty(0, "customproperty", true, 1); // returns SPROP_TYPE_INT
Edited by Trillster

Merge request reports

Loading