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 07-04-2007 , 22:47   Re: Reliable CHannel Overflow
Reply With Quote #1

ok, I found a different way to do it, but I dont know if it will work, and I dont have anyway to test it right now. Can anyone spot anyhting bad, or can test this for me or anything.

Here is my new way. I stole loading from superhero, so it has a different while() loop.

Code:
#include <amxmodx> #include <amxmisc> #define MAXLINES 11 new file[128]; new readLine = 0; new lengthRead; new data[1024]; new MsgSayText; new ads[MAXLINES][192] new total_lines; 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", 0, "", 0, "b"); } public load_message() {     get_configsdir(file, 127);     formatex(file, 127, "%s/message.ini", file);                 if(!file_exists(file)) {         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!");     }     while((readLine = read_file(file, readLine, data, 1023, lengthRead)) != 0) {         if(equal(data[0], ";")) continue;         data[191] = '^0'         copy(ads[readLine], 191, data);                 total_lines++;     } } public display_message() {     new players[32], num;     get_players(players, num);         for(new i; i <= total_lines; i++) {         message_begin(MSG_BROADCAST, MsgSayText);         write_byte(0);         write_string(ads[i]);         message_end();     } }
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 07-05-2007 , 04:05   Re: Reliable CHannel Overflow
Reply With Quote #2

Why did you do this
PHP Code:
new players[32], num;
    
get_players(playersnum); 
if you used MSG_BROADCAST? It's redundant.

For some reason you decided not to change the way your text gets printed nor consider the reasons for this change:
1. Currently you limited the size to 11 lines. Consider the fact that you have 142390644 lines.
2. ALL your lines get printed at once. That could spam the chat.

This can be fixed. All you have to do is print a SINGLE line at a time. Since your text has no prefix attached you could use "^n" if multiple lines is a must. Doing this will also fix the overflow error when using MSG_ONE.


[EDIT]
In case you decide to change it, you have 2 ways of doing it:
1. With incrementing lines.
2. With random lines.

You can change MSG_ONE to MSG_ONE_UNRELIABLE if you wish.

1. Code follows:
PHP Code:
public display_message(){
    new 
players[32], num
    
static line
    
    get_players
(playersnum"ch")
    for(new 
0numi++){
        
        
message_begin(MSG_ONEMsgSayText)
        
write_byte(players[i])
        
write_string(ads[line])
        
message_end()
    }
    
    
// Increment the current line
    // If we displayed all lines then go to the first line
    // (for a cyclic display)
    
++line
    
if(line == total_linesline 0

2.
PHP Code:
public display_message(){
    new 
players[32], numline
    
    
// A random line to display    
    
line random_num(0total_lines 1)
    
    
get_players(playersnum"ch")
    for(new 
0numi++){
        
        
message_begin(MSG_ONEMsgSayText)
        
write_byte(players[i])
        
write_string(ads[line])
        
message_end()
    }


Last edited by _Master_; 07-06-2007 at 05:30.
_Master_ is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-05-2007 , 10:58   Re: Reliable CHannel Overflow
Reply With Quote #3

the get_players was left over from previous version, and I didnt take it out, sorry. but I do cycle through all the lines notice:
I store the total amount of lines loaded into total_lines, then cycle through all messages that were loaded using this varriable.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 07-05-2007 , 14:13   Re: Reliable CHannel Overflow
Reply With Quote #4

... which is the whole point of this: you cycle through all the messages in an attempt to dislpay ALL of them at once.
_Master_ is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-05-2007 , 14:29   Re: Reliable CHannel Overflow
Reply With Quote #5

which is exactly what I want to do...
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 07-06-2007 , 05:28   Re: Reliable CHannel Overflow
Reply With Quote #6

If the two problems I've mentioned do not warrant a code rewrite then I would say that's the end of it.
_Master_ is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-06-2007 , 12:50   Re: Reliable CHannel Overflow
Reply With Quote #7

both the "problems" you mentioned are not infact problems but are the functionality I wish for, but what I am asking, is does this code remove the overflow error if it is the fact that I am showing all lines at once that is causing the error, then I will change it.
__________________
DO NOT PM me about avp mod.
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:24.


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