local sampev, vkeys = require 'lib.samp.events', require 'lib.vkeys'
local main_color = 0xFF0000
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('color', color)
while true do
wait(0)
end
end
function color(id)
local color = sampGetPlayerColor(id)
sampAddChatMessage("color: "..color, -1)
local aa, rr, gg, bb = explode_argb(color)
local color = join_argb(255, rr, gg, bb)
sampAddChatMessage("{"..color.."}"..'123', -1)
end
function explode_argb(argb)
local a = bit.band(bit.rshift(argb, 24), 0xFF)
local r = bit.band(bit.rshift(argb, 16), 0xFF)
local g = bit.band(bit.rshift(argb, 8), 0xFF)
local b = bit.band(argb, 0xFF)
return a, r, g, b
end
function join_argb(a, r, g, b)
local argb = b -- b
argb = bit.bor(argb, bit.lshift(g, 8)) -- g
argb = bit.bor(argb, bit.lshift(r, 16)) -- r
argb = bit.bor(argb, bit.lshift(a, 24)) -- a
return argb
end