AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Message showing twice. (https://forums.alliedmods.net/showthread.php?t=183829)

Napoleon_be 04-27-2012 09:52

Message showing twice.
 
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



fysiks 04-27-2012 09:55

Re: Message showing twice.
 
Just return PLUGIN_HANDLED.

Napoleon_be 04-27-2012 09:57

Re: Message showing twice.
 
doesn't work.

<VeCo> 04-27-2012 10:04

Re: Message showing twice.
 
Do you use another plugin that changes the chat?

Napoleon_be 04-27-2012 10:07

Re: Message showing twice.
 
Fixed it already, thanks for your answers tho.

Napoleon_be 04-27-2012 10:14

Re: Message showing twice.
 
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?

<VeCo> 04-27-2012 10:18

Re: Message showing twice.
 
Return PLUGIN_HANDLED_MAIN and remove that dublicate function.

fysiks 04-27-2012 10:20

Re: Message showing twice.
 
Quote:

Originally Posted by Napoleon_be (Post 1697409)
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.

Napoleon_be 04-27-2012 10:49

Re: Message showing twice.
 
I had another plugin like <VeCo> said.

Also, thanks. return PLUGIN_HANDLED_MAIN worked. Thanks :)

ConnorMcLeod 04-27-2012 15:41

Re: Message showing twice.
 
Also, remove :

Code:

    register_message(szSayText, "MsgDuplicate")
}

public MsgDuplicate(id) {
    return PLUGIN_HANDLED
}

This is bad code taken from an unapproved (by me) plugin.


All times are GMT -4. The time now is 07:44.

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