@@ -1066,14 +1066,17 @@ function SendClientMessage(amx, player, r, g, b, a, message)
1066
1066
end
1067
1067
1068
1068
-- replace colors
1069
- message = result :gsub (" (=?{[0-9A-Fa-f]*})" ,
1069
+ outputChatBox (colorizeString (message ), player , r , g , b , true )
1070
+ end
1071
+
1072
+ -- replace colors
1073
+ function colorizeString (string )
1074
+ return string :gsub (" (=?{[0-9A-Fa-f]*})" ,
1070
1075
function (colorMatches )
1071
1076
colorMatches = colorMatches :gsub (" [{}]+" , " " ) -- replace the curly brackets with nothing
1072
1077
colorMatches = ' #' .. colorMatches -- Append to the beginning
1073
1078
return colorMatches
1074
1079
end )
1075
-
1076
- outputChatBox (message , player , r , g , b , true )
1077
1080
end
1078
1081
1079
1082
function SendClientMessageToAll (amx , r , g , b , a , message )
@@ -1082,13 +1085,8 @@ function SendClientMessageToAll(amx, r, g, b, a, message)
1082
1085
end
1083
1086
1084
1087
-- replace colors
1085
- message = result :gsub (" (=?{[0-9A-Fa-f]*})" ,
1086
- function (colorMatches )
1087
- colorMatches = colorMatches :gsub (" [{}]+" , " " ) -- replace the curly brackets with nothing
1088
- colorMatches = ' #' .. colorMatches -- Append to the beginning
1089
- return colorMatches
1090
- end )
1091
-
1088
+ message = colorizeString (message )
1089
+
1092
1090
for i ,data in pairs (g_Players ) do
1093
1091
SendClientMessage (amx , data .elem , r , g , b , a , message )
1094
1092
end
@@ -1846,15 +1844,8 @@ function format(amx, outBuf, outBufSize, fmt, ...)
1846
1844
local result = fmt :format (unpack (args ))
1847
1845
1848
1846
-- replace colors
1849
- result = result :gsub (" (=?{[0-9A-Fa-f]*})" ,
1850
- function (colorMatches )
1851
- colorMatches = colorMatches :gsub (" [{}]+" , " " ) -- replace the curly brackets with nothing
1852
- colorMatches = ' #' .. colorMatches -- Append to the beginning
1853
- return colorMatches
1854
- end )
1855
-
1856
1847
if # result + 1 <= outBufSize then
1857
- writeMemString (amx , outBuf , result )
1848
+ writeMemString (amx , outBuf , colorizeString ( result ) )
1858
1849
end
1859
1850
end
1860
1851
0 commit comments