Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
|
02-17-2020
, 03:25
Re: print_chat color help
|
#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(PLUGIN, VERSION, AUTHOR) if(!file_exists(USER_FILE)) { new f = 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(PLUGIN, VERSION, AUTHOR) if(!file_exists(USER_FILE)) { new f = 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(id, Color: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], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server. message[192] = '^0';
new team, ColorChange, index, MSG_Type; if(id) { MSG_Type = MSG_ONE; index = id; } else { index = FindPlayer(); MSG_Type = MSG_ALL; } team = get_user_team(index); ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message); if(ColorChange) { Team_Info(index, MSG_Type, TeamName[team]); } }
ShowColorMessage(id, type, message[]) { 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(type, get_user_msgid_saytext, _, id); write_byte(id) write_string(message); message_end(); }
Team_Info(id, type, team[]) { 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(type, get_user_msgid_teaminfo, _, id); write_byte(id); write_string(team); message_end();
return 1; }
ColorSelection(index, type, Color:Type) { switch(Type) { case RED: { return Team_Info(index, type, TeamName[1]); } case BLUE: { return Team_Info(index, type, TeamName[2]); } case GREY: { return Team_Info(index, type, TeamName[0]); } }
return 0; }
FindPlayer() { new i = -1;
while(i <= get_maxplayers()) { if(is_user_connected(++i)) return i; }
return -1; }
Last edited by alferd; 02-17-2020 at 03:31.
|
|