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

[HELP] Set Player's Name Color


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 08-13-2019 , 07:46   [HELP] Set Player's Name Color
Reply With Quote #1

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 clientint args)
{
    if(
args 1)
    {
        
ReplyToCommand(client"[SM] Use: sm_nc <color> (examples: {red} {blue} {green} ...)");
    }
    
    
char arg[64];
    
GetCmdArg(1argsizeof(arg));
    
    
char file[512];
    
BuildPath(Path_SMfilesizeof(file), "nc.cfg");
    
KeyValues kv = new KeyValues("NC");
    
kv.ImportFromFile(file);
    
    
char sID[64];
    
GetClientAuthId(clientAuthId_Steam2sIDsizeof(sID));
    
    if(
KvJumpToKey(kvsIDtrue))
    {
        
char name[MAX_NAME_LENGTH];
        
char cor[64];
        
GetClientName(clientnamesizeof(name));
        
        
KvGetString(kv"nome"namesizeof(name));
        
KvGetString(kv"cor"corsizeof(cor));
        
        if(!
StrEqual(argcor))
        {
            
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(intauthorHandle recipientschar[] namechar[] message)
{
    
char file[512];
    
BuildPath(Path_SMfilesizeof(file), "nc.cfg");
    
    
KeyValues kv = new KeyValues("NC");
    
kv.ImportFromFile(file);
    
    
char sid[64];
    
GetClientAuthId(authorAuthId_Steam2sidsizeof(sid));
    if(
KvJumpToKey(kvsid))
    {
        
char color[64];
        
KvGetString(kv"cor"colorsizeof(color));
        
Format(nameMAX_NAME_LENGTH"%s%s"colorname);
    }

Where is the problem?

Best Regards,

SpirT.
__________________

Last edited by SpirT; 08-15-2019 at 09:53.
SpirT is offline
 



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 20:31.


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