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

print_chat color help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
svas
Junior Member
Join Date: Aug 2016
Location: Turkey
Old 02-16-2020 , 18:35   print_chat color help
Reply With Quote #1

Hello, friends, I have a very simple logic, nick encryption plug in my hand.
I want this plugin to make the say commands green. is there anyone to help me?

Succeeded reg. command send
Nick: and Pw:

I want to differ from between everyone of that. Like that in say chat color.
Nick: asd Pw: 123

Thank you from now.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new const USER_FILE[] = "addons/amxmodx/configs/custom_users.ini";

new 
bool:MessageModeByServer;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    if(!
file_exists(USER_FILE)) {
        new 
fopen(USER_FILE,"wt");
        
fclose(f)
    }
    
    
register_clcmd("say /nickpw","PasswordRequest")
    
register_clcmd("Sifrenizi Giriniz","PasswordReceive")
    
}
public 
client_connect(id) {
    new 
UserPW[32],UserName[32];
    
get_user_info(id,"_pw",UserPW,31)
    
get_user_name(id,UserName,31)
    
    new 
maxlines file_size(USER_FILE,1);
    new 
szLineText[148],LineName[32],LinePW[32];
    new 
txtlen;
    for(new 
line;line<maxlines;line++) {
        
read_file(USER_FILE,line,szLineText,147,txtlen)
        
parse(szLineText,LineName,31,LinePW,31)
        if(
equali(UserName,LineName)) {
            if(!
equal(UserPW,LinePW)) {
                
server_cmd("kick #%d ^"Server'a Giris Hakkiniz Yok Cunku PW Yanlis Girdiniz^"",get_user_userid(id))
                return PLUGIN_HANDLED
            }
        }
    }
    return PLUGIN_CONTINUE
    
}
public PasswordRequest(id) {
    if(is_user_registered(id)) {
        client_print(id,print_chat,"Zaten Nickiniz Sifreli")
        return PLUGIN_HANDLED
    }
    
    MessageModeByServer = true;
    client_cmd(id,"messagemode ^"Sifrenizi Giriniz^"")
    return PLUGIN_HANDLED
}
public PasswordReceive(id) {
    if(!MessageModeByServer) {
        console_print(id,"Gecersiz Istek")
        return PLUGIN_HANDLED
    }
    new szText[32];
    read_args(szText,31)
    remove_quotes(szText)
    new cmd[10],szPW[32],others[32];
    parse(szText,cmd,9,szPW,31,others,31)
    remove_quotes(szPW)
    new szName[32];
    get_user_name(id,szName,31)
    MessageModeByServer = false;
    
    if(szPW[0] == 0) {
        client_print(id,print_chat,"Sifre Kismi Bos Birakilamaz")
        client_cmd(id,"messagemode ^"Sifrenizi Giriniz^"")
        return PLUGIN_HANDLED
    }
    
    register_user(szName,szPW)
    client_print(id,print_chat,"Nickiniz Basariyla Sifrelendi. Nick: %s PW: %s",szName,szPW)
    client_cmd(id,"setinfo _pw ^"%s^"",szPW)
    return PLUGIN_HANDLED
}
stock is_user_registered(id) {
    new name[32];
    get_user_name(id,name,31)
    
    new szLineText[128],txtlen;
    new LineName[64],LinePW[64];
    new maxlines;
    maxlines = file_size(USER_FILE,1);
    for(new line;line<maxlines;line++) {
        read_file(USER_FILE,line,szLineText,127,txtlen)
        parse(szLineText,LineName,63,LinePW,63)
        if(equali(name,LineName)) {
            return true;
        }
    }
    return false;
}
stock register_user(const szName[],const szPW[]) {
    new LineText[148];
    formatex(LineText,147,"^"%s^" ^"%s^"",szName,szPW)
    write_file(USER_FILE,LineText)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1055\\ f0\\ fs16 \n\\ par }
*/ 

Last edited by svas; 02-16-2020 at 18:42.
svas is offline
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 02-17-2020 , 03:25   Re: print_chat color help
Reply With Quote #2

1. One code:
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new const USER_FILE[] = "addons/amxmodx/configs/custom_users.ini";

new 
bool:MessageModeByServer;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    if(!
file_exists(USER_FILE)) {
        new 
fopen(USER_FILE,"wt");
        
fclose(f)
    }
    
register_dictionary("My_Text.txt");
    
register_clcmd("say /nickpw","PasswordRequest")
    
register_clcmd("Sifrenizi_Giriniz","PasswordReceive")
    
}
public 
client_connect(id) {
    new 
UserPW[32],UserName[32];
    
get_user_info(id,"_pw",UserPW,31)
    
get_user_name(id,UserName,31)
    
    new 
maxlines file_size(USER_FILE,1);
    new 
szLineText[148],LineName[32],LinePW[32];
    new 
txtlen;
    for(new 
line;line<maxlines;line++) {
        
read_file(USER_FILE,line,szLineText,147,txtlen)
        
parse(szLineText,LineName,31,LinePW,31)
        if(
equali(UserName,LineName)) {
            if(!
equal(UserPW,LinePW)) {
                
server_cmd("kick #%d ^"Server'a Giris Hakkiniz Yok Cunku PW Yanlis Girdiniz^"",get_user_userid(id))
                return PLUGIN_HANDLED
            }
        }
    }
    return PLUGIN_CONTINUE
    
}
public PasswordRequest(id) {
    if(is_user_registered(id)) {
        client_print(id,print_chat,"Zaten Nickiniz Sifreli")
        return PLUGIN_HANDLED
    }
    
    MessageModeByServer = true;
    client_cmd(id,"messagemode ^"Sifrenizi_Giriniz^"")
    return PLUGIN_HANDLED
}
public PasswordReceive(id) {
    if(!MessageModeByServer) {
        console_print(id,"Gecersiz Istek")
        return PLUGIN_HANDLED
    }
    new szText[32];
    read_args(szText,31)
    remove_quotes(szText)
    new cmd[10],szPW[32],others[32];
    parse(szText,cmd,9,szPW,31,others,31)
    remove_quotes(szPW)
    new szName[32];
    get_user_name(id,szName,31)
    MessageModeByServer = false;
    
    if(szPW[0] == 0) {
        client_print(id,print_chat,"Sifre Kismi Bos Birakilamaz")
        client_cmd(id,"messagemode ^"Sifrenizi_Giriniz^"")
        return PLUGIN_HANDLED
    }
    
    register_user(szName,szPW)
    print_color(id, "%L",id, "NICK_PW",szName,szPW)
    client_cmd(id,"setinfo _pw ^"%s^"",szPW)
    return PLUGIN_HANDLED
}
stock is_user_registered(id) {
    new name[32];
    get_user_name(id,name,31)
    
    new szLineText[128],txtlen;
    new LineName[64],LinePW[64];
    new maxlines;
    maxlines = file_size(USER_FILE,1);
    for(new line;line<maxlines;line++) {
        read_file(USER_FILE,line,szLineText,127,txtlen)
        parse(szLineText,LineName,63,LinePW,63)
        if(equali(name,LineName)) {
            return true;
        }
    }
    return false;
}
stock register_user(const szName[],const szPW[]) {
    new LineText[148];
    formatex(LineText,147,"^"%s^" ^"%s^"",szName,szPW)
    write_file(USER_FILE,LineText)
}

stock print_color(const id, const input[], any:...)
{
    new count = 1, players[32];
    static msg[191];
    vformat(msg, 190, input, 3);

    replace_all(msg, 190, "!g", "^4");
    replace_all(msg, 190, "!y", "^1");
    replace_all(msg, 190, "!t", "^3");   

    if(id) players[0] = id; else get_players(players, count, "ch");
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected(players[i]))
            {
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }

    return PLUGIN_HANDLED;

addons/amxmodx/data/lang/my_text.txt
Code:
Nickiniz Basariyla Sifrelendi. !gNick: %s !tPW: %s
============================================
2.This can also be used
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

static const GREENS[] = "^x04" //green

new const USER_FILE[] = "addons/amxmodx/configs/custom_users.ini";

new 
bool:MessageModeByServer;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    if(!
file_exists(USER_FILE)) {
        new 
fopen(USER_FILE,"wt");
        
fclose(f)
    }
    
    
register_clcmd("say /nickpw","PasswordRequest")
    
register_clcmd("Sifrenizi Giriniz","PasswordReceive")
    
}
public 
client_connect(id) {
    new 
UserPW[32],UserName[32];
    
get_user_info(id,"_pw",UserPW,31)
    
get_user_name(id,UserName,31)
    
    new 
maxlines file_size(USER_FILE,1);
    new 
szLineText[148],LineName[32],LinePW[32];
    new 
txtlen;
    for(new 
line;line<maxlines;line++) {
        
read_file(USER_FILE,line,szLineText,147,txtlen)
        
parse(szLineText,LineName,31,LinePW,31)
        if(
equali(UserName,LineName)) {
            if(!
equal(UserPW,LinePW)) {
                
server_cmd("kick #%d ^"Server'a Giris Hakkiniz Yok Cunku PW Yanlis Girdiniz^"",get_user_userid(id))
                return PLUGIN_HANDLED
            }
        }
    }
    return PLUGIN_CONTINUE
    
}
public PasswordRequest(id) {
    if(is_user_registered(id)) {
        client_print(id,print_chat,"Zaten Nickiniz Sifreli")
        return PLUGIN_HANDLED
    }
    
    MessageModeByServer = true;
    client_cmd(id,"messagemode ^"Sifrenizi Giriniz^"")
    return PLUGIN_HANDLED
}
public PasswordReceive(id) {
    if(!MessageModeByServer) {
        console_print(id,"Gecersiz Istek")
        return PLUGIN_HANDLED
    }
    new szText[32];
    read_args(szText,31)
    remove_quotes(szText)
    new cmd[10],szPW[32],others[32];
    parse(szText,cmd,9,szPW,31,others,31)
    remove_quotes(szPW)
    new szName[32];
    get_user_name(id,szName,31)
    MessageModeByServer = false;
    
    if(szPW[0] == 0) {
        client_print(id,print_chat,"Sifre Kismi Bos Birakilamaz")
        client_cmd(id,"messagemode ^"Sifrenizi Giriniz^"")
        return PLUGIN_HANDLED
    }
    
    register_user(szName,szPW)
    ColorChat(id, NORMAL, "Nickiniz Basariyla Sifrelendi. %sNick%s: %s %sPW%s: %s",GREENS,NORMALS,szName,REDS,NORMALS,szPW)
    client_cmd(id,"setinfo _pw ^"%s^"",szPW)
    return PLUGIN_HANDLED
}
stock is_user_registered(id) {
    new name[32];
    get_user_name(id,name,31)
    
    new szLineText[128],txtlen;
    new LineName[64],LinePW[64];
    new maxlines;
    maxlines = file_size(USER_FILE,1);
    for(new line;line<maxlines;line++) {
        read_file(USER_FILE,line,szLineText,127,txtlen)
        parse(szLineText,LineName,63,LinePW,63)
        if(equali(name,LineName)) {
            return true;
        }
    }
    return false;
}
stock register_user(const szName[],const szPW[]) {
    new LineText[148];
    formatex(LineText,147,"^"%s^" ^"%s^"",szName,szPW)
    write_file(USER_FILE,LineText)

addons/amxmodx/scripting/include/colorchat.inc
PHP Code:
/* Fun functions
*
* by Numb
*
* This file is provided as is (no warranties).
*/

#if defined _colorchat_included
  #endinput
#endif
#define _colorchat_included

enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    if( !
get_playersnum() ) return;
    
    new 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    new 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    static 
bool:saytext_used;
    static 
get_user_msgid_saytext;
    if(!
saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText");
        
saytext_used true;
    }
    
message_begin(typeget_user_msgid_saytext_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    static 
bool:teaminfo_used;
    static 
get_user_msgid_teaminfo;
    if(!
teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo");
        
teaminfo_used true;
    }
    
message_begin(typeget_user_msgid_teaminfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    new 
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
            return 
i;
    }

    return -
1;


Last edited by alferd; 02-17-2020 at 03:31.
alferd is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-17-2020 , 05:38   Re: print_chat color help
Reply With Quote #3

__________________

Last edited by OciXCrom; 02-17-2020 at 05:38.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 02-17-2020 , 06:10   Re: print_chat color help
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
Excellent

Last edited by alferd; 02-17-2020 at 06:10.
alferd is offline
svas
Junior Member
Join Date: Aug 2016
Location: Turkey
Old 02-17-2020 , 12:08   Re: print_chat color help
Reply With Quote #5

i m very sorry, but my mind is confused
i dont understand any
svas is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-17-2020 , 16:33   Re: print_chat color help
Reply With Quote #6

No, your mind is refusing to understand. You got a bunch of valid answers - use one. We can't spoon-feed you here.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 02-17-2020 , 16:35   Re: print_chat color help
Reply With Quote #7

Just follow every step he does in the video, it's not that hard.

1) Place the cromchat.inc file in scripting/include folder.
2) add
PHP Code:
#include <cromchat> 
in your code, like he does in the vid.
3) replace your current
PHP Code:
client_print() 
line with the
PHP Code:
CC_SendMessage() 
command. (Colors are also listed in the video.)
4) Recompile and you're ready to go.
__________________

Last edited by Napoleon_be; 02-17-2020 at 16:35.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-17-2020 , 16:52   Re: print_chat color help
Reply With Quote #8

He also needs to remove the "print_chat" argument. Still, if he didn't understand from watching a video, I doubt reading text would be any better.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
svas
Junior Member
Join Date: Aug 2016
Location: Turkey
Old 02-17-2020 , 17:12   Re: print_chat color help
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
No, your mind is refusing to understand. You got a bunch of valid answers - use one. We can't spoon-feed you here.
Yes, you are right. but I have never been in such an attitude or behavior or even thought. on the contrary, I really want to learn. thank you for your interest
svas is offline
svas
Junior Member
Join Date: Aug 2016
Location: Turkey
Old 02-17-2020 , 17:13   Re: print_chat color help
Reply With Quote #10

Quote:
Originally Posted by Napoleon_be View Post
Just follow every step he does in the video, it's not that hard.

1) Place the cromchat.inc file in scripting/include folder.
2) add
PHP Code:
#include <cromchat> 
in your code, like he does in the vid.
3) replace your current
PHP Code:
client_print() 
line with the
PHP Code:
CC_SendMessage() 
command. (Colors are also listed in the video.)
4) Recompile and you're ready to go.
thank you so much for your help and interest.
svas is offline
Reply


Thread Tools
Display Modes

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 10:46.


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