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

Name prefix based on client


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
feren02
Senior Member
Join Date: Mar 2012
Old 01-21-2021 , 02:15   Name prefix based on client
Reply With Quote #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(idg_bIsValid[id] = true;
public 
client_disconnect(idg_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 
0MAX_TAGSi++) {
        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 
0server_print("[CLAN-TAG] %i clan tag%s loaded" g_iNum , (g_iNum 0) ? "s" "");
        case 
1console_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=nLine=0;
        while(
read_file(szFileStr nLine++ , szText 163 nLen)) {
            new 
szTag[64] , szSteamID[64];
            
parse(szTextszTag 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-"%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(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(szArg1 63);
    
read_argv(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(szArg1 63);
    
read_argv(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!
feren02 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-21-2021 , 07:25   Re: Name prefix based on client
Reply With Quote #2

What kind of "launchers" are we talking about here?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
feren02
Senior Member
Join Date: Mar 2012
Old 01-21-2021 , 22:00   Re: Name prefix based on client
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
What kind of "launchers" are we talking about here?
Hello! Shocks its OciX!!!

Just a normal cstrike launcher, default only. Or can I make my own CS launcher, that points and opens hl.exe to play?


Thank you for your support through the years.... Looking forward.
feren02 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-21-2021 , 23:16   Re: Name prefix based on client
Reply With Quote #4

A plugin won't be able to know what application was used to execute an executable on your operating system since it's the same application that would be running in the end. A plugin can read cvar values or user info so if one of those is set then that could be used by the plugin.
__________________

Last edited by fysiks; 01-21-2021 at 23:18.
fysiks is offline
feren02
Senior Member
Join Date: Mar 2012
Old 01-22-2021 , 23:00   Re: Name prefix based on client
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
A plugin won't be able to know what application was used to execute an executable on your operating system since it's the same application that would be running in the end. A plugin can read cvar values or user info so if one of those is set then that could be used by the plugin.
In my personal thought, CVARS are sometimes incompetitive to detect. Is there any other way around to TAG PLAYER NAMES when they launched hl.exe different from my CSTRIKE LAUNCHER? I am reading this forum all through out and seen some stuff relevant to my request...

If there is a way round please help me on it. Thank you for your usual support!
feren02 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-22-2021 , 23:26   Re: Name prefix based on client
Reply With Quote #6

Quote:
Originally Posted by feren02 View Post
In my personal thought, CVARS are sometimes incompetitive to detect. Is there any other way around to TAG PLAYER NAMES when they launched hl.exe different from my CSTRIKE LAUNCHER? I am reading this forum all through out and seen some stuff relevant to my request...

If there is a way round please help me on it. Thank you for your usual support!
You're not getting any good answers because your request makes no sense. Also, I already told you not is not possible to know how the executable was launched.
__________________

Last edited by fysiks; 01-22-2021 at 23:26.
fysiks is offline
feren02
Senior Member
Join Date: Mar 2012
Old 01-22-2021 , 23:29   Re: Name prefix based on client
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
A plugin won't be able to know what application was used to execute an executable on your operating system since it's the same application that would be running in the end. A plugin can read cvar values or user info so if one of those is set then that could be used by the plugin.
In my personal thought, CVARS are sometimes incompetitive to detect. Is there any other way around to TAG PLAYER NAMES when they launched hl.exe different from my CSTRIKE LAUNCHER? I am reading this forum all through out and seen some stuff relevant to my request...

If there is a way round please help me on it. Thank you for your usual support!
feren02 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-23-2021 , 07:46   Re: Name prefix based on client
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
A plugin won't be able to know what application was used to execute an executable on your operating system since it's the same application that would be running in the end. A plugin can read cvar values or user info so if one of those is set then that could be used by the plugin.

Quote:
Originally Posted by fysiks View Post
You're not getting any good answers because your request makes no sense. Also, I already told you not is not possible to know how the executable was launched.
__________________









Last edited by CrazY.; 01-23-2021 at 07:46.
CrazY. 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 18:22.


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