Hey,
Today I tried to do by myself a plugin that changes, player's name color on chat.
I tried this but does not work:
PHP Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "SpirT"
#define PLUGIN_VERSION "1.0"
#include <sourcemod>
#include <sdktools>
#include <colors>
#pragma newdecls required
public Plugin myinfo =
{
name = "[SpirT] Name Color",
author = PLUGIN_AUTHOR,
description = "This plugin allows any player to have permission to change his name in chat!",
version = PLUGIN_VERSION,
url = ""
};
public void OnPluginStart()
{
RegConsoleCmd("sm_nc", Command_NameColor);
}
public Action Command_NameColor(int client, int args)
{
if(args < 1)
{
ReplyToCommand(client, "[SM] Use: sm_nc <color> (examples: {red} {blue} {green} ...)");
}
char arg[64];
GetCmdArg(1, arg, sizeof(arg));
char file[512];
BuildPath(Path_SM, file, sizeof(file), "nc.cfg");
KeyValues kv = new KeyValues("NC");
kv.ImportFromFile(file);
char sID[64];
GetClientAuthId(client, AuthId_Steam2, sID, sizeof(sID));
if(KvJumpToKey(kv, sID, true))
{
char name[MAX_NAME_LENGTH];
char cor[64];
GetClientName(client, name, sizeof(name));
KvGetString(kv, "nome", name, sizeof(name));
KvGetString(kv, "cor", cor, sizeof(cor));
if(!StrEqual(arg, cor))
{
KvSetString(kv, "cor", arg);
}
ReplyToCommand(client, "[SM] Sorry, but the color you choosed is already you name's color. Please choose another");
}
delete kv;
return Plugin_Handled;
}
public Action OnChatMessage(int& author, Handle recipients, char[] name, char[] message)
{
char file[512];
BuildPath(Path_SM, file, sizeof(file), "nc.cfg");
KeyValues kv = new KeyValues("NC");
kv.ImportFromFile(file);
char sid[64];
GetClientAuthId(author, AuthId_Steam2, sid, sizeof(sid));
if(KvJumpToKey(kv, sid))
{
char color[64];
KvGetString(kv, "cor", color, sizeof(color));
Format(name, MAX_NAME_LENGTH, "%s%s", color, name);
}
}
Where is the problem?
Best Regards,
SpirT.
__________________