Registered Functions

Dedmen Miller edited this page Nov 18, 2017 · 8 revisions

RSQF

RSQF or Registered SQFunction is a way to avoid callExtensions. You can register new "script commands" with your very own C++ implementation!

How's it done

You can register nular, unary and binary commands which are also able to return something. It is required to register them during pre_start, so that scripts compiling within the game can make use of them. Trying to register outside of pre_start will cause an exception to be thrown.

Examples

Nular:

intercept::types::registered_sqf_function _nular_func_example; //Return value of register_sqf_function has to be stored for the lifetime of the registered function

game_value test_nular_fnc () {
    return "this is a test";
}

void intercept::pre_start() {
    _nular_func_example = intercept::client::host::register_sqf_function(
        "testnular",
        "Description",
        userFunctionWrapper<test_nular_fnc>,
        intercept::types::GameDataType::STRING); //Return type
}

Unary:

intercept::types::registered_sqf_function _unary_func_example; //Return value of register_sqf_function has to be stored for the lifetime of the registered function

game_value test_unary_fnc (game_value_parameter right_arg) {
    return "this is a test";
}

void intercept::pre_start() {
    _unary_func_example = intercept::client::host::register_sqf_function(
        "testunary",
        "Description",
        userFunctionWrapper<test_unary_fnc>,
        intercept::types::GameDataType::STRING, //Return type
        intercept::types::GameDataType::STRING); //Right Argument Type
}

Binary:

intercept::types::registered_sqf_function _binary_func_example; //Return value of register_sqf_function has to be stored for the lifetime of the registered function

game_value test_binary_fnc (game_value_parameter left_arg, game_value_parameter right_arg) {
    return "this is a test";
}

void intercept::pre_start() {
    _binary_func_example = intercept::client::host::register_sqf_function(
        "testbinary",
        "Description",
        userFunctionWrapper<test_binary_fnc>,
        intercept::types::GameDataType::STRING, //Return type
        intercept::types::GameDataType::STRING, //Left Argument Type
        intercept::types::GameDataType::STRING); //Right Argument Type
}

Note:

  • If you multiple RSQF then you can register them all in the same pre_start.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.