Raised This Month: $ Target: $400
 0% 

Reliable CHannel Overflow


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-20-2007 , 18:44   Reliable CHannel Overflow
Reply With Quote #1

I made this simple plugin for my clan's server so that we could advertise new ect. It works perfectly, but it causes a reliable channel overflow error eventually. we had msg_delay set to 90.0 and 60.0seconds the times this happened any ideas?
Code:
#include <amxmodx> #include <amxmisc> new msg_file[128]; new ReadData[512]; new MsgSayText; public plugin_init() {     register_plugin("Message Display", "1.0", "Rolnaaba");         register_cvar("msg_delay", "120.0"); //how long between each message (seconds)         set_task(get_cvar_float("msg_delay"), "load_message");     MsgSayText = get_user_msgid("SayText"); } public load_message() {     get_configsdir(msg_file, 127);     formatex(msg_file, 127, "%s/message.ini", msg_file);                 new file = fopen(msg_file, "r");               if(file) {                   while(!feof(file)) {             fgets(file, ReadData, 511);                         if(ReadData[0] == ';')                 continue;                             display_message(ReadData);         }         fclose(file);     } else {         log_amx("Unable to find message.ini, Plugin Failed. Please place message.ini into your configs folder!");                 set_fail_state("Unable to find message.ini, Plugin Failed. Please place message.ini into your configs folder!");     } } public display_message(message[]) {     new message2[536];     formatex(message2, 535, "^x04%s", message);         new players[32], num, i;     get_players(players, num);     for(i = 0; i <= num; i++) {         new y = players[i];         if(!is_user_connected(y) || is_user_bot(y)) continue;         message_begin(MSG_ONE, MsgSayText, {0,0,0}, y);         write_byte(y);         write_string(message2);         message_end();     }         set_task(get_cvar_float("msg_delay"), "load_message"); }
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-20-2007 , 18:51   Re: Reliable CHannel Overflow
Reply With Quote #2

1. Why don't you set a looping task for it ?
2. Take a closer look at your while() loop...
_Master_ is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-20-2007 , 18:51   Re: Reliable CHannel Overflow
Reply With Quote #3

I think is because you send this to many players in the same moment!Why you don't send the message to all players by "0" with "client_print" ?
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-20-2007 , 18:56   Re: Reliable CHannel Overflow
Reply With Quote #4

client print doesnt support the ^x04 color thing, and thats the only way I know how to make it colored green, is there a way to color it green with client print?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
pRED*
Join Date: Dec 2006
Old 06-20-2007 , 20:38   Re: Reliable CHannel Overflow
Reply With Quote #5

Do it the same way you're doing it but change from MSG_ONE (message sent to a single client, over reliable data stream) to MSG_BROADCAST (message to all players, unreliable).

This removes the need for a loop and MSG_BROADCAST is the equivalent of client_print(0...) and also it's unreliable which means (i think) it doesn't get sent if its going to cause an overflow.

Also you don't need to read the file in every time you want to display the message. Read the file once on map load into a string array (define a number like MAX_ADS 30, new ads[MAX_ADS][128])

Then just loop through that array when you want to print..
pRED* is offline
Old 06-20-2007, 20:44
_Master_
This message has been deleted by _Master_. Reason: nvm...
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-21-2007 , 03:34   Re: Reliable CHannel Overflow
Reply With Quote #7

Quote:
Originally Posted by Rolnaaba View Post
client print doesnt support the ^x04 color thing, and thats the only way I know how to make it colored green, is there a way to color it green with client print?
Like this? Messages in chat . http://forums.alliedmods.net/showthread.php?t=45753
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-21-2007 , 05:10   Re: Reliable CHannel Overflow
Reply With Quote #8

Turning this to MSG_BROADCAST is only a workaround to the problem. It will still flood the channel.

Again, your while() loop is causing this.
_Master_ is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-20-2007 , 22:00   Re: Reliable CHannel Overflow
Reply With Quote #9

thnx
Code:
message_begin(MSG_BROADCAST, MsgSayText);     write_byte(0);     write_string(message2);     message_end();
like that?
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 06-20-2007 at 22:14.
Rolnaaba is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 06-21-2007 , 07:35   Re: Reliable CHannel Overflow
Reply With Quote #10

well how can I do it differently Master?
updated code:
Code:
#include <amxmodx> #include <amxmisc> #define MAXLINES 11 new msg_file[128]; new ReadData[512]; new MsgSayText; new ads[MAXLINES][256] new atline = 0; public plugin_init() {     register_plugin("Message Display", "1.0", "Rolnaaba");         register_cvar("msg_delay", "120.0"); //how long between each message (seconds)         MsgSayText = get_user_msgid("SayText");         load_message();         set_task(get_cvar_float("msg_delay"), "display_message"); } public load_message() {     get_configsdir(msg_file, 127);     formatex(msg_file, 127, "%s/message.ini", msg_file);                 new file = fopen(msg_file, "r");               if(file) {                   while(!feof(file)) {             fgets(file, ReadData, 511);                         if(ReadData[0] == ';')                 continue;             if(atline >= MAXLINES) {                 log_amx("Message too long, cutting it off atline = %i", atline);                 continue;             }                             copy(ads[atline], 511, ReadData);             atline++;         }         fclose(file);                 for(new i; i <= atline; i++) {             formatex(ads[i], 255, "^x04%s", ads[i]);         }     } else {         log_amx("Unable to find message.ini, Plugin Failed. Please place message.ini into your configs folder!");                 set_fail_state("Unable to find message.ini, Plugin Failed. Please place message.ini into your configs folder!");     } } public display_message() {     new players[32], num;     get_players(players, num);         for(new i; i <= atline; i++) {         message_begin(MSG_BROADCAST, MsgSayText);         write_byte(0);         write_string(ads[i]);         message_end();     }         set_task(get_cvar_float("msg_delay"), "load_message"); }
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 06-21-2007 at 07:42.
Rolnaaba 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 21:25.


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