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

[ADMIN], [MOD] and [VIP] tag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marquezs
Member
Join Date: Jun 2010
Old 06-16-2010 , 06:24   [ADMIN], [MOD] and [VIP] tag
Reply With Quote #1

Hi there, I'm looking for one plugin for each tag. In the counter strike server chat, it appears [ADMIN] in green before the name and then the words they say are in green too.

This plugin does it very well: http://forums.alliedmods.net/showpos...33&postcount=2

And I've tried to edit the flags and put a [MOD] and a [ADMIN] tag working. But the two plugins at the same time bug each other. I wanted the plugin with [ADMIN] tag to have the flag A and the [MOD] the flag B.

And if possible, a plugin with the same settings but with tag [VIP] and flag Z.

But if you could just put [ADMIN] and [MOD] plugins I would be happy and maybe I would sort out how to edit the sma to make the VIP plugin work together with those two.


I hope you have understood what I said, thank you
marquezs is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-16-2010 , 11:59   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #2

You do know that every single person who enters into your server has the Z flag right?

I think...atleast...the Z flag indicates a regular user.
RedRobster is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2010 , 12:50   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #3

Quote:
Originally Posted by marquezs View Post
And I've tried to edit the flags and put a [MOD] and a [ADMIN] tag working. But the two plugins at the same time bug each other.
That's why you should put it all in one plugin.
__________________
fysiks is online now
t*stylez
BANNED
Join Date: Apr 2010
Old 06-16-2010 , 12:52   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #4

z flag is no admin o.o
t*stylez is offline
marquezs
Member
Join Date: Jun 2010
Old 06-16-2010 , 14:40   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
That's why you should put it all in one plugin.
Ok that would be perfect. Let's say [ADMIN] has flag A, [MOD] has flag d and [VIP] has flag b. How would I do that

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN         "Admin Chat Colors"
#define VERSION     "2.0"
#define AUTHOR         "Arion"

#define ACCESS_LEVEL    ADMIN_IMMUNITY
#define ADMIN_LISTEN    ADMIN_LEVEL_C

new message[192]
new sayText
new teamInfo
new maxPlayers

new g_MessageColor
new g_NameColor
new g_AdminListen

new strName[191]
new strText[191]
new alive[11]

public plugin_init()
{
    register_plugin (PLUGIN, VERSION, AUTHOR)
    
    g_MessageColor = register_cvar ("amx_color", "2") // Message colors: [1] Default Yellow, [2] Green, [3] White, [4] Blue, [5] Red

    g_NameColor = register_cvar ("amx_namecolor", "6") // Name colors: [1] Default Yellow, [2] Green, [3] White, [4] Blue, [5] Red, [6] Team-color
    
    g_AdminListen = register_cvar ("amx_listen", "1") // Set whether admins see or not all messages (Alive, dead and team-only)
    
    
    sayText = get_user_msgid ("SayText")
    teamInfo = get_user_msgid ("TeamInfo")
    maxPlayers = get_maxplayers()
    
    
    register_message (sayText, "avoid_duplicated")
    
    register_clcmd ("amx_color", "set_color", ACCESS_LEVEL, "<color>")
    register_clcmd ("amx_namecolor", "set_name_color", ACCESS_LEVEL, "<color>")
    register_clcmd ("amx_listen", "set_listen", ACCESS_LEVEL, "<1 | 0>")
    
    register_clcmd ("say", "hook_say")
    register_clcmd ("say_team", "hook_teamsay")
}


public avoid_duplicated (msgId, msgDest, receiver)
{
    return PLUGIN_HANDLED
}


public hook_say(id)
{
    read_args (message, 191)
    remove_quotes (message)
    
    if (message[0] == '@' || message[0] == '/' || message[0] == '!' || equal (message, "")) // Ignores Admin Hud Messages, Admin Slash commands, 
                                                   // Gungame commands and empty messages
        return PLUGIN_CONTINUE

        
    new name[32]
    get_user_name (id, name, 31)
    
    new bool:admin = false
    
    if (get_user_flags(id) & ACCESS_LEVEL)
        admin = true
        
    
    new isAlive
    
    if (is_user_alive (id))
        {
            isAlive = 1
            alive = "^x01"
        }
    else
        {
            isAlive = 0
            alive = "^x01*DEAD* "
        }
    
    static color[10]
    

    
    if (admin)
        {
            // Name
            switch (get_pcvar_num (g_NameColor))
                {
                    case 1:
                        format (strName, 191, "^x04[ADMIN] %s%s", alive, name)

                    case 2:
                        format (strName, 191, "^x04[ADMIN] %s^x04%s ", alive, name)
                        
                    case 3:
                        {
                            color = "SPECTATOR"
                            format (strName, 191, "^x04[ADMIN] %s^x03%s ", alive, name)
                        }
                        
                    case 4:
                        {
                            color = "CT"
                            format (strName, 191, "^x04[ADMIN] %s^x03%s", alive, name)
                        }

                    case 5:
                        {
                            color = "TERRORIST"
                            format (strName, 191, "^x04[ADMIN] %s^x03%s", alive, name)
                        }
                    
                    case 6:
                        {
                            get_user_team (id, color, 9)
                                
                            format (strName, 191, "^x04[ADMIN] %s^x03%s", alive, name)
                        }
                }
            
            
            // Message
            switch (get_pcvar_num (g_MessageColor))
                {
                    case 1:    // Yellow
                        format (strText, 191, "%s", message)
                        
                    case 2:    // Green
                        format (strText, 191, "^x04%s", message)
                        
                    case 3:    // White
                        {
                            copy (color, 9, "SPECTATOR")
                            format (strText, 191, "^x03%s", message)
                        }

                    case 4:    // Blue
                        {
                            copy (color, 9, "CT")
                            format (strText, 191, "^x03%s", message)
                        }
                        
                    case 5:    // Red
                        {
                            copy (color, 9, "TERRORIST")
                            format (strText, 191, "^x03%s", message)
                        }
                }
        }
    
    else     // Player is not admin. Team-color name : Yellow message
        {
            get_user_team (id, color, 9)
            
            format (strName, 191, "%s^x03%s", alive, name)
            
            format (strText, 191, "%s", message)
        }

    format (message, 191, "%s^x01 :  %s", strName, strText)
            
    sendMessage (color, isAlive)    // Sends the colored message
    
    return PLUGIN_CONTINUE
}


public hook_teamsay(id)
{
    new playerTeam = get_user_team(id)
    new playerTeamName[19]
    
    switch (playerTeam) // Team names which appear on team-only messages
        {
            case 1:
                copy (playerTeamName, 11, "Terrorists")
                
            case 2:
                copy (playerTeamName, 18, "Counter-Terrorists")
                
            default:
                copy (playerTeamName, 9, "Spectator")
        }
        
    read_args (message, 191)
    remove_quotes (message)
    
    if (message[0] == '@' || message[0] == '/' || message[0] == '!' || equal (message, "")) // Ignores Admin Hud Messages, Admin Slash commands, 
                                                   // Gungame commands and empty messages
        return PLUGIN_CONTINUE

        
    new name[32]
    get_user_name (id, name, 31)
    
    new bool:admin = false
    
    if (get_user_flags(id) & ACCESS_LEVEL)
        admin = true
        
    
    new isAlive
    
    if (is_user_alive (id))
        {
            isAlive = 1
            alive = "^x01"
        }
    else
        {
            isAlive = 0
            alive = "^x01*DEAD* "
        }
    
    static color[10]
    

    
    if (admin)
        {
            // Name
            switch (get_pcvar_num (g_NameColor))
                {
                    case 1:
                        format (strName, 191, "%s(%s)^x04[ADMIN] %s", alive, playerTeamName, name)

                    case 2:
                        format (strName, 191, "%s(%s)^x04[ADMIN] ^x04%s", alive, playerTeamName, name)
                        
                    case 3:
                        {
                            color = "SPECTATOR"
                            format (strName, 191, "%s(%s)^x04[ADMIN] ^x03%s", alive, playerTeamName, name)
                        }
                        
                    case 4:
                        {
                            color = "CT"
                            format (strName, 191, "%s(%s)^x04[ADMIN] ^x03%s", alive, playerTeamName, name)
                        }

                    case 5:
                        {
                            color = "TERRORIST"
                            format (strName, 191, "%s(%s)^x04[ADMIN] ^x03%s", alive, playerTeamName, name)
                        }
                    
                    case 6:
                        {
                            get_user_team (id, color, 9)
                                
                            format (strName, 191, "%s(%s)^x04[ADMIN] ^x03%s", alive, playerTeamName, name)
                        }
                }
            
            
            // Message
            switch (get_pcvar_num (g_MessageColor))
                {
                    case 1:    // Yellow
                        format (strText, 191, "%s", message)
                        
                    case 2:    // Green
                        format (strText, 191, "^x04%s", message)
                        
                    case 3:    // White
                        {
                            copy (color, 9, "SPECTATOR")
                            format (strText, 191, "^x03%s", message)
                        }

                    case 4:    // Blue
                        {
                            copy (color, 9, "CT")
                            format (strText, 191, "^x03%s", message)
                        }
                        
                    case 5:    // Red
                        {
                            copy (color, 9, "TERRORIST")
                            format (strText, 191, "^x03%s", message)
                        }
                }
        }
    
    else     // Player is not admin. Team-color name : Yellow message
        {
            get_user_team (id, color, 9)
            
            format (strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
            
            format (strText, 191, "%s", message)
        }
    
    format (message, 191, "%s ^x01:  %s", strName, strText)
    
    sendTeamMessage (color, isAlive, playerTeam)    // Sends the colored message
    
    return PLUGIN_CONTINUE    
}


public set_color (id, level, cid)
{
    if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED
        
    new arg[1], newColor
    read_argv (1, arg, 1)
    
    newColor = str_to_num (arg)
    
    if (newColor >= 1 && newColor <= 5)
        {
            set_cvar_num ("amx_color", newColor)
            set_pcvar_num (g_MessageColor, newColor)
    
            if (get_pcvar_num (g_NameColor) != 1 &&
                   ((newColor == 3 &&  get_pcvar_num (g_NameColor) != 3)
                 || (newColor == 4 &&  get_pcvar_num (g_NameColor) != 4)
                 || (newColor == 5 &&  get_pcvar_num (g_NameColor) != 5)))
                {
                    set_cvar_num ("amx_namecolor", 2)
                    set_pcvar_num (g_NameColor, 2)
                }
        }
        
    return PLUGIN_HANDLED
}


public set_name_color (id, level, cid)
{
    if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED
        
    new arg[1], newColor
    read_argv (1, arg, 1)
    
    newColor = str_to_num (arg)
    
    if (newColor >= 1 && newColor <= 6)
        {
            set_cvar_num ("amx_namecolor", newColor)
            set_pcvar_num (g_NameColor, newColor)
            
            if ((get_pcvar_num (g_MessageColor) != 1
                && ((newColor == 3 &&  get_pcvar_num (g_MessageColor) != 3)
                 || (newColor == 4 &&  get_pcvar_num (g_MessageColor) != 4)
                 || (newColor == 5 &&  get_pcvar_num (g_MessageColor) != 5)))
                 || get_pcvar_num (g_NameColor) == 6)
                {
                    set_cvar_num ("amx_color", 2)
                    set_pcvar_num (g_MessageColor, 2)
                }
        }
    
    return PLUGIN_HANDLED
}


public set_listen (id, level, cid)
{
    if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED
        
    new arg[1], newListen
    read_argv(1, arg, 1)
    
    newListen = str_to_num (arg)
    
    set_cvar_num ("amx_listen", newListen)
    set_pcvar_num (g_AdminListen, newListen)
    
    return PLUGIN_HANDLED
}


public sendMessage (color[], alive)
{
    new teamName[10]
    
    for (new player = 1; player < maxPlayers; player++)
        {
            if (!is_user_connected(player))
                continue

            if (alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
                {
                    get_user_team (player, teamName, 9)    // Stores user's team name to change back after sending the message
                    
                    changeTeamInfo (player, color)        // Changes user's team according to color choosen
                    
                    writeMessage (player, message)        // Writes the message on player's chat
                    
                    changeTeamInfo (player, teamName)    // Changes user's team back to original
                }
        }
}


public sendTeamMessage (color[], alive, playerTeam)
{
    new teamName[10]
    
    for (new player = 1; player < maxPlayers; player++)
        {
            if (!is_user_connected(player))
                continue

            if (get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
                {
                    if (alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
                        {
                            get_user_team (player, teamName, 9)    // Stores user's team name to change back after sending the message
                            
                            changeTeamInfo (player, color)        // Changes user's team according to color choosen
                            
                            writeMessage (player, message)        // Writes the message on player's chat
                            
                            changeTeamInfo (player, teamName)    // Changes user's team back to original
                        }
                }
        }
}


public changeTeamInfo (player, team[])
{
    message_begin (MSG_ONE, teamInfo, _, player)    // Tells to to modify teamInfo (Which is responsable for which time player is)
    write_byte (player)                // Write byte needed
    write_string (team)                // Changes player's team
    message_end()                    // Also Needed
}


public writeMessage (player, message[])
{
    message_begin (MSG_ONE, sayText, {0, 0, 0}, player)    // Tells to modify sayText (Which is responsable for writing colored messages)
    write_byte (player)                    // Write byte needed
    write_string (message)                    // Effectively write the message, finally, afterall
    message_end ()                        // Needed as always
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2070\\ f0\\ fs16 \n\\ par }
*/
This is the code for just the [ADMIN] tag, it works perfectly but I can't put or don't know how to do the rest. I've tried to edit this plugin, put flag b and the compile and have two plugins running but they would bug each other.


Can you help me? I would really appreciate, thank you
marquezs is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2010 , 15:30   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #6

Ok, try this:

(rename the file to what ever your's is called)
Attached Files
File Type: sma Get Plugin or Get Source (compile.sma - 8359 views - 10.0 KB)
__________________

Last edited by fysiks; 06-16-2010 at 19:21.
fysiks is online now
iwontsuffer
BANNED
Join Date: Jan 2010
Old 06-16-2010 , 15:34   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #7

I think what he wants is when an admin, mod, and VIP talk itll be like this

VIP flag = [FLAG] i.e. u
Admin flag = [FLAG] i.e. d
Mod flag = [FLAG] i.e. c ; [FLAG] put in a flag of what it resembles

[ADMIN] (NAME): Greentext....
[VIP] (NAME): Blue Text....
[MOD] (NAME): Red Text...

The people with those flags will have that name auto appear before they type.
iwontsuffer is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2010 , 15:36   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #8

Quote:
Originally Posted by iwontsuffer View Post
I think what he wants is when an admin, mod, and VIP talk itll be like this

VIP flag = [FLAG] i.e. u
Admin flag = [FLAG] i.e. d
Mod flag = [FLAG] i.e. c ; [FLAG] put in a flag of what it resembles

[ADMIN] (NAME): Greentext....
[VIP] (NAME): Blue Text....
[MOD] (NAME): Red Text...

The people with those flags will have that name auto appear before they type.
ECHO ECHO echo . . .
__________________
fysiks is online now
DIREKTOR
Senior Member
Join Date: Jan 2010
Location: On server
Old 06-16-2010 , 15:37   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #9

fysiks your code makes evry msg to be dubbled .
__________________
Quote:
Originally Posted by KadiR View Post
Learn the fucking server rules you idiot.
DIREKTOR is offline
Send a message via MSN to DIREKTOR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2010 , 15:39   Re: [ADMIN], [MOD] and [VIP] tag
Reply With Quote #10

Quote:
Originally Posted by DIREKTOR View Post
fysiks your code makes evry msg to be dubbled .
I didn't change anything that would do that. If it does then it did it before I touched it.
__________________
fysiks is online now
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 00:25.


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