introspect.inc - Run simple Pawn code while the server is running! -
Slice - 19.08.2013
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
Re: introspect.inc - Run simple Pawn code while the server is running! -
theYiin - 19.08.2013
omg this is awesome !
AW: introspect.inc - Run simple Pawn code while the server is running! -
Mellnik - 19.08.2013
I had something like this in mind and now it got released
Re: introspect.inc - Run simple Pawn code while the server is running! -
Jochemd - 19.08.2013
This looks really nifty, basically you could run whole an admin system with this without pre-scripting something
Re: introspect.inc - Run simple Pawn code while the server is running! -
Slice - 19.08.2013
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.
Re: introspect.inc - Run simple Pawn code while the server is running! -
Slice - 19.08.2013
Sure!
Re: introspect.inc - Run simple Pawn code while the server is running! -
Slice - 19.08.2013
Nice, looks promising.
I'll start working on array dereferencing and return values.
Re: introspect.inc - Run simple Pawn code while the server is running! -
Hiddos - 19.08.2013
Awesome, I'll definitely use this!
Re: introspect.inc - Run simple Pawn code while the server is running! -
Slice - 19.08.2013
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.
Re: introspect.inc - Run simple Pawn code while the server is running! -
Slice - 22.08.2013
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.