Skip to content

Built-In Functions

Built-In Functions

lethal.landing comes with some default functions to speed the development of add-ons up. Using a proper IDE which is suitable for web development is recommended but not required.

Read/Write Settings

// Reads an addon setting where:
// $name is the name of the setting of type String
// $plugin is your addons name and should be equal to the addons folder name; type String
// returns whatever value $value has
rPluginSetting($name, $plugin);
// Writes an addon setting where:
// $name is the name of the setting of type String
// $value the value the type can be anything
// $plugin is your addons name and should be equal to the addons folder name; type String

wPluginSetting($name, $value, $plugin);

Auth Functions

// Checks whether or not the current user is logged in.
// If not the execution of code stops and the user is redirected to the root url of lethal.landing.
loggedIn();
// Checks whether or not the current user is logged in.
// Returns boolean true if logged in, false otherwise.
isLoggedIn();
// Checks whether or not the current logged in user is added in the config.php as an admin.
// Returns boolean true if the user is admin, false otherwise.
isAdmin();
// Checks whether or not the current logged in user is added in the config.php as an admin.
// If not the execution of code stops and the user is redirected to the root url of lethal.landing.
hasAccess();

User Functions

// Returns the current logged in user as object.
// Fails if not logged in so make sure to execute 'loggedIn()' before!
currentUser();
// Returns the user object for given Steam ID.
// Will return empty object if it doesnt exist.
getUserBySteam($steam);
// Checks if the user for given Steam ID exists, otherwise creates the user.
// $token is your SteamAPI token. You can use the $token globally.
findOrNewUser($steam, $token);

Miscellaneous

// Converts a hex color to rgba.
// Color expects a string with the hex color.
// $opacity is an optional float between 0 - 1
hex2rgba($color, $opacity = false);
// Gets the absolute url for the root of your website like 'https://example.com/'
// Note: absURL() returns a trailing slash!
absURL();

Tip!

To get the accent color you've set in the appearance settings you can use rSetting('accent_color'), which will return the hex value of it!