Skip to content

Latest commit

 

History

History
196 lines (119 loc) · 2.31 KB

utility.md

File metadata and controls

196 lines (119 loc) · 2.31 KB

Utilities

fmt(<string>, <?arguments...>)

Get a formatted string.

a = "Iswenzz";
b = 10;

string = fmt("%s %d", a, b);

Trim(<string>)

Trim a string.

string = trim("    hello world    ");

Ternary(<condition>, <true>, <false>)

Check the condition and return the 1st value if true or the second value if false.

a = Ternary(player.name == "Iswenzz", 1000, 0);

IfUndef(<var>, <default>)

Give a default value if the variable is undefined.

name = IfUndef(player.name, "Unknown player");

GetType(<var>)

Get the type name of a GSC variable.

type = GetType(player.name);

ToString(<var>)

Convert int, float, vector to string.

str = ToString(player.velocity);

ToInt(<var>)

Convert string, float, vector to integer.

i = ToInt("123");

ToFloat(<var>)

Convert string, int, vector to float.

f = ToFloat("1.23");

IsNullOrEmpty(<str>)

Check if a string is undefined or empty.

IsNullOrEmpty(player.name);

IsStringAlpha(<str>)

Check if a string is alphanumeric.

IsStringAlpha("abc123_&");

IsStringFloat(<str>)

Check if a string contains a float.

IsStringFloat("123.123");

IsStringInt(<str>)

Check if a string contains an integer.

IsStringInt("123");

ToRGB(<r>, <g>, <b>)

Normalize RGB vector.

rgb = ToRGB(125, 255, 255);

HexToRGB(<hex>)

Convert a HEX color string to a normalized RGB vector.

rgb = HexToRGB("#AABBCC");
rgb = HexToRGB("AABBCC");

StartsWith(<string>, <value>)

Check if a string starts with a specific value.

StartsWith("hello world", "hello");

EndsWith(<string>, <value>)

Check if a string ends with a specific value.

EndsWith("hello world", "world");

StrJoin(<array>, <separator>)

Join string array with a separator.

str = StrJoin(array, "-");

Replace(<source>, <search>, <replace>)

Replace a string.

str = Replace("SR Speedrun", "Speedrun", "Deathrun");

PathJoin(<paths...>)

Join filepath strings.

path = StrJoin("C:\\home", "cod4", "speedrun");
path = StrJoin("/home", "cod4", "speedrun");