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

Solved Coloured message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ssproxima
Senior Member
Join Date: Jan 2015
Old 03-05-2018 , 12:19   Coloured message
Reply With Quote #1

I have this code of tagme but it is giving error of loose indentation while compiling but the plugin is working fine. Another thing is that I want the client print to be coloured. Please some one help me.

Code:
#include <amxmodx>
#define PLUGIN        "TagMe" 
#define VERSION        "2.0" 
#define AUTHOR        "unknown" 

#define cm(%1)        (sizeof(%1)-1) 

new pCvar_Tag; 

public plugin_init() 
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR); 
     
    pCvar_Tag = register_cvar("amx_sv_tag", " TAG | "); 
             

    register_clcmd("say_team /tagme", "cmdTagMe");
    register_clcmd("say /tagme", "cmdTagMe");
    register_clcmd("say_team /untag", "cmdunTag");
    register_clcmd("say /untag", "cmdunTag");
            
} 

public cmdTagMe(id) 
{ 
    new szArg[192]; 
    read_args(szArg, charsmax(szArg)); 
    remove_quotes(szArg); 
     
    static szName[33], szTag[16]; 
     
    get_user_name(id, szName, cm(szName)); 
    get_pcvar_string(pCvar_Tag, szTag, cm(szTag)); 
     
    if(containi(szName, szTag) != -1) 
    {
		client_print(id, print_chat, "[AMXX TAG] You already Have the Tag !");
		return PLUGIN_CONTINUE;
    } 
   
    format(szName, cm(szName), "%s %s", szTag, szName); 
    set_user_info(id, "name", szName);
    client_print(id, print_chat, "[AMXX TAG] You are now having the Tag !");
    
    return(szArg[0] == '/'); 
} 

public cmdunTag(id) 
{ 
    static szName[33], szTag[16]; 
     
    get_user_name(id, szName, cm(szName)); 
    get_pcvar_string(pCvar_Tag, szTag, cm(szTag)); 
  
   
     replace_all( szName, cm(szName), szTag, "" ); 
     set_user_info( id, "name", szName ); 
     client_print(id, print_chat, "[AMXX TAG ] You have now removed the Tag !");
    
    return PLUGIN_CONTINUE; 
}

Last edited by ssproxima; 03-05-2018 at 13:27.
ssproxima is offline
WhiteFang1319
Senior Member
Join Date: Jan 2017
Old 03-05-2018 , 12:42   Re: Coloured message
Reply With Quote #2

Loose indentation is just a warning that just says that some part of the code is indented different than other lines of code.
If you're using AMX 1.8.3 then change client_print to client_print_color
In the message use
^4 = for green
^3 = for team color
^1 = normal
If you're not using Amx 1.8.3 then you could use this color chat include: https://forums.alliedmods.net/showthread.php?t=295046
WhiteFang1319 is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 03-05-2018 , 12:54   Re: Coloured message
Reply With Quote #3

Original Author is ZOF'X

Loose Identations are just Warnings ( Simple words : It means your code has just some incorrect spacing )

For color, Here you go :
PHP Code:
#include <amxmodx>
#if AMXX_VERSION_NUM < 183
    #include <chatcolor>
#endif

#define PLUGIN        "TagMe" 
#define VERSION        "2.0" 
#define AUTHOR        "ZOF'X" 

#define cm(%1)        (sizeof(%1)-1) 

new pCvar_Tag

public 
plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR); 
     
    
pCvar_Tag register_cvar("amx_sv_tag"" TAG | "); 
             

    
register_clcmd("say_team /tagme""cmdTagMe");
    
register_clcmd("say /tagme""cmdTagMe");
    
register_clcmd("say_team /untag""cmdunTag");
    
register_clcmd("say /untag""cmdunTag");
            


public 
cmdTagMe(id

    new 
szArg[192]; 
    
read_args(szArgcharsmax(szArg)); 
    
remove_quotes(szArg); 
     
    static 
szName[33], szTag[16]; 
     
    
get_user_name(idszNamecm(szName)); 
    
get_pcvar_string(pCvar_TagszTagcm(szTag)); 
     
    if(
containi(szNameszTag) != -1
    {
        
client_print_color(id0"^3[AMXX TAG] ^4You already Have the Tag !");
        return 
PLUGIN_CONTINUE;
    } 
   
    
format(szNamecm(szName), "%s %s"szTagszName); 
    
set_user_info(id"name"szName);
    
client_print_color(id0"^3[AMXX TAG] ^4You are now having the Tag !");
    
    return(
szArg[0] == '/'); 


public 
cmdunTag(id

    static 
szName[33], szTag[16]; 
     
    
get_user_name(idszNamecm(szName)); 
    
get_pcvar_string(pCvar_TagszTagcm(szTag)); 
  
   
    
replace_allszNamecm(szName), szTag"" ); 
    
set_user_infoid"name"szName ); 
    
client_print_color(id0"^3[AMXX TAG ] ^4You have now removed the Tag !");
    
    return 
PLUGIN_CONTINUE


Last edited by instinctpt1; 03-06-2018 at 00:50. Reason: coloring
instinctpt1 is offline
ssproxima
Senior Member
Join Date: Jan 2015
Old 03-05-2018 , 13:07   Re: Coloured message
Reply With Quote #4

Thanks for the help. but is it chatcolor or colorchat?

Last edited by ssproxima; 03-05-2018 at 13:15.
ssproxima is offline
ssproxima
Senior Member
Join Date: Jan 2015
Old 03-05-2018 , 13:27   Re: Coloured message
Reply With Quote #5

Done the plugin is working fine all warnings gone and getting coloured messages. Thanks for help
ssproxima is offline
sanimare
Senior Member
Join Date: Sep 2010
Old 03-05-2018 , 14:01   Re: Coloured message
Reply With Quote #6

Add admin check and message if you're not admin you can't tag yourself?
sanimare is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 03-05-2018 , 14:35   Re: Coloured message
Reply With Quote #7

Quote:
Originally Posted by sanimare View Post
Add admin check and message if you're not admin you can't tag yourself?
Cant understand ..
instinctpt1 is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 03-05-2018 , 14:38   Re: Coloured message
Reply With Quote #8

Quote:
Originally Posted by ssproxima View Post
Thanks for the help. but is it chatcolor or colorchat?
chatcolor is a Updated version of colorchat ( Which can provide support for 1.8.2 with same codes as in 1.8.3 )

While old colorchat has its own include and its coding is also different
If u have AMXX 1.8.3 then you need not to worry about anything
instinctpt1 is offline
sanimare
Senior Member
Join Date: Sep 2010
Old 03-05-2018 , 18:22   Re: Coloured message
Reply With Quote #9

Quote:
Originally Posted by instinctpt1 View Post
Cant understand ..
If a player(admin) have custom level ban, flag "d" for example, he can use chat command /tagme and if he is standard player with z flag message appears: You have no right's to tag yourself, only admin can use tag.
sanimare is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 03-06-2018 , 01:04   Re: Coloured message
Reply With Quote #10

Quote:
Originally Posted by sanimare View Post
If a player(admin) have custom level ban, flag "d" for example, he can use chat command /tagme and if he is standard player with z flag message appears: You have no right's to tag yourself, only admin can use tag.
Try :
PHP Code:
#include <amxmodx>
#include <amxmisc>
#if AMXX_VERSION_NUM < 183
    #include <chatcolor>
#endif

#define PLUGIN        "TagMe" 
#define VERSION        "2.0" 
#define AUTHOR        "ZOF'X" 

#define cm(%1)        (sizeof(%1)-1) 

new pCvar_Tag

public 
plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR); 
     
    
pCvar_Tag register_cvar("amx_sv_tag"" TAG | "); 
             

    
register_clcmd("say_team /tagme""cmdTagMe"ADMIN_BAN);
    
register_clcmd("say /tagme""cmdTagMe"ADMIN_BAN);
    
register_clcmd("say_team /untag""cmdunTag");
    
register_clcmd("say /untag""cmdunTag");
            


public 
cmdTagMe(idlvlcid
{
    if(!
cmd_access(id,lvl,cid0))
        return 
PLUGIN_HANDLED

    
new szArg[192]; 
    
read_args(szArgcharsmax(szArg)); 
    
remove_quotes(szArg); 
     
    static 
szName[33], szTag[16]; 
     
    
get_user_name(idszNamecm(szName)); 
    
get_pcvar_string(pCvar_TagszTagcm(szTag)); 
     
    if(
containi(szNameszTag) != -1
    {
        
client_print_color(id0"^3[AMXX TAG] ^4You already Have the Tag !");
        return 
PLUGIN_CONTINUE;
    } 
   
    
format(szNamecm(szName), "%s %s"szTagszName); 
    
set_user_info(id"name"szName);
    
client_print_color(id0"^3[AMXX TAG] ^4You are now having the Tag !");
    
    return(
szArg[0] == '/'); 


public 
cmdunTag(id

    static 
szName[33], szTag[16]; 
     
    
get_user_name(idszNamecm(szName)); 
    
get_pcvar_string(pCvar_TagszTagcm(szTag)); 
  
   
    
replace_allszNamecm(szName), szTag"" ); 
    
set_user_infoid"name"szName ); 
    
client_print_color(id0"^3[AMXX TAG ] ^4You have now removed the Tag !");
    
    return 
PLUGIN_CONTINUE

instinctpt1 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 20:26.


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