Raised This Month: $ Target: $400
 0% 

Cross-Plugin Communication?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Minimum
Senior Member
Join Date: Jun 2006
Old 11-02-2006 , 18:22   Cross-Plugin Communication?
Reply With Quote #1

I was wondering if a plugin could communicate with another plugin. Like how there could be one base plugin and then smaller components that can be used or not used. The problem is that my main plugin file is getting too large (2826 Lines) so AMXX-Studio is lagging like a madman for no reason I see (My CPU Usage is fine, RAM is fine also). This is mainly because I have a console which displays information to the player. Right Here (on the bottom left) I want to get messages from the smaller plugin over to the main plugin to display in that message console. I have one method that could work but it would involve hitting the MySQL database every .05 seconds.
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 11-02-2006 , 18:27   Re: Cross-Plugin Communication?
Reply With Quote #2

Quote:
Originally Posted by Minimum View Post
I was wondering if a plugin could communicate with another plugin. Like how there could be one base plugin and then smaller components that can be used or not used. The problem is that my main plugin file is getting too large (2826 Lines) so AMXX-Studio is lagging like a madman for no reason I see (My CPU Usage is fine, RAM is fine also). This is mainly because I have a console which displays information to the player. Right Here (on the bottom left) I want to get messages from the smaller plugin over to the main plugin to display in that message console. I have one method that could work but it would involve hitting the MySQL database every .05 seconds.
You should look into dynamic natives (register_native) and plugin API (CreateMultiForward, CreateOneForward, ExecuteForward).
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Nostrodamous
BANNED
Join Date: Oct 2006
Old 11-02-2006 , 18:41   Re: Cross-Plugin Communication?
Reply With Quote #3

yes go read Hawks tutorial on API and dynamic natives (two seperate tutorials) , youll see how it works . (good stuff)
Nostrodamous is offline
Minimum
Senior Member
Join Date: Jun 2006
Old 11-04-2006 , 02:52   Re: Cross-Plugin Communication?
Reply With Quote #4

I tried out the dynamic natives and got this error.

Code:
Natives Called
L 11/03/2006 - 23:59:46: [AMXX] Plugin "zombiemod_test.amxx" failed to load: Module/Library Class "gab_zombie" required for plugin.  Check modules.ini.
zombiemod.amxx -
Code:
public plugin_natives() {     register_library("gab_zombie")     server_print("Natives Called")     register_native("hud_display","hud_print",1) } /*      Hud Write Code */  public hud_print(id,message[]) {     if(id == 0) {         new x, players[32]         get_players(players,x)         for( new i = 0;  i < x; i++ ) {             new playerindex = players[i]             format(hudmsg4[playerindex],127,"%s",hudmsg3[playerindex])             format(hudmsg3[playerindex],127,"%s",hudmsg2[playerindex])             format(hudmsg2[playerindex],127,"%s",hudmsg1[playerindex])             format(hudmsg1[playerindex],127,"%s",message)         }         return PLUGIN_HANDLED     }     format(hudmsg4[id],127,"%s",hudmsg3[id])     format(hudmsg3[id],127,"%s",hudmsg2[id])     format(hudmsg2[id],127,"%s",hudmsg1[id])     format(hudmsg1[id],127,"%s",message)     return PLUGIN_HANDLED }

zombiemod_test.amxx -
Code:
#include <gab_zombie>

gab_zombie.inc -
Code:
/*      Gabion Studios Zombie Mod Include File */  #pragma reqclass "gab_zombie" native hud_display(id,message[])
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-04-2006 , 08:34   Re: Cross-Plugin Communication?
Reply With Quote #5

Quote:
Originally Posted by Nostrodamous View Post
yes go read Hawks tutorial on API and dynamic natives (two seperate tutorials) , youll see how it works . (good stuff)
I love how you repeat everything the person above you said, only in a less incorrect form.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 11-04-2006 , 09:57   Re: Cross-Plugin Communication?
Reply With Quote #6

Code:
#pragma reqlib "gab_zombie"
->

Code:
#pragma reqlib gab_zombie
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Minimum
Senior Member
Join Date: Jun 2006
Old 11-04-2006 , 13:34   Re: Cross-Plugin Communication?
Reply With Quote #7

Well everything else but the actual thing works. Instead of recieving a message it just recieves a blank message. As shown here. Any suggestions?

zombiemod_global.amxx -
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Zombie Mod Includes" #define VERSION "1.0 Final" #define AUTHOR "Minimum" // Hud Variables new hudmsg1[64][128]            // Hud Row 1 Information new hudmsg2[64][128]            // Hud Row 2 Information new hudmsg3[64][128]            // Hud Row 3 Information new hudmsg4[64][128]            // Hud Row 4 Information public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         // Cvars     register_cvar("zombie_statushud","Zombie Mod Console - 0.1.2 Final")         // Tasks     set_task(0.5,"zombiemodconsole",0,"",0,"b")     // Zombie Mod Console } /*      Register Fake Natives */  public plugin_natives() {     register_library("gab_zombie")     register_native("hud_display","hud_redir",1)     server_print("Natives Called") } /*      Client Join Server Code */  public client_putinserver(id) {     format(hudmsg1[id],127,"Welcome to Gabion Studios Undead Zone.")     format(hudmsg2[id],127,"Say /motd for more info on this plugin.")     set_task(1.0,"userdrop",id)     return PLUGIN_HANDLED } /*      Client Disconnect Code (Since client_disconnect doesn't seem to work) */  public userdrop(id) {     if(!is_user_connected(id)) {         format(hudmsg1[id],127," ")         format(hudmsg2[id],127," ")         format(hudmsg3[id],127," ")         format(hudmsg4[id],127," ")         return PLUGIN_HANDLED     }     set_task(1.0,"userdrop",id)     return PLUGIN_HANDLED } /*      Hud Write Code */  public hud_print(id,message[]) {     if(id == 0) {         new x, players[32]         get_players(players,x)         for( new i = 0;  i < x; i++ ) {             new playerindex = players[i]             format(hudmsg4[playerindex],127,"%s",hudmsg3[playerindex])             format(hudmsg3[playerindex],127,"%s",hudmsg2[playerindex])             format(hudmsg2[playerindex],127,"%s",hudmsg1[playerindex])             format(hudmsg1[playerindex],127,"%s",message)         }         return PLUGIN_HANDLED     }     format(hudmsg4[id],127,"%s",hudmsg3[id])     format(hudmsg3[id],127,"%s",hudmsg2[id])     format(hudmsg2[id],127,"%s",hudmsg1[id])     format(hudmsg1[id],127,"%s",message)     return PLUGIN_HANDLED } /*      Hud Native Redirect */  public hud_redir(id,message[]) {     hud_print(id,message)     return PLUGIN_HANDLED } /*      Hud Console Code */  public zombiemodconsole(id) {     new authid[32], num, players[32]     get_players(players,num)     for( new i = 0;  i < num; i++ ) {         get_user_authid( players[i], authid, 31)         if(equali(authid,"BOT") || equali(authid,"UNKNOWN")) return PLUGIN_HANDLED         // Status Console         new sc_outputstat[128], playerindex         get_user_authid( players[i], authid, 31)         get_cvar_string("zombie_statushud",sc_outputstat,127)         set_hudmessage(0, 200, 0, 0.0, 0.65,0,0.0,99.9,0.0,0.0,2)         playerindex = players[i]         show_hudmessage( players[i], " %s ^n --- ^n %s ^n %s ^n %s ^n %s",sc_outputstat,hudmsg1[playerindex],hudmsg2[playerindex],hudmsg3[playerindex],hudmsg4[playerindex])     }     return PLUGIN_HANDLED   }

zombiemod.amxx (One hud_display example) -
Code:
format(hudformat,127,"You have gained a level.")     hud_display(id,hudformat)

gab_zombie.inc -
Code:
/*      Gabion Studios Zombie Mod Include File */  #pragma reqlib gab_zombie native hud_display(id,message[]);
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 11-04-2006 , 13:57   Re: Cross-Plugin Communication?
Reply With Quote #8

Inside hud_redir, you need to run param_convert(message), THEN pass it to hud_display..
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Minimum
Senior Member
Join Date: Jun 2006
Old 11-04-2006 , 14:16   Re: Cross-Plugin Communication?
Reply With Quote #9

Hud_redir is hud_display. I tried to put it in hud_redir and it gave me an argument type mismatch. Message is a string just so you know.
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 11-04-2006 , 14:18   Re: Cross-Plugin Communication?
Reply With Quote #10

Quote:
Originally Posted by Minimum View Post
Hud_redir is hud_display. I tried to put it in hud_redir and it gave me an argument type mismatch. Message is a string just so you know.
What? Why don't you just use style 0 then, and get_string?
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 04:57.


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