View Single Post
Author Message
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin D.
Old 02-24-2022 , 01:42   Rename players to prevent taking CLAN tag
Reply With Quote #1

Hi,

I use this easy script below to give admins a clantag.

How can I modify this to prevent other players from using

setinfo name CLANTAG playername

The innitial idea was to hook playerrename, then string replace name and then rename player.
After that rename the admins.

That would cause the hook again and ends in a loop bc I set playername and fire rename player hook again.

Another problem I had was when I hook playerrename I only see the oldplayer name with
Format(strNickname, sizeof(strNickname), "%N", client);
But you would need the new player name to do the string replace.

Below is the old script with the attempt, below below is the new attempt that ends in mess.

I guess it is the wrong approach...

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

#define PLUGIN_NAME "[INS] Admin TAG"
#define PLUGIN_VERSION "0.02"

public Plugin myinfo = {
    
name PLUGIN_NAME,
    
author "Linothorax",
    
description "Add [♛] infront of Playername",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart() {
    
PrintToServer("Loaded %s v%s"PLUGIN_NAMEPLUGIN_VERSION);
}

public 
void OnClientPostAdminCheck(int client) {
    if (
GetUserAdmin(client) != INVALID_ADMIN_ID) {
        
char strNickname[156];
        
Format(strNicknamesizeof(strNickname), "CLANTAG %N"client);
        
SetClientName(clientstrNickname);
    }


PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

#define PLUGIN_NAME "TAG"
#define PLUGIN_VERSION "0.0.1"

public Plugin myinfo = {
    
name PLUGIN_NAME,
    
author "TAG",
    
description "TAG",
    
version PLUGIN_VERSION,
    
url ""
};


public 
void OnPluginStart()
{
        
HookEvent("player_changename"_renameifneeded);
        
HookEvent("player_connect_full"_renameifneeded);
}


public 
void _renameifneeded(Event event, const char[] namebool dontBroadcast)
{
        
int client GetClientOfUserId(GetEventInt(event"userid"));
        
char strNickname[256];
        
Format(strNicknamesizeof(strNickname), "%N"client);
        
PrintToChat(client"Name atm %s",strNickname);
        
ReplaceString(strNickname256"CLANTAG" "");
        
PrintToChat(client"Name after stringreplace %s",strNickname);
        
Format(strNickname256"%s"strNickname);
        
SetClientName(clientstrNickname);
        if (
GetUserAdmin(client) != INVALID_ADMIN_ID) {
        
Format(strNickname256"CLANTAG %N"client);
        
SetClientName(clientstrNickname);
    }


__________________

Last edited by finishlast; 02-24-2022 at 01:50.
finishlast is offline