Raised This Month: $ Target: $400
 0% 

[help] letting 2 plugins interact with each other


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-01-2012 , 10:03   [help] letting 2 plugins interact with each other
Reply With Quote #1

I just made this include, could anyone tell me if this is correct for what i want to do?


the point of the include is to remember when a first plugin has done something that needs to enable an action inside another plugin. So that they can work/interact on each other, will this work?


PHP Code:
 
#if defined _jbrebel_included
#endinput
#endif
#define _jbrebel_included
 
/**
* Returns whether a player is a rebel or not.
*
* @param id Player index.
* @return True if he is, false otherwise.
*/
native is_user_rebel(id)
/**
* Set's a players status to rebel.
*
* @param id Player index.
* @return True on success, false otherwise.
*/
native set_user_rebel(id)
/**
* Removes a player's rebelstatus.
*
* @param id Player index.
* @return True on success, false otherwise.
*/
native remove_user_rebel(id

Last edited by striker07; 05-01-2012 at 10:03.
striker07 is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 10:58   Re: [help] letting 2 plugins interact with each other
Reply With Quote #2

I must be overseeing something becous this is not working,
when I started up my server with the 2 plugins that use this include it showed me this error:

Code:
L 05/28/2012 - 16:55:07: [AMXX] Plugin "walkguard.amxx" failed to load: Plugin uses an unknown function (name "set_user_rebel") - check your modules.ini.
L 05/28/2012 - 16:55:07: [AMXX] Plugin "jailbreak-the-siege.amxx" failed to load: Plugin uses an unknown function (name "is_user_rebel") - check your modules.ini.
Can some1 give me a lil explanation on how to do this pls?
__________________

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 , 11:00   Re: [help] letting 2 plugins interact with each other
Reply With Quote #3

Did you registered the library and those natives in plugin_natives() in the main plugin?
__________________
<VeCo> is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 11:16   Re: [help] letting 2 plugins interact with each other
Reply With Quote #4

No, I added this now but i need some help, this is the first time I attempt something like this:
PHP Code:
public plugin_natives ()
{
 
register_native("is_user_rebel""_is_user_rebel");
 
register_native("set_user_rebel""_set_user_rebel");
 
register_native("remove_user_rebel""_remove_user_rebel");
}
public 
_is_user_rebel(id)
{
 if(
is_user_rebel(id) )
  return 
1;
 else
  return 
0;
}
public 
_set_user_rebel(id)
{
 if(!
is_user_rebel(id) )
 {
  
//No clue what to put here, just some bold guesses
  
return 1;
 }
}
public 
_remove_user_rebel(id)
{
 
// need some help

When this piece of code is finished then i should put that in both plugin that use this include right?
what do you mean with the library?
__________________

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

Last edited by striker07; 05-28-2012 at 11:19.
striker07 is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-28-2012 , 11:30   Re: [help] letting 2 plugins interact with each other
Reply With Quote #5

Quote:
Originally Posted by striker07 View Post
if(is_user_rebel(id) )
return 1;
else
return 0;
Code:
(is_user_rebel(id) ) ? return 1 : return 0
Both work....that is just pretty. ;)
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-28-2012 , 11:39   Re: [help] letting 2 plugins interact with each other
Reply With Quote #6

PHP Code:
public _is_user_rebel(id)
{
    return 
is_user_rebel(id);

Or if is_user_rebel returns values != 0/1

PHP Code:
public _is_user_rebel(id)
{
    return !!
is_user_rebel(id);

__________________

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

If you don't use 1 in the end of register_native, then the native function should look like this:

PHP Code:
public _is_user_rebel(plugin,params)
{
return 
/*...*/is_user_rebel(get_param(1))

For the library I meant using register_library.
__________________

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

Quote:
Originally Posted by Bugsy View Post
PHP Code:
public _is_user_rebel(id)
{
return 
is_user_rebel(id);

Or if is_user_rebel returns values != 0/1
PHP Code:
public _is_user_rebel(id)
{
return !!
is_user_rebel(id);

hehe bugsy you expert, i see you like making you're code hard to read :p

Quote:
Originally Posted by <VeCo> View Post
If you don't use 1 in the end of register_native, then the native function should look like this:

PHP Code:
public _is_user_rebel(plugin,params)
{
return 
/*...*/is_user_rebel(get_param(1))

For the library I meant using register_library.
I'm confused, are the first 2 (_is_user_rebel & _set_user_rebel ) correct the way i did it?

and how about the _remove_user_rebel, will this do it:
PHP Code:
public _remove_user_rebel(id)
{
 if( 
is_user_rebel(id) )
  return 
0;
// Or just this, if it's possible:
 
return is_user_rebel(id) = 0;

for the libraby: it doesnt use a dictionary, its worked in the plugin itself and for walkguard i adjusted the existing library
__________________

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 , 12:41   Re: [help] letting 2 plugins interact with each other
Reply With Quote #9

Add ",1" in the end of register_native if you want to use the nativе parameters directly.
__________________
<VeCo> is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 05-28-2012 , 12:53   Re: [help] letting 2 plugins interact with each other
Reply With Quote #10

Quote:
Originally Posted by <VeCo> View Post
Add ",1" in the end of register_native if you want to use the nativе parameters directly.
So then i dont need the public functions linked to the natives?
but then will the game know that the remove function removes the rebel state( is_user_rebel(id) )?
__________________

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