Senior Member
|
01-21-2021
, 02:15
Name prefix based on client
|
#1
|
Hello everyone,
Hope all is well amidst the pandemic.
Anyway, would like to seek for scripting help for name tags / prefix in-game.
Using this .sma in my server and it works really great, however I need to level it up:
PHP Code:
#include <amxmodx>
#include <amxmisc>
static const Plugin[] = "Clan Tag Checker";
static const Version[] = "2.0";
static const Author[] = "v3x";
#define ACCESS_LEVEL ADMIN_CFG // Access Level for amx_addtag command
#define MAX_TAGS 50 // *** You MUST change this if you're using 50+ clan tags! ***
#define MAX_TAG_LEN 25
#define MAX_STEAM_LEN 33
#define LOAD_FREQ 120.0 // Set to 0 to disable automatically loading after X seconds
public plugin_init() {
register_plugin(Plugin , Version , Author);
register_clcmd("amx_addplayer" , "AddPlayer" , ACCESS_LEVEL , "^"<tag>^" <nick,#userid>");
register_clcmd("amx_addsteam" , "AddSteam" , ACCESS_LEVEL , "^"<tag>^" <SteamID>");
register_concmd("amx_loadtags" , "Cmd_LoadTags" , ACCESS_LEVEL , " reloads tags file");
if(LOAD_FREQ > 0) {
set_task(LOAD_FREQ , "LoadTags" , 39819 , _ , _ , "b");
}
}
new g_szConfigsDir[64];
new bool:g_bIsValid[33];
new g_iNum = 0;
new g_szTag[MAX_TAGS][MAX_TAG_LEN];
new g_szSteamID[MAX_TAGS][MAX_STEAM_LEN];
new g_szTagFile[]="clan_tags.ini";
public client_connect(id) g_bIsValid[id] = true;
public client_disconnect(id) g_bIsValid[id] = true;
public client_authorized(id) {
new szUsername[33];
get_user_name(id , szUsername , 32);
CheckTag(id , szUsername);
}
public client_infochanged(id) {
new szUsername[33]
get_user_info(id , "name" , szUsername , 32);
CheckTag(id , szUsername);
}
public CheckTag(id , p_szName[]) {
for(new i = 0; i < MAX_TAGS; i++) {
new szAuthID[33];
get_user_authid(id , szAuthID , 32);
if(containi(p_szName , g_szTag[i]) == 0) {
if(!equali(szAuthID , g_szSteamID[i])) {
g_bIsValid[id] = false;
} else {
g_bIsValid[id] = true;
break;
}
}
}
set_task(3.0 , "CheckAgain" , id);
}
public Cmd_LoadTags(id , lvl , cid) {
if(!cmd_access(id , lvl , cid , 1)) {
return PLUGIN_HANDLED;
}
LoadTags();
switch(is_user_connected(id)) {
case 0: server_print("[CLAN-TAG] %i clan tag%s loaded" , g_iNum , (g_iNum > 0) ? "s" : "");
case 1: console_print(id , "[CLAN-TAG] %i clan tag%s loaded" , g_iNum , (g_iNum > 0) ? "s" : "");
}
return PLUGIN_HANDLED;
}
public LoadTags() {
get_configsdir(g_szConfigsDir , 63);
new szFileStr[64];
format(szFileStr , 63 , "%s/%s" , g_szConfigsDir , g_szTagFile);
if(file_exists(szFileStr)) {
new szText[164];
new nLen=0 , nLine=0;
while(read_file(szFileStr , nLine++ , szText , 163 , nLen)) {
new szTag[64] , szSteamID[64];
parse(szText, szTag , 63 , szSteamID , 63);
if(szTag[0] == ';' || !szText[0]) continue;
remove_quotes(szTag);
remove_quotes(szSteamID);
if(g_iNum >= MAX_TAGS-1) {
break;
}
format(g_szTag[g_iNum] , MAX_TAG_LEN-1, "%s" , szTag);
format(g_szSteamID[g_iNum] , MAX_STEAM_LEN-1 , "%s" , szSteamID);
g_iNum++;
}
}
else {
log_amx("[AMXX] Clan Tag file not found: %s" , szFileStr);
}
return PLUGIN_HANDLED;
}
public CheckAgain(id) {
new szUsername[33];
get_user_name(id , szUsername , 32);
if(!g_bIsValid[id] && is_user_connected(id) && strlen(szUsername)) {
server_cmd("kick #%d Clan Tag Protected" , get_user_userid(id));
client_print(0 , print_chat , "%s kicked, clan tag is protected" , szUsername);
server_print("%s kicked, clan tag is protected" , szUsername);
client_cmd(id , "echo **************************");
client_cmd(id , "echo Please change your tag! ");
client_cmd(id , "echo **************************");
return;
}
else if(g_bIsValid[id]) {
server_print("[CLAN-TAG] %s validated",szUsername)
}
}
public AddPlayer(id , level , cid) {
if(!cmd_access(id , level , cid , 3)) {
return PLUGIN_HANDLED;
}
new szArg1[64];
new szArg2[64];
read_argv(1 , szArg1 , 63);
read_argv(2 , szArg2 , 63);
new nTarget = cmd_target(id , szArg2 , 0);
if(!is_user_connected(nTarget)) {
return PLUGIN_HANDLED;
}
new szAuthID[64];
get_user_authid(nTarget , szAuthID , 63);
new szUsername[33];
get_user_name(nTarget , szUsername , 32);
get_configsdir(g_szConfigsDir , 63);
new szFileStr[64];
format(szFileStr , 63 , "%s/%s" , g_szConfigsDir , g_szTagFile);
new szTextStr[164];
format(szTextStr , 163 , "^n^"%s^" %s" , szArg1 , szAuthID);
if(file_exists(szFileStr)) {
write_file(szFileStr , szTextStr , -1);
console_print(id , "[CLAN-TAG] %s added with ^"%s^" tag!" , szUsername , szArg1);
LoadTags();
}
else if(!file_exists(szFileStr)) {
console_print(id , "[CLAN-TAG] Couldn't locate ^"%s^"!" , szFileStr);
}
return PLUGIN_HANDLED;
}
public AddSteam(id , level , cid) {
if(!cmd_access(id , level , cid , 3)) {
return PLUGIN_HANDLED;
}
new szArg1[64];
new szArg2[64];
read_argv(1 , szArg1 , 63);
read_argv(2 , szArg2 , 63);
if(!strlen(szArg1) || !strlen(szArg2)) {
return PLUGIN_HANDLED;
}
get_configsdir(g_szConfigsDir , 63);
new szFileStr[64];
format(szFileStr , 63 , "%s/%s" , g_szConfigsDir , g_szTagFile);
new szTextStr[164];
format(szTextStr , 163 , "^n^"%s^" %s" , szArg1 , szArg2);
if(file_exists(szFileStr)) {
write_file(szFileStr , szTextStr , -1);
console_print(id , "[CLAN-TAG] ^"%s^" added with ^"%s^" tag!" , szArg2 , szArg1);
LoadTags();
}
else if(!file_exists(szFileStr)) {
console_print(id , "[CLAN-TAG] Couldn't locate ^"%s^"!" , szFileStr);
}
return PLUGIN_HANDLED;
}
***THE REQUEST***
- Put Name Tags / Prefix when players launched hl.exe via different CSTRIKE launcher and not my launcher
- To determine players who uses different cstrike launchers aside from my server provided as client to match server files (weapon skins, sounds, etc.)
***BIG QUESTION***
- Is there a .sma that checks what client launcher players used to open hl.exe?
Thank you and looking forward!
|
|