Raised This Month: $ Target: $400
 0% 

Call command from another plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 09-03-2012 , 06:21   Call command from another plugin
Reply With Quote #1

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
vitorrossi is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-03-2012 , 06:35   Re: Call command from another plugin
Reply With Quote #2

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(); 
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 09-03-2012 at 06:35.
Alka is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-03-2012 , 08:59   Re: Call command from another plugin
Reply With Quote #3

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,
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 09-03-2012 at 09:26.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-03-2012 , 09:33   Re: Call command from another plugin
Reply With Quote #4

Well yeah, that's how it should look / works. :-)
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 09-03-2012 at 09:34.
Alka is offline
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 09-03-2012 , 15:30   Re: Call command from another plugin
Reply With Quote #5

Thanks!
vitorrossi is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-03-2012 , 15:45   Re: Call command from another plugin
Reply With Quote #6

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 :/
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-04-2012 at 01:36.
ConnorMcLeod is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-03-2012 , 15:53   Re: Call command from another plugin
Reply With Quote #7

@Connor - g_iNoSilSetModel ? Shouldn't that be g_iSetvGlowFunctionIndex? O.o
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 09-03-2012 at 15:57.
Alka is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-03-2012 , 20:04   Re: Call command from another plugin
Reply With Quote #8

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 ?
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-04-2012 , 01:37   Re: Call command from another plugin
Reply With Quote #9

Quote:
Originally Posted by Alka View Post
@Connor - g_iNoSilSetModel ? Shouldn't that be g_iSetvGlowFunctionIndex? O.o
What ???


Quote:
Originally Posted by lucas_7_94 View Post
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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-04-2012 , 07:10   Re: Call command from another plugin
Reply With Quote #10

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

@lucas - No problem. :-)
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 09-04-2012 at 07:14.
Alka is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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