AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Cross-Plugin Communication? (https://forums.alliedmods.net/showthread.php?t=46782)

Minimum 11-02-2006 18:22

Cross-Plugin Communication?
 
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.

Hawk552 11-02-2006 18:27

Re: Cross-Plugin Communication?
 
Quote:

Originally Posted by Minimum (Post 398825)
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).

Nostrodamous 11-02-2006 18:41

Re: Cross-Plugin Communication?
 
yes go read Hawks tutorial on API and dynamic natives (two seperate tutorials) , youll see how it works . (good stuff):up:

Minimum 11-04-2006 02:52

Re: Cross-Plugin Communication?
 
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[])

Zenith77 11-04-2006 08:34

Re: Cross-Plugin Communication?
 
Quote:

Originally Posted by Nostrodamous (Post 398839)
yes go read Hawks tutorial on API and dynamic natives (two seperate tutorials) , youll see how it works . (good stuff):up:

I love how you repeat everything the person above you said, only in a less incorrect form.

Hawk552 11-04-2006 09:57

Re: Cross-Plugin Communication?
 
Code:

#pragma reqlib "gab_zombie"
->

Code:

#pragma reqlib gab_zombie

Minimum 11-04-2006 13:34

Re: Cross-Plugin Communication?
 
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[]);

Hawk552 11-04-2006 13:57

Re: Cross-Plugin Communication?
 
Inside hud_redir, you need to run param_convert(message), THEN pass it to hud_display..

Minimum 11-04-2006 14:16

Re: Cross-Plugin Communication?
 
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.

Hawk552 11-04-2006 14:18

Re: Cross-Plugin Communication?
 
Quote:

Originally Posted by Minimum (Post 399606)
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?


All times are GMT -4. The time now is 04:57.

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