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_NAME, PLUGIN_VERSION);
}
public void OnClientPostAdminCheck(int client) {
if (GetUserAdmin(client) != INVALID_ADMIN_ID) {
char strNickname[156];
Format(strNickname, sizeof(strNickname), "CLANTAG %N", client);
SetClientName(client, strNickname);
}
}
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[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
char strNickname[256];
Format(strNickname, sizeof(strNickname), "%N", client);
PrintToChat(client, "Name atm %s",strNickname);
ReplaceString(strNickname, 256, "CLANTAG" , "");
PrintToChat(client, "Name after stringreplace %s",strNickname);
Format(strNickname, 256, "%s", strNickname);
SetClientName(client, strNickname);
if (GetUserAdmin(client) != INVALID_ADMIN_ID) {
Format(strNickname, 256, "CLANTAG %N", client);
SetClientName(client, strNickname);
}
}
__________________