Skip to content

utils

Note

Most of the functions here require SCRIPTS > General > Allow insecure to be enabled.

random_int

random_int(min: number, max: number) -> number

Returns a random integer number within the given boundaries.

Parameters

Name Type Description
min number Minimal value
max number Maximal value

Usage

local rnd = utils.random_int(0, 100);

random_float

random_float(min: number, max: number) -> number

Returns a random float number with the given boundaries.

Parameters

Name Type Description
min number Minimal value
max number Maximal value

Usage

local rnd = utils.random_float(0.01, 99.9);

new_timer

new_timer(delay: number, fn: ()) -> timer

Creates a new timer instance.

Parameters

Name Type Description
delay number Delay between timer calls, in ms
fn function() Timer callback

Usage

local timer = utils.new_timer(100, function()
    print('This will be printed every 100ms');
end);

run_delayed

run_delayed(delay: number, fn: ()))

Runs a function after a set delay.

Parameters

Name Type Description
delay number Call delay
fn function() Callback

Usage

utils.run_delayed(100, function()
    print('This will be printed once after 100ms');
end);

json_encode

json_encode(data: table) -> string

Encodes a given lua table to a json string.

Parameters

Name Type Description
data table Lua table

Usage

local table = 
{
    value = 1,
    color = "pink"
};

local json_string = utils.json_encode(table);

json_decode

json_decode(data: string) -> table

Decodes a given json string to a lua table.

Parameters

Name Type Description
data string JSON formated string

Usage

local json_data = 
[[
{
  "value": 1,
  "color": "pink"
}
]];

local json_decoded = utils.json_decode(json_data);

find_interface

find_interface(module: string, interface: string) -> number

Returns the interface address or nil on failure.

Parameters

Name Type Description
module string Target module
interface string Interface name

Usage

local client_ptr = utils.find_interface('client.dll', 'VClient018');

find_pattern

find_pattern(module: string, pattern: string) -> number

Returns the pattern address or nil on failure.

Parameters

Name Type Description
module string Target module
pattern string Byte pattern to scan

Additional information

Pattern may contain special indicators on which address will be operated while searching. This includes automatic relative call follow, offset, dereference, etc.

  • [ - start dereference or follow point.
  • ] - end dereference or follow point. Note, that the max size is 4 bytes.
  • * - indicates that next dereference/follow point MUST be a follow point. Only may be before [!
  • + - add offset to an address. Decimal number.
  • - - subtract offset from an address. Decimal number.
  • ? - wildcard. A byte might be anything on this place.

Warning

If you do not know what "dereferencing" or "relative call" means, please avoid putting indicators mindlessly. This will only cause the game to crash.

Usage

-- simple search
local addr = utils.find_pattern('client.dll', 'DE AD BE EF');

-- add offset to an address
local addr = utils.find_pattern('client.dll', 'DE AD BE EF + 5');

-- dereference a value
local addr = utils.find_pattern('client.dll', 'DE AD BE EF [ ? ? ? ? ] 0B AD C0 DE');

-- follow a relative call
local addr = utils.find_pattern('client.dll', 'DE AD BE EF *[ ? ? ? ? ] 0B AD C0 DE');

-- double dereference, adds 1 to first dereferenced value
local addr = utils.find_pattern('client.dll', 'DE AD BE EF [ [ ? ? ? ? ] + 1 ] 0B AD C0 DE');

flags

flags(flag: number, ...) -> number

Combines numbers with the bitwise OR operator.

Parameters

Name Type Description
flag number... Flags to combine

Usage

utils.flags(render.font_flag_outline, render.font_flag_shadow);

http_get

http_get(url: string, headers: string, fn: (string))

Deprecated

This function is deprecated and will be removed in future updates. Use net.http_get instead.

Performs a GET request to the given url.

Parameters

Name Type Description
url string Request URL
headers string Headers. Empty string will not add any headers to the request
fn function(string) Result callback

Usage

utils.http_get('https://pastebin.com/raw/FT1aRqq8', 'Accept: */*', function(response)
    print(response);
end);

http_post

http_post(url: string, headers: string, body: string, fn: (string))

Deprecated

This function is deprecated and will be removed in future updates. Use net.http_post instead.

Performs a POST request to the given url.

Parameters

Name Type Description
url string Request URL
headers string Headers. Empty string will not add any headers to the request
body string Request body
fn function(string) Result callback

Usage

utils.http_post(
  'https://reqbin.com/echo/post/json', 
  'Content-Type: application/json', 
  '{"id": 12345}', 
  function(response)
    print(response);
  end
);

set_clan_tag

set_clan_tag(tag: string)

Sets the given clantag.

Parameters

Name Type Description
tag string Clantag to set

Usage

utils.set_clan_tag('ev0lve > all');

world_to_screen

world_to_screen(x: number, y: number, z: number) -> number, number

Gets 2D coordinates from 3D coordinates or nil on failure.

Parameters

Name Type Description
x number X position in the world space
y number Y position in the world space
z number Z position in the world space

Usage

local x, y = utils.world_to_screen(local_player:get_hitbox_position(0));

get_unix_time

get_unix_time() -> number

Returns current unix timestamp.

Usage

utils.get_unix_time();