Raised This Month: $51 Target: $400
 12% 

chat error.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
svas
Junior Member
Join Date: Aug 2016
Location: Turkey
Old 02-19-2020 , 08:50   chat error.
Reply With Quote #1

hello, friends i have a plugin, this plugin was written to change the message color and nick color of the players and admins. But I have a problem with the plugin. That is; While the plugin sends the messages of normal players 1 time, it sends the messages of the players who have admin or slot authorization to the chat part twice. I want to fix this. can anyone help me

PHP Code:
// Renkler: [1] Sari, [2] Yesil, [3] Beyaz, [4] Mavi, [5] Kirmizi, [6] Takim Rengi

#include <amxmodx>
#include <amxmisc>

#define YONETICI_ADMIN ADMIN_IMMUNITY
#define PLUGINCI_ADMIN ADMIN_RCON
#define NORMAL_ADMIN ADMIN_BAN
#define SLOT_ADMIN ADMIN_RESERVATION
#define USER_ADMIN ADMIN_USER
#define ADMIN_LISTEN ADMIN_BAN

new message[192]
new 
YoneticiNickRengiPluginciNickRengiAdminNickRengiSlotNickRengiUserNickRengi;
new 
YoneticiMesajRengiPluginciMesajRengiAdminMesajRengiSlotMesajRengiUserMesajRengi;
new 
AdminListenalive[11], strName[191], strText[191]

new const 
yTag[] = "";
new const 
kurucu[] = "";
new const 
pluginci[] = "";
new const 
admin[] = "";
new const 
slot[] = "";

public 
plugin_init() {
    
register_plugin("Renkli Yazma""1.0""Anonim / edit: Berk")

    
register_clcmd("say""hook_say")
    
register_clcmd("say_team""hook_sayteam")

    
register_message (get_user_msgid ("SayText"), "avoid_duplicated")

    
YoneticiNickRengi register_cvar("yonetici_nick_color""5")

    
PluginciNickRengi register_cvar("pluginci_nick_color""5")

    
AdminNickRengi register_cvar("admin_nick_color""5")

    
SlotNickRengi register_cvar("slot_nick_color""5")

    
UserNickRengi register_cvar("user_nick_color""3")

    
YoneticiMesajRengi register_cvar("yonetici_mesaj_color""2")

    
PluginciMesajRengi register_cvar("pluginci_mesaj_color""2")

    
AdminMesajRengi register_cvar("admin_mesaj_color""2")

    
SlotMesajRengi register_cvar("slot_mesaj_color""2")

    
UserMesajRengi register_cvar("user_mesaj_color""1")

    
AdminListen register_cvar("amx_listen""1")
}

public 
avoid_duplicated (msgIdmsgDestreceiver)
{
    return 
PLUGIN_HANDLED
}

public 
hook_say(id)
{
    
read_args(message191)
    
remove_quotes(message)

    if(
message[0] == '@' || message[0] == '!' || equal(message"")) return PLUGIN_CONTINUE;

    new 
name[32]
    
get_user_name(idname31)

    new 
bool:User false
    
new bool:Slot false
    
new bool:Admin false
    
new bool:Pluginci false
    
new bool:Yonetici false

    
if(get_user_flags(id) & YONETICI_ADMINYonetici true
    
else if(get_user_flags(id) & PLUGINCI_ADMINPluginci true
    
else if(get_user_flags(id) & NORMAL_ADMINAdmin true
    
else if(get_user_flags(id) & SLOT_ADMINSlot true
    
else if(get_user_flags(id) & USER_ADMINUser true

    
new isAlive

    
if(is_user_alive(id))
    {
        
isAlive 1
        alive 
"^x01"
    
}
    else
    {
        
isAlive 0
        alive 
"^x01*OLU*"
    
}

    static 
color[10]

    if(
Yonetici)
    {
        
Admin false
        Slot 
false
        Pluginci 
false
        User 
false

        
switch(get_pcvar_num(YoneticiNickRengi))
        {
            case 
1: {
                
format (strName191"^x04%s %s %s"kurucualivename)
            }
            case 
2: {
                
format (strName191"^x04%s %s ^x04%s"kurucualivename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"^x04%s %s ^x03%s"kurucualivename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"^x04%s %s ^x03%s"kurucualivename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"^x04%s %s ^x03%s"kurucualivename)
            }
            case 
6: {
                
get_user_team(idcolor9)
                
format (strName191"^x04%s %s ^x03%s"kurucualivename)
            }
        }
        switch(
get_pcvar_num(YoneticiMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
Pluginci)
    {
        
Yonetici false
        Admin 
false
        Slot 
false
        User 
false

        
switch(get_pcvar_num(PluginciNickRengi))
        {
            case 
1: {
                
format (strName191"^x04%s %s %s"plugincialivename)
            }
            case 
2: {
                
format (strName191"^x04%s %s ^x04%s"plugincialivename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"^x04%s %s ^x03%s"plugincialivename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"^x04%s %s ^x03%s"plugincialivename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"^x04%s %s ^x03%s"plugincialivename)
            }
            case 
6: {
                
get_user_team(idcolor9)
                
format (strName191"^x04%s %s ^x03%s"plugincialivename)
            }
        }
        switch(
get_pcvar_num(PluginciMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
Admin)
    {
        
Yonetici false
        Slot 
false
        Pluginci 
false
        User 
false

        
switch(get_pcvar_num(AdminNickRengi))
        {
            case 
1: {
                
format (strName191"^x04%s %s %s"adminalivename)
            }
            case 
2: {
                
format (strName191"^x04%s %s ^x04%s"adminalivename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"^x04%s %s ^x03%s"adminalivename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"^x04%s %s ^x03%s"adminalivename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"^x04%s %s ^x03%s"adminalivename)
            }
            case 
6: {
                
get_user_team(idcolor9)
                
format (strName191"^x04%s %s ^x03%s"adminalivename)
            }
        }
        switch(
get_pcvar_num(AdminMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
Slot)
    {
        
Yonetici false
        Admin 
false
        Pluginci 
false
        User 
false

        
switch(get_pcvar_num(SlotNickRengi))
        {
            case 
1: {
                
format (strName191"^x04%s %s %s"slotalivename)
            }
            case 
2: {
                
format (strName191"^x04%s %s ^x04%s"slotalivename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"^x04%s %s ^x03%s"slotalivename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"^x04%s %s ^x03%s"slotalivename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"^x04%s %s ^x03%s"slotalivename)
            }
            case 
6: {
                
get_user_team(idcolor9)
                
format (strName191"^x04%s %s ^x03%s"slotalivename)
            }
        }
        switch(
get_pcvar_num(SlotMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
User)
    {
        
Yonetici false
        Admin 
false
        Slot 
false
        Pluginci 
false

        
switch(get_pcvar_num(UserNickRengi))
        {
            case 
1: {
                
format (strName191"^x04%s %s %s"yTagalivename)
            }
            case 
2: {
                
format (strName191"^x04%s %s ^x04%s"yTagalivename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"^x04%s %s ^x03%s"yTagalivename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"^x04%s %s ^x03%s"yTagalivename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"^x04%s %s ^x03%s"yTagalivename)
            }
            case 
6: {
                
get_user_team(idcolor9)
                
format (strName191"^x04%s %s ^x03%s"yTagalivename)
            }
        }
        switch(
get_pcvar_num(UserMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else
    {
        
get_user_team(idcolor9)
        
format (strName191"%s^x03%s"alivename)
        
format (strText191"%s"message)
    }
    
format (message191"%s^x01 :  %s"strNamestrText)
    
sendMessage (colorisAlive)
    return 
PLUGIN_CONTINUE;
}

public 
hook_sayteam(id)
{
    new 
playerTeam get_user_team(id)
    new 
playerTeamName[19]

    switch(
playerTeam)
    {
        case 
1: {
            
copy (playerTeamName11"Terrorists")
        }
        case 
2: {
            
copy (playerTeamName18"Counter-Terrorists")
        }
        default: {
            
copy (playerTeamName9"Spectator")
        }
    }

    
read_args(message191)
    
remove_quotes(message)

    if(
message[0] == '@' || message[0] == '!' || equal(message"")) return PLUGIN_CONTINUE;

    new 
name[32]
    
get_user_name(idname31)

    new 
bool:User false
    
new bool:Slot false
    
new bool:Admin false
    
new bool:Pluginci false
    
new bool:Yonetici false

    
if(get_user_flags(id) & YONETICI_ADMINYonetici true
    
else if(get_user_flags(id) & PLUGINCI_ADMINPluginci true
    
else if(get_user_flags(id) & NORMAL_ADMINAdmin true
    
else if(get_user_flags(id) & SLOT_ADMINSlot true
    
else if(get_user_flags(id) & USER_ADMINUser true

    
new isAlive

    
if(is_user_alive(id))
    {
        
isAlive 1
        alive 
"^x01"
    
}
    else
    {
        
isAlive 0
        alive 
"^x01*OLU*"
    
}

    static 
color[10]

    if(
Yonetici)
    {
        
Admin false
        Slot 
false
        User 
false
        Pluginci 
false

        
switch(get_pcvar_num(YoneticiNickRengi))
        {
            case 
1: {
                
format (strName191"%s(%s) %s"aliveplayerTeamNamename)
            }
            case 
2: {
                
format (strName191"%s(%s) ^x04%s"aliveplayerTeamNamename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
6: {
                
get_user_team (idcolor9)
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
        }
        switch(
get_pcvar_num(YoneticiMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
Pluginci)
    {
        
Admin false
        Slot 
false
        User 
false
        Yonetici 
false

        
switch(get_pcvar_num(PluginciNickRengi))
        {
            case 
1: {
                
format (strName191"%s(%s) %s"aliveplayerTeamNamename)
            }
            case 
2: {
                
format (strName191"%s(%s) ^x04%s"aliveplayerTeamNamename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
6: {
                
get_user_team (idcolor9)
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
        }
        switch(
get_pcvar_num(PluginciMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
Admin)
    {
        
Yonetici false
        Slot 
false
        User 
false
        Pluginci 
false

        
switch(get_pcvar_num(AdminNickRengi))
        {
            case 
1: {
                
format (strName191"%s(%s) %s"aliveplayerTeamNamename)
            }
            case 
2: {
                
format (strName191"%s(%s) ^x04%s"aliveplayerTeamNamename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
6: {
                
get_user_team (idcolor9)
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
        }
        switch(
get_pcvar_num(AdminMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
Slot)
    {
        
Yonetici false
        Admin 
false
        User 
false
        Pluginci 
false

        
switch(get_pcvar_num(SlotNickRengi))
        {
            case 
1: {
                
format (strName191"%s(%s) %s"aliveplayerTeamNamename)
            }
            case 
2: {
                
format (strName191"%s(%s) ^x04%s"aliveplayerTeamNamename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
6: {
                
get_user_team (idcolor9)
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
        }
        switch(
get_pcvar_num(SlotMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else if(
User)
    {
        
Yonetici false
        Admin 
false
        Slot 
false

        
switch(get_pcvar_num(UserNickRengi))
        {
            case 
1: {
                
format (strName191"%s(%s) %s"aliveplayerTeamNamename)
            }
            case 
2: {
                
format (strName191"%s(%s) ^x04%s"aliveplayerTeamNamename)
            }
            case 
3: {
                
color "SPECTATOR"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
4: {
                
color "CT"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
5: {
                
color "TERRORIST"
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
            case 
6: {
                
get_user_team (idcolor9)
                
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            }
        }
        switch(
get_pcvar_num(UserMesajRengi))
        {
            case 
1: {
                
format (strText191"%s"message)
            }
            case 
2: {
                
format (strText191"^x04%s"message)
            }
            case 
3: {
                
copy (color9"SPECTATOR")
                
format (strText191"^x03%s"message)
            }
            case 
4: {
                
copy (color9"CT")
                
format (strText191"^x03%s"message)
            }
            case 
5: {
                
copy (color9"TERRORIST")
                
format (strText191"^x03%s"message)
            }
        }
    }
    else
    {
        
get_user_team (idcolor9)
        
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
        
format (strText191"%s"message)
    }
    
format (message191"%s ^x01:  %s"strNamestrText)
    
sendTeamMessage (colorisAliveplayerTeam)
    return 
PLUGIN_CONTINUE
}

public 
set_listen(idlevelcid)
{
    if(!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED;

    new 
arg[1], newListen
    read_argv
(1arg1)

    
newListen str_to_num (arg)

    
set_cvar_num ("amx_listen"newListen)
    
set_pcvar_num (AdminListennewListen)

    return 
PLUGIN_HANDLED
}

public 
sendMessage(color[], alive)
{
    new 
teamName[10]

    for(new 
player 1player get_maxplayers(); player++)
    {
        if(!
is_user_connected(player))
            continue

        if(
alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
        {
            
get_user_team(playerteamName9)
            
changeTeamInfo(playercolor)
            
writeMessage(playermessage)
            
changeTeamInfo(playerteamName)
        }
    }
}

public 
sendTeamMessage(color[], aliveplayerTeam)
{
    new 
teamName[10]

    for(new 
player 1player get_maxplayers(); player++)
    {
        if(
get_user_team(player) == playerTeam || get_pcvar_num(AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
        {
            if(
alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
            {
                
get_user_team(playerteamName9)
                
changeTeamInfo(playercolor)
                
writeMessage(playermessage)
                
changeTeamInfo(playerteamName)
            }
        }
    }
}

public 
changeTeamInfo(playerteam[])
{
    
message_begin (MSG_ONEget_user_msgid ("TeamInfo"), _player)
    
write_byte (player)
    
write_string (team)
    
message_end()
}

public 
writeMessage (playermessage[])
{
    
message_begin (MSG_ONEget_user_msgid ("SayText"), {000}, player)
    
write_byte (player)
    
write_string (message)
    
message_end ()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1055\\ f0\\ fs16 \n\\ par }
*/ 
svas is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-19-2020 , 12:46   Re: chat error.
Reply With Quote #2

That plugin is very poorly coded and harcoded. No point in still using it in 2020. I strongly suggest you use this instead - https://forums.alliedmods.net/showthread.php?t=297952

With this one you can customize the entire chat via the configuration file, just the way you want it - fast and easy.
__________________

Last edited by OciXCrom; 02-19-2020 at 12:47.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 09:24.


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