CallLocalFunction
From SA-MP Wiki
Contents |
CallLocalFunction
Calls a public function from within the same virtual engine, which is basically the GM or FS that the public is located in.
Important note: This calls the public function from its own script loaded into the server.
(const format[], {Float,_}:...)
| function[] | Public functions' name. |
| format[] | Tag/format of each variable |
| {Float,_}:... | 'Indefinite' number of arguments of any tag |
| Returns | This returns the value that the only public function returned. |
Format Strings
| Placeholder | Meaning |
|---|---|
| c | Inserts a single character. |
| d, i | Inserts an integer (whole) number |
| x | Inserts a number in hexadecimal notation. |
| f | Inserts a floating point number. |
| s | Inserts a string. |
The values for the placeholders follow in the exact same order as parameters in the call.
A non-working example.
/* File1 */ forward callMe(const string[]); public callMe(const string[]) { printf("callMe> %s", string); return 86; } /* File2 */ CallLocalFunction("callMe", "s", "OHAI THAR BAGPUSS!!11"); /* This one wouldn't work because the public 'callMe' is not defined in File2, you would need to use CallRemoteFunction for that. */
A working example.
/* File1 */ forward callMe(const string[]); public callMe(const string[]) { printf("callMe> %s", string); return 86; } CallRemoteFunction("callMe", "s", "OHAI THAR BAGPUSS!!11"); /* This one would work because this function is defined in the same file as this callback is. */
Related Functions
The following functions might be useful as well, as they're related to this function in one way or another.
- CallRemoteFunction: Does the same, calls every public function with that name.
