@@ -783,8 +783,8 @@ function GetPVarString(amx, player, varname, outbuf, length)
783
783
return 0
784
784
end
785
785
786
- if # value [2 ] < maxlength then
787
- writeMemString (amx , outbuf , value )
786
+ if # value [2 ] < length then
787
+ writeMemString (amx , outbuf , value [ 2 ] )
788
788
else
789
789
writeMemString (amx , outbuf , string.sub (value , 0 , length - 1 ))
790
790
end
@@ -1064,13 +1064,31 @@ function SendClientMessage(amx, player, r, g, b, a, message)
1064
1064
message = message :gsub (' /' .. samp , ' /' .. mta )
1065
1065
end
1066
1066
end
1067
- outputChatBox (message , player , r , g , b )
1067
+
1068
+ -- replace colors
1069
+ message = result :gsub (" (=?{[0-9A-Fa-f]*})" ,
1070
+ function (colorMatches )
1071
+ colorMatches = colorMatches :gsub (" [{}]+" , " " ) -- replace the curly brackets with nothing
1072
+ colorMatches = ' #' .. colorMatches -- Append to the beginning
1073
+ return colorMatches
1074
+ end )
1075
+
1076
+ outputChatBox (message , player , r , g , b , true )
1068
1077
end
1069
1078
1070
1079
function SendClientMessageToAll (amx , r , g , b , a , message )
1071
1080
if (amx .proc == ' OnPlayerConnect' and message :match (' joined' )) or (amx .proc == ' OnPlayerDisconnect' and message :match (' left' )) then
1072
1081
return
1073
1082
end
1083
+
1084
+ -- 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
+
1074
1092
for i ,data in pairs (g_Players ) do
1075
1093
SendClientMessage (amx , data .elem , r , g , b , a , message )
1076
1094
end
@@ -1081,11 +1099,11 @@ function SendDeathMessage(amx, killer, victim, reason)
1081
1099
end
1082
1100
1083
1101
function SendPlayerMessageToAll (amx , sender , message )
1084
- outputChatBox (getPlayerName (sender ) .. ' ' .. message , root , 255 , 255 , 255 )
1102
+ outputChatBox (getPlayerName (sender ) .. ' ' .. message , root , 255 , 255 , 255 , true )
1085
1103
end
1086
1104
1087
1105
function SendPlayerMessageToPlayer (amx , playerTo , playerFrom , message )
1088
- outputChatBox (getPlayerName (playerFrom ) .. ' ' .. message , playerTo , 255 , 255 , 255 )
1106
+ outputChatBox (getPlayerName (playerFrom ) .. ' ' .. message , playerTo , 255 , 255 , 255 , true )
1089
1107
end
1090
1108
1091
1109
function SendRconCommand (amx , command )
@@ -1823,8 +1841,18 @@ function format(amx, outBuf, outBufSize, fmt, ...)
1823
1841
i = i - 1
1824
1842
end
1825
1843
end
1844
+
1826
1845
fmt = fmt :gsub (' (%%[%-%d%.]*)%*(%a)' , ' %1%2' )
1827
1846
local result = fmt :format (unpack (args ))
1847
+
1848
+ -- 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
+
1828
1856
if # result + 1 <= outBufSize then
1829
1857
writeMemString (amx , outBuf , result )
1830
1858
end
@@ -2270,13 +2298,13 @@ end
2270
2298
function GetVehicleParamsEx (amx , vehicle , refEngine , refLights , refAlarm , refDoors , refBonnet , refBoot , refObjective )
2271
2299
local vehicleID = getElemID (vehicle )
2272
2300
2273
- amx .memDAT [refEngine ] = getVehicleEngineState (vehicle )
2274
- amx .memDAT [refLights ] = getVehicleOverrideLights (vehicle ) == 2 and true or false
2275
- amx .memDAT [refAlarm ] = g_Vehicles [vehicleID ].alarm
2276
- amx .memDAT [refDoors ] = isVehicleLocked (vehicle )
2301
+ amx .memDAT [refEngine ] = getVehicleEngineState (vehicle ) and 1 or 0 -- Lua expects this to be an int, so cast it
2302
+ amx .memDAT [refLights ] = getVehicleOverrideLights (vehicle ) == 2 and 1 or 0
2303
+ amx .memDAT [refAlarm ] = g_Vehicles [vehicleID ].alarm and 1 or 0
2304
+ amx .memDAT [refDoors ] = isVehicleLocked (vehicle ) and 1 or 0
2277
2305
amx .memDAT [refBonnet ] = getVehicleDoorOpenRatio (vehicle , 0 ) > 0
2278
2306
amx .memDAT [refBoot ] = getVehicleDoorOpenRatio (vehicle , 1 ) > 0
2279
- amx .memDAT [refObjective ] = g_Vehicles [vehicleID ].objective or false
2307
+ amx .memDAT [refObjective ] = g_Vehicles [vehicleID ].objective or 0
2280
2308
2281
2309
return 1
2282
2310
end
0 commit comments