AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   plugin-to-plugin communication (https://forums.alliedmods.net/showthread.php?t=658)

MagicShot 03-30-2004 18:10

Hrm...
 
What kinda things is this usefull for?

BAILOPAN 03-30-2004 18:24

if you have to ask you don't know ;]

<serious> it's useful for calling arbitrary functions that you do not know the name for.

for example, PHP has this ability:
$x = "myfunction"
$x(); //This will call "myfunction" if it exists

same thing in C:

int myfunc(void);

int (*func)(void) = myfunc;
(*func)();

MagicShot 03-30-2004 18:55

?
 
Does the "callfunc_begin" execute the public fuction in the plugin also?

PM 03-31-2004 07:39

Re: ?
 
Quote:

Originally Posted by MagicShot
Does the "callfunc_begin" execute the public fuction in the plugin also?

What? The callfunc_end does the actual execution

MagicShot 03-31-2004 11:58

oh
 
yeah sorry PM.. thats what i meant but when You execute it it will run what evers in that public command?

PM 03-31-2004 12:21

i don't really understand you so i'll make an example :)

plugin1
Code:
// other code (plugin_init etc)... public the_function(paramint, &paramintref, paramstr[]) {    log_amx("the_function called. paramint = %d, paramintref = %d, paramstr = %s", paramint, paramintref, paramstr);    paramintref++;    paramstr[0] = '[';    return 100; } // other code...

plugin2
Code:
// in a function new intVar = 8; new strVar[] = "(:" log_amx("Will call the_function in plugin1.amx; the int param is 4, the intrf Param is 8, the str param is ^"(:^""); callfunc_begin("the_function", "plugin1.amx"); callfunc_push_int(4); callfunc_push_intrf(intVar); callfunc_push_str(strVar); new retVal = callfunc_end(); log_amx("Called it. Return value: %d; the int var is %d and the str var is %s", retVal, intVar, strVar);

The output should be:
Code:

Will call the_function in plugin1.amx; the int param is 4, the intrf Param is 8, the str param is "(:"

the_function called. paramint = 4, paramintref = 8, paramstr = (:

Called it. Return value: 100; the int var is 9 and the str var is [:

Not tested tho :)


All times are GMT -4. The time now is 21:35.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.