AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Q:How to run commands from one plugin out of another plugin? (https://forums.alliedmods.net/showthread.php?t=1166)

Johnny got his gun 04-18-2004 17:01

If you want to run functions residing in other plugins:

Code:
/* 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);

IceMouse[WrG] 04-18-2004 17:50

It would be nice to note that (I'm pretty sure) you must push the values BEFORE calling the function

AssKicR 04-18-2004 18:42

Jonny u forgot

Code:
/* Make the actual call. * Return value of the function called. */ native callfunc_end();

IceMouse[WrG] 04-18-2004 18:58

Alright.. Then you push the vars inbetween callfunc_begin() and callfunc_end()

RedBaron 04-18-2004 20:39

Okay guys,

so, how would the code look like with

bbmonster_spawn agrunt RedBaron

green = plugincommand
blue = monstername
red = playername

but the monster- and playername should be variable!?!?!?

P.S.: If someone wants to see how the "advanced" AntiCampingplugin works, just give me a PM!!! :wink: 8)

IceMouse[WrG] 04-18-2004 20:45

Well since Zor is so picky:
Code:
new playername[33]; get_user_name(id,playername,32); new monstername[33]; switch(random_num(1,2)) {     case 1: strcpy(monstername,"agrunt",33);     case 2: strcpy(monstername,"hassassin",33); } server_cmd("bbmonster_spawn %s %s",monstername,playername);
(Don't rely on those being correct functions)


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

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