Skip to content

Native caller

iAmir edited this page Mar 7, 2020 · 5 revisions
samp.callNative(nativeName, paramTypes, args...)

a function to call samp natives from your JavaScript code.

Usage

samp.callNative('native name here', 'param types (specifiers)', args...);

Examples

samp.on(EVENT_PLAYER_CONNECT, (playerid) => {
    samp.callNative('SendClientMessage', 'iis', playerid, 0xff00ffff, "Welcome to the server player " + playerid);
});
samp.on(EVENT_PLAYER_CONNECT, (playerid) => {
    let name = samp.callNative("GetPlayerName", "iSi", playerid, 24);
    samp.callNative("SendClientMessageToAll", "is", -1, "{006600}[JOIN] {ffffff}" + name + " has joined the server");
});

Specifiers

*Note: lower-case specifiers are used for passing values, in order to call a native with reference parameters, use upper-case specifiers, then they will be returned as return value of your call

Specifiers Info
i, d integer (both do the same thing, both can take unsigned and signed integers)
f float
s string
a array of integers
v array of floats
I, D (Return value) integer
F (Return value) float
S (Return value) string
A (Return value) array of integers
V (Return value) array of floats
Clone this wiki locally