This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[INC] ColorVariables


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 19:47.


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