AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Call command from another plugin (https://forums.alliedmods.net/showthread.php?t=195076)

vitorrossi 09-03-2012 06:21

Call command from another plugin
 
Hey guys! I am wrinting a plugin, and in it I wanted to call a command "give_item" from a different plugin, frostnade.amxx. I tried looking through a few commands such as callfunc_being but I couldn't figure out. Could someone point me in the right direction? Thank you

Alka 09-03-2012 06:35

Re: Call command from another plugin
 
You can't call an amxmodx native like give_item() which is included in fun module, useless? You must call a custom public function. Lets say you have the following public function in frostnade.amxx plugin
PHP Code:

public give_frostnade(id)
{
    
//...code to give frostnade and other checks / sprites / messages / etc...


then you can call it from another plugin like this
PHP Code:

callfunc_begin("give_frostnade""frostnade.amxx"); // function name "x" from plugin "y"
callfunc_push_int(id); // first parameter
callfunc_end(); 


lucas_7_94 09-03-2012 08:59

Re: Call command from another plugin
 
I dont want to do a new thread to post , i want to understand this.

Alka if the public has more than 1 parameter.

Ex:

Code:
public SetvGlow( id , v_model[ ] , glows[ 3 ]) {           // <somethinghere> }

in another plugin i have

Code:
callfunc_begin( "SetvGlow", "something.amxx" ) callfunc_push_int( id ) callfunc_push_str( model ) callfunc_push_array( vGlow, sizeof vGlow ) callfunc_end()
Will works , or had another method to do that ?

Thanks,

Alka 09-03-2012 09:33

Re: Call command from another plugin
 
Well yeah, that's how it should look / works. :-)

vitorrossi 09-03-2012 15:30

Re: Call command from another plugin
 
Thanks!

ConnorMcLeod 09-03-2012 15:45

Re: Call command from another plugin
 
I think callfunc_begin_i is faster than callfunc_begin, but i may be wrong.

PHP Code:

new g_iSomePluginIndexg_iSetvGlowFunctionIndex

public plugin_cfg()
{
    
g_iSomePluginIndex is_plugin_loaded("SomeThing Name")
    if( 
g_iSomePluginIndex )
    {
        
g_iSetvGlowFunctionIndex get_func_id("SetvGlow"g_iSomePluginIndex)
    }
}

Call_SetvGlow(idmodel[], vGlow[3])
{
    if( 
g_iSetvGlowFunctionIndex )
    {
        
callfunc_begin_i(g_iSetvGlowFunctionIndexg_iSomePluginIndex)
        
callfunc_push_intid )
        
callfunc_push_strmodel )
        
callfunc_push_arrayvGlowsizeof vGlow )
        
callfunc_end()
    }



About frostnade, i think in last version there is a native that lets you give a nade.
Edit : Nope :/

Alka 09-03-2012 15:53

Re: Call command from another plugin
 
@Connor - g_iNoSilSetModel ? Shouldn't that be g_iSetvGlowFunctionIndex? O.o

lucas_7_94 09-03-2012 20:04

Re: Call command from another plugin
 
Wow , Really thanks ConnorMcLeod & Alka :)

Only last question , in callfunc_begin_i , second parameter is the number with the server load the plugin ? or i'm wrong ?

ConnorMcLeod 09-04-2012 01:37

Re: Call command from another plugin
 
Quote:

Originally Posted by Alka (Post 1790609)
@Connor - g_iNoSilSetModel ? Shouldn't that be g_iSetvGlowFunctionIndex? O.o

What ???


Quote:

Originally Posted by lucas_7_94 (Post 1790760)
Wow , Really thanks ConnorMcLeod & Alka :)

Only last question , in callfunc_begin_i , second parameter is the number with the server load the plugin ? or i'm wrong ?

The plugin index, it is the value returned bu register_plugin and is_plugin_loaded.
Basically you pass function index and plugin index.

Alka 09-04-2012 07:10

Re: Call command from another plugin
 
@Connor
Code:

Last edited by ConnorMcLeod; Today at 08:36 AM.
FAIL!

@lucas - No problem. :-)


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

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