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)

ann0yanc3 03-30-2004 01:18

plugin-to-plugin communication
 
to what extent can plugins communicate with one another?

Johnny got his gun 03-30-2004 01:20

xvars, cvars, vault, files, sql, tasks, ...

But to be honest; why do you need interplugin communication? I have made a lot of plugins and almost never really needed that.

KiN | SuicideDog 03-30-2004 03:23

I can see that .. I'm thinking of redoing next map.. and map chooser so they track the last 5 maps.. I would like to share vars between them.

PM 03-30-2004 05:25

you can also call a public function in an another plugin using the callfunc_* natives. Check the amxmodx.inc file for details

MagicShot 03-30-2004 12:04

hmm
 
Quote:

Originally Posted by PM
you can also call a public function in an another plugin using the callfunc_* natives. Check the amxmodx.inc file for details

Quote:

/* Call a function in this / an another plugin by name.
* Parameters:
* plugin - plugin name; if "", the caller plugin is used.
* If specified, it has to be the exact name (for example stats.amx)
* func - function name
* Return value:
* 1 - Success
* 0 - Runtime error
* -1 - Plugin not found
* -2 - Function not found */
native callfunc_begin(const plugin[]="", const func[]);


/* Push a parameter (integer, string, float) */
native callfunc_push_int(value);
native callfunc_push_str(value[]);
native callfunc_push_float(Float: value);
native callfunc_push_intrf(&value);
native callfunc_push_floatrf(& Float: value);

/* Make the actual call.
* Return value of the function called. */
native callfunc_end();
Do all three of those need to be used when calling a pubic?

when

PM 03-30-2004 12:20

hmm lol the function prototype actually is
Code:
native callfunc_begin(const func[], const plugin[]="");
looks like we have messed it up in the include file

anyways, here is an example:
Code:
callfunc_begin("my_function", "theplugin.amx"); callfunc_push_int(4); callfunc_push_str("Hello"); callfunc_push_float(myfloatvalue); new returnValue = callfunc_end();

this will call the public function my_function in the plugin theplugin.amx, the first parameter will be 4, the second parameter will be "Hello", the third parameter will be the value of myfloatvalue variable / constant / whatever. In returnValue, the return value will be stored ;]

callfunc_push_int: push the value of the integer
used with normal parameters
callfunc_push_intrf: push the reference to the variable
used with &prm parameters
callfunc_push_float: push the value of the float
used with Float:prm parameters
callfunc_push_floatrf: push the reference to the float variable
used with &Float:prm parameters
callfunc_push_str: push a string (an array)
used with prm[] / const prm[] parameters

A native like
callfunc(func, plugin, param1, param2, param2);
is not possible / very very hard to implement.

]FUSION[ Gray Death 03-30-2004 12:34

Is there anything bad, to use a couple of cvars for communication? Especially slow, limited, etc...?

MagicShot 03-30-2004 18:02

Hrm
 
What does it mean to "push"?

AssKicR 03-30-2004 18:05

snd info over to that plugin

BAILOPAN 03-30-2004 18:05

push and pop refer to stacks of data such as an array or list.

Push adds an item to the tail/end of a list. PM's callfunc works by pushing values onto a list of parameters and then calling the actual function once you end it. much like message_begin ... write_x.... message_end


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

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