Raised This Month: $7 Target: $400
 1% 

[INC] ColorVariables


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-31-2015 , 16:24   [INC] ColorVariables
Reply With Quote #1

In layman's terms:
Plugin developers are not supposed to use actual colors, but variables which can be easily set by server masters.

How does it work?

  1. Create a plugin with ColorVariables
  2. Use color variables in chat messages and not actual colors
  3. Optional: If you need some new variables, create them with CAddVariable
  4. Optional: If you want, you can create a forwarded variable for other plugins to use (like {@isRebel CLIENT_INDEX}, {@rank CLIENT_INDEX}, {@rainbow} etc.)
  5. Optional: If you want to use variables from other plugins, load them with CLoadPluginConfig or CLoadPluginVariables (If server master renamed plugin binary, this won't work!)

Quick example:

Normal: PrintToChatAll("\x02[prefix]\x01 %N gave you \x03AK-47\x01!", client)
ColorVariables: CPrintToChatAll("%N gave you {highlight}AK-47{default}!", client)

ColorVariables plugin example:
PHP Code:
#include <colorvariables>

public OnPluginStart()
{
    
CSetPrefix("KillInfo"); // Set plugin chat prefix to "KillInfo" (will be used in every print function)

    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));

    
CPrintToChatAll("{player %d}%N {default} killed {player %d}%N"attackerattackervictimvictim);
    
// {prefix}[KillInfo] {teamcolor}Will {default}killed {teamcolor}Mark

    
CPrintToChat(victim"{highlight}Player {player %d}%N {highlight}killed you!"attackerattacker);
    
// {prefix}[KillInfo] {highlight}Player {teamcolor}Will {highlight}killed you!

    
return Plugin_Continue

More info, full feature list and download in GitHub repository.

Last edited by KissLick; 03-13-2016 at 19:06.
KissLick is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 03-10-2016 , 11:38   Re: [INC] ColorVariables
Reply With Quote #2

This thread needs more comments! Finally an include for colors across games, and very well written too. The only issue I had is that {teamcolor} is not in the list for Source 2009 games, I had to add it myself.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 03-10-2016 , 16:30   Re: [INC] ColorVariables
Reply With Quote #3

Quote:
Originally Posted by DJ Tsunami View Post
This thread needs more comments! Finally an include for colors across games, and very well written too. The only issue I had is that {teamcolor} is not in the list for Source 2009 games, I had to add it myself.
Thx! I really appreciate that! As for the {teamcolor}, looks like I forgot that one O:-) - gonna add it.

EDIT:
Oh I think I remember why there is no {teamcolor}, you can use {player CLIENT_INDEX} to get a player's team color. But anyway, I will have a look at it.
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 03-10-2016 at 16:47.
KissLick is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 03-11-2016 , 03:08   Re: [INC] ColorVariables
Reply With Quote #4

Wish I knew about this include sooner, It would've been useful a few months ago. :/

Thanks for the release!
Drixevel is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 03-11-2016 , 03:43   Re: [INC] ColorVariables
Reply With Quote #5

Quote:
Originally Posted by KissLick View Post
you can use {player CLIENT_INDEX} to get a player's team color.
True, but in my case (Advertisements) the server administrator gets to choose the messages and where to put the colors, and I don't want to have to figure out where they put {player %d} and then inject the client index I know {engine 3} also works, but {teamcolor} is easier for people to remember
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 03-11-2016 at 03:44.
DJ Tsunami is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 03-11-2016 , 06:57   Re: [INC] ColorVariables
Reply With Quote #6

Just added {teamcolor} to Source2009 colors :-)

But there still is that little problem with loading foreign color config whose binary was renamed... I would like to fix that somehow, but I am very unsure how.... Any ideas, please? O:-)
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 03-11-2016 , 08:35   Re: [INC] ColorVariables
Reply With Quote #7

This include seems very useful. I will use it from now
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 03-11-2016 , 10:24   Re: [INC] ColorVariables
Reply With Quote #8

Quote:
Originally Posted by Franc1sco View Post
This include seems very useful. I will use it from now
Dear God... Now Valve can say I collaborated on some new weapon skins plugin... uaaaaaaaaaaaaaaaaaaaaaaaaaa it's driving me crazyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy :-D
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 03-11-2016 , 10:51   Re: [INC] ColorVariables
Reply With Quote #9

Quote:
Originally Posted by KissLick View Post
Dear God... Now Valve can say I collaborated on some new weapon skins plugin... uaaaaaaaaaaaaaaaaaaaaaaaaaa it's driving me crazyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy :-D
Sure ;)
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 03-11-2016 at 10:53.
Franc1sco is offline
Send a message via MSN to Franc1sco
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 06-19-2016 , 10:15   Re: [INC] ColorVariables
Reply With Quote #10

I get this error when compiling my plugin:
Code:
//// admin-see-all-chat.sp
//
// sourcemod\addons\sourcemod\scripting\include\colorvariables.inc(147) : error 017: undefined symbol "iTeam"
// sourcemod\addons\sourcemod\scripting\include\colorvariables.inc(153) : error 001: expected token: ")", but found "~"
// sourcemod\addons\sourcemod\scripting\include\colorvariables.inc(153) : warning 215: expression has no effect
// sourcemod\addons\sourcemod\scripting\include\colorvariables.inc(153) : error 001: expected token: ";", but found ")"
// sourcemod\addons\sourcemod\scripting\include\colorvariables.inc(153) : error 029: invalid expression, assumed zero
// sourcemod\addons\sourcemod\scripting\include\colorvariables.inc(153) : fatal error 189: too many error messages on one line
//
// Compilation aborted.
// 5 Errors.
//
// Compilation Time: 0,8 sec

Last edited by condolent; 06-19-2016 at 10:16.
condolent is offline
Reply


Thread Tools
Display Modes

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 01:46.


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