Raised This Month: $ Target: $400
 0% 

[help] letting 2 plugins interact with each other


Post New Thread Reply   
 
Thread Tools Display Modes
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-28-2012 , 13:00   Re: [help] letting 2 plugins interact with each other
Reply With Quote #11

You will need the function again, but you would use the parameters exactly as in the native. If you don't pass 1 in the end of register_native, then the function should look like:

PHP Code:
public _some_random_native(plugin,params)
{
// And then here get each parameter with get_param(number)
// Like if the native is "some_random_native(id,this_is_two_thousand_lol)"
// Then you should use get_param(1) to get "id" parameter and get_param(2) to get the value of "this_is_two_thousand_lol" parameter

But if you pass 1 in the end of register_native, then you can use directly the parameters as in the native prototype. The same native will look like:

PHP Code:
public _some_random_native(id,this_is_two_thousand_lol)
{
// And here you can directly use "id" and "this_is_two_thousand_lol" as function parameters from the native
// The parameters of this function are exactly the same as the native prototype in the library.
// This method seems to be better, but you may need additional byref conversion if you pass strings (not exactly sure?) with get_param_byref

__________________

Last edited by <VeCo>; 05-28-2012 at 13:02.
<VeCo> is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 13:19   Re: [help] letting 2 plugins interact with each other
Reply With Quote #12

I'm afread I don't understand it,
What should i put in plugin_natives()?
this:
PHP Code:
public plugin_natives ()
{
 
register_native("is_user_rebel""_is_user_rebel",1);
 
register_native("set_user_rebel""_set_user_rebel",1);
 
register_native("remove_user_rebel""_remove_user_rebel",1);
}
// then what do i have to put in the handlers? 
or like this and without the handlers:
PHP Code:
public plugin_natives ()
{
register_native("is_user_rebel"1);
register_native("set_user_rebel"1);
register_native("remove_user_rebel",1);

I hate myself for asking this but could you show me how to do it with this example?
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]
striker07 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-28-2012 , 13:26   Re: [help] letting 2 plugins interact with each other
Reply With Quote #13

The first one.

I really didn't explained it better... maybe someone could tell the things more understandable and correct me if I'm wrong.
__________________
<VeCo> is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 13:40   Re: [help] letting 2 plugins interact with each other
Reply With Quote #14

I only use one parameter and that is the id of the player sended to the handler,
so if I do this for the handlers will it work (and is this what you ment?):
PHP Code:
public _is_user_rebel(plugin,params)
{
return 
is_user_rebel(get_param(1) );
}
 
public 
_set_user_rebel(plugin,params)
{
return 
set_user_rebel(get_param(1) );
}
 
public 
_set_user_rebel(plugin,params)
{
return 
set_user_rebel(get_param(1) );
}
 
public 
_remove_user_rebel(plugin,params)
{
return 
remove_user_rebel(get_param(1) );

if so then is that the same as this ?:
Code:
public _is_user_rebel(id)
{
return is_user_rebel(id);
}
 
 
public _set_user_rebel(id)
{
return is_user_rebel(id) = 1;
}
 
public _remove_user_rebel(id)
{
return is_user_rebel(id) = 0;
}
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]

Last edited by striker07; 05-28-2012 at 13:48.
striker07 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-28-2012 , 13:43   Re: [help] letting 2 plugins interact with each other
Reply With Quote #15

If you want to use the second one, then add ",1" in the end of register_native.
__________________
<VeCo> is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 13:47   Re: [help] letting 2 plugins interact with each other
Reply With Quote #16

ah ok so that second part will do the job as i need it if i use a 1 as third parameter in register_native?
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]
striker07 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-28-2012 , 13:52   Re: [help] letting 2 plugins interact with each other
Reply With Quote #17

Yes, you will use "id" directly.
__________________
<VeCo> is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 14:02   Re: [help] letting 2 plugins interact with each other
Reply With Quote #18

Ok thx, becous (quoted from funcwiki):
Quote:
Originally Posted by amxmodx-funcwiki
When a plugin uses your native (you should distribute a .inc), the handler will be called with two parameters: the calling plugin id, and the number of parameters.

NOTE: Style should always be 0. The "dJeyL" mode value of 1 is deprecated, since it is not properly compatible with any by-reference type.

The advantage to keeping style set to 0 is that it more closely resembles the AMX Mod/X module API.
So sry for asking once more but will this do the exact same thing as the part with a 1 as third parameter(style) in register_native:
PHP Code:
public _is_user_rebel(plugin,params)
{
return 
is_user_rebel(get_param(1) );
}
 
public 
_set_user_rebel(plugin,params)
{
return 
set_user_rebel(get_param(1) );
}
 
public 
_remove_user_rebel(plugin,params)
{
return 
remove_user_rebel(get_param(1) );

with this i mean wil the remove funtion set the result from is_user_rebel native to 0 and the set function setting the result is_user_rebel(id) to 1
Or for that does it have to look like this?:
PHP Code:
public _is_user_rebel(plugin,params)
{
return 
is_user_rebel(get_param(1) );
}
 
public 
_set_user_rebel(plugin,params)
{
return 
is_user_rebel(get_param(1)) = 1;
}
 
public 
_remove_user_rebel(plugin,params)
{
return 
is_user_rebel(get_param(1)) = 0;

__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]

Last edited by striker07; 05-28-2012 at 14:05.
striker07 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-28-2012 , 14:05   Re: [help] letting 2 plugins interact with each other
Reply With Quote #19

Yes, everything other is the same, except using get_param() instead of real parameter names.
__________________
<VeCo> is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 14:07   Re: [help] letting 2 plugins interact with each other
Reply With Quote #20

Ah ok so i should use the second code block,
tyvm veco i will test this out right away.
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]
striker07 is offline
Reply



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 07:47.


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