[Include] introspect.inc - Run simple Pawn code while the server is running!
#1

This will allow you to modify variables and run functions while the server is running. The variables/functions do not need to be public!

For example, you can create a command and do things like /exec MyFunction(123, 456.789, "hello").

Example command (untested):
pawn Код:
#include <zcmd>
#define AMX_NAME "my_gamemode.amx"
#include <introspect>

COMMAND:exec(playerid, params[]) {
    if (!IsPlayerAdmin(playerid)) {
        return 0;
    }
   
    new error[128];
   
    if (RunSimpleStatement(params, error)) {
        SendClientMessage(playerid, 0x00CC00FF, "Success!");
    } else {
        format(error, sizeof(error), "Error: %s", error);
       
        SendClientMessage(playerid, 0xCC0000FF, msg);
    }
   
    return 1;
}
Beware:
  • If a variable/function wants a float value, you must always put numbers like 1.0, and never just 1.
  • You can only put simple values. You can't put variables in function calls (at the moment).
  • Always provide the right number of arguments to a function.
  • If you assign a string value to an int/float variable, you're gonna have a bad time.
TODO:
https://github.com/oscar-broman/samp-introspect/issues

GitHub: https://github.com/oscar-broman/samp-introspect
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)