mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 18:38:26 +00:00
Add random rgb and random rgba for CS:S parsing.
{RGBX} - random rgb
{RGBAX} - random rgba
This commit is contained in:
parent
a20ca87b3b
commit
2153eddd37
@ -157,4 +157,9 @@ Chat **(NEW!)**
|
||||
- [x] Update cache for a player when his rank updates.
|
||||
- [x] Add `sm_ranks` `sm_chatranks`.
|
||||
- [x] Add `Shavit_FormatChat` native.
|
||||
- [ ] Add {randomrgb} and {randomrgba} for CS:S parsing.
|
||||
- [x] Add random rgb and random rgba for CS:S parsing.
|
||||
|
||||
Zones
|
||||
--
|
||||
- [ ] Make zones be trigger-based for high-performance.
|
||||
- [ ] Migrate zone settings and InsideZone() to use Dynamic.
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
// For CS:S, you have the following variables available: (NOTE: The format for colors is like HTML. RRGGBBAA)
|
||||
// {RGB} - like \x07, usage: "{RGB}FF0000" for red
|
||||
// {RGBA} - like \x08, usage: "{RGBA}FF0000FE" for 254 alpha red
|
||||
// {RGBX} - random rgb color
|
||||
// {RGBAX} - random rgba color
|
||||
//
|
||||
// CS:GO colors:
|
||||
// {team} will become purple for spectators
|
||||
|
||||
@ -416,20 +416,21 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
||||
|
||||
char[] sMessage = new char[300];
|
||||
strcopy(sMessage, 300, sArgs);
|
||||
ReplaceString(sMessage[0], 1, "!", "");
|
||||
ReplaceString(sMessage[0], 1, "/", "");
|
||||
|
||||
bool bCmd = false;
|
||||
Handle hCon = FindFirstConCommand(sMessage, 300, bCmd);
|
||||
|
||||
if(hCon != null)
|
||||
if(ReplaceString(sMessage[0], 1, "!", "") > 0 || ReplaceString(sMessage[0], 1, "/", "") > 0)
|
||||
{
|
||||
FindNextConCommand(hCon, sMessage, 300, bCmd);
|
||||
delete hCon;
|
||||
bool bCmd = false;
|
||||
Handle hCon = FindFirstConCommand(sMessage, 300, bCmd);
|
||||
|
||||
if(bCmd)
|
||||
if(hCon != null)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
FindNextConCommand(hCon, sMessage, 300, bCmd);
|
||||
delete hCon;
|
||||
|
||||
if(bCmd)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -559,6 +560,24 @@ public void FormatVariables(int client, char[] buffer, int maxlen, const char[]
|
||||
{
|
||||
ReplaceString(sTempFormattingRules, maxlen, "{RGB}", "\x07");
|
||||
ReplaceString(sTempFormattingRules, maxlen, "{RGBA}", "\x08");
|
||||
|
||||
char[] sColorBuffer = new char[16];
|
||||
|
||||
do
|
||||
{
|
||||
GetRandomHex(sColorBuffer, 6);
|
||||
Format(sColorBuffer, 16, "\x07%s", sColorBuffer);
|
||||
}
|
||||
|
||||
while(ReplaceStringEx(sTempFormattingRules, maxlen, "{RGBX}", sColorBuffer) > 0);
|
||||
|
||||
do
|
||||
{
|
||||
GetRandomHex(sColorBuffer, 8);
|
||||
Format(sColorBuffer, 16, "\x08%s", sColorBuffer);
|
||||
}
|
||||
|
||||
while(ReplaceStringEx(sTempFormattingRules, maxlen, "{RGBAX}", sColorBuffer) > 0);
|
||||
}
|
||||
|
||||
else
|
||||
@ -634,3 +653,28 @@ public int Native_FormatChat(Handle handler, int numParams)
|
||||
|
||||
return SetNativeString(6, sBuffer, maxlength);
|
||||
}
|
||||
|
||||
public void GetRandomHex(char[] buffer, int size)
|
||||
{
|
||||
char[] sHex = "0123456789abcdef";
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
buffer[i] = sHex[RealRandomInt(0, 15)];
|
||||
}
|
||||
|
||||
buffer[size+1] = '\0';
|
||||
}
|
||||
|
||||
// from SMLib
|
||||
public int RealRandomInt(int min, int max)
|
||||
{
|
||||
int random = GetURandomInt();
|
||||
|
||||
if(random == 0)
|
||||
{
|
||||
random++;
|
||||
}
|
||||
|
||||
return RoundToCeil(float(random) / (float(2147483647) / float(max - min + 1))) + min - 1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user