Raised This Month: $ Target: $400
 0% 

Message showing twice.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-27-2012 , 09:52   Message showing twice.
Reply With Quote #1

title says all. When i type something in chat, the prefix and colors are correct, but it's showing the message twice, why?

PHP Code:
#include <amxmodx>

#define VERSION "1.0"

new szSayTextszMaxPlayers

public plugin_init() {
    
register_plugin("AdminChat"VERSION"NapoleoN#")
    
    
register_clcmd("say""HandleSay")
    
    
szSayText get_user_msgid("SayText")
    
szMaxPlayers get_maxplayers()
    
register_message(szSayText"MsgDuplicate")
}

public 
MsgDuplicate(id) {
    return 
PLUGIN_HANDLED
}

public 
HandleSay(id) {
    new 
arg[100], szName[32]; get_user_name(idszNamecharsmax(szName))
    
    
read_args(argcharsmax(arg))
    
remove_quotes(arg)
    
    if(
get_user_flags(id) & ADMIN_KICK && is_valid_msg(arg)) {
        ( 
is_user_alive(id) ? format(argcharsmax(arg), "^x04[Admin]^x03 %s: %s"szNamearg) : format(argcharsmax(arg), "^x03*DEAD*^x04 [Admin]^x03 %s: %s"szNamearg))
    }
    
    for(new 
1<= szMaxPlayersi++) {
        if(!
is_user_connected(i))
            continue
        if(
is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i)) {
            
message_begin(MSG_ONEszSayText, {000}, i)
            
write_byte(id)
            
write_string(arg)
            
message_end();
        } 
    }
    return 
PLUGIN_CONTINUE;
}

bool:is_valid_msg(const arg[]) {
    if(
arg[0] == '@' || !strlen(arg)) { 
        return 
false
    
}
    return 
true

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-27-2012 , 09:55   Re: Message showing twice.
Reply With Quote #2

Just return PLUGIN_HANDLED.
__________________
fysiks is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-27-2012 , 09:57   Re: Message showing twice.
Reply With Quote #3

doesn't work.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 04-27-2012 , 10:04   Re: Message showing twice.
Reply With Quote #4

Do you use another plugin that changes the chat?
__________________
<VeCo> is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-27-2012 , 10:07   Re: Message showing twice.
Reply With Quote #5

Fixed it already, thanks for your answers tho.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-27-2012 , 10:14   Re: Message showing twice.
Reply With Quote #6

Also, i have the godmode plugin, but when i type /godmode now, it isn't showing the menu or anything, can someone help me with this?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 04-27-2012 , 10:18   Re: Message showing twice.
Reply With Quote #7

Return PLUGIN_HANDLED_MAIN and remove that dublicate function.
__________________

Last edited by <VeCo>; 04-27-2012 at 10:19.
<VeCo> is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-27-2012 , 10:20   Re: Message showing twice.
Reply With Quote #8

Quote:
Originally Posted by Napoleon_be View Post
Fixed it already, thanks for your answers tho.
So what was it?


Also, you have to remember when you start returning PLUGIN_HANDLED on any chat hook you risk messing things up with other plugins.
__________________
fysiks is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-27-2012 , 10:49   Re: Message showing twice.
Reply With Quote #9

I had another plugin like <VeCo> said.

Also, thanks. return PLUGIN_HANDLED_MAIN worked. Thanks
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-27-2012 , 15:41   Re: Message showing twice.
Reply With Quote #10

Also, remove :

Code:
    register_message(szSayText, "MsgDuplicate")
}

public MsgDuplicate(id) {
    return PLUGIN_HANDLED
}
This is bad code taken from an unapproved (by me) plugin.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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:44.


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