[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
#2

omg this is awesome !
Reply
#3

I had something like this in mind and now it got released
Reply
#4

This looks really nifty, basically you could run whole an admin system with this without pre-scripting something
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
Nice, good luck writing a more advanced parser for this.
I won't go very far with it. When you can use variables/arrays both in assignments and function calls I'll be satisfied.

Update
Native functions have been added. You can now call any native function from RunSimpleStatement.
Reply
#6

Sure!
Reply
#7

Nice, looks promising. I'll start working on array dereferencing and return values.
Reply
#8

Awesome, I'll definitely use this!
Reply
#9

Added support for one-dimensional arrays and reference variables.

Functions that use &args or ... (variadic), such as printf, require the use of variable references instead of just passing the values.

Instead of doing this:
/exec printf("one two %d", 345)
Do this:
/exec printf("one two %d", &345)

As for arrays, you can now do this:
/exec g_SomeArray[5] = 123.345

Multi-dimensional arrays are not yet supported.
Reply
#10

Whoa, nice!

I'm working on a re-write of the part that loads debug information and provides information about variables/functions. I'll push it to GitHub as soon as it can do everything the current code does.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)