Как узнать цвет 3D Text?

moreveal

Известный
Проверенный
920
617
Lua:
local ffi = require 'ffi'
ffi.cdef[[
    struct stTextLabel
    {
        char            *pText;
        unsigned long   color;
        float           fPosition[3];
        float           fMaxViewDistance;
        unsigned char   byteShowBehindWalls;
        unsigned short  sAttachedToPlayerID;
        unsigned short  sAttachedToVehicleID;
    }__attribute__((packed));

    struct stTextLabelPool
    {
        struct stTextLabel    textLabel[2048];
        int                   iIsListed[2048];
    }__attribute__((packed));
]]

function getTextLabelInfo(id)
    local pool = ffi.cast("struct stTextLabelPool*", sampGetTextlabelPoolPtr())
    if pool.iIsListed[id] ~= 0 and pool.textLabel[id] ~= nil then
        return true, {
            id = id,
            text = ffi.string(pool.textLabel[id].pText),
            color = pool.textLabel[id].color,
            pos = { x = pool.textLabel[id].fPosition[0], y = pool.textLabel[id].fPosition[1], z = pool.textLabel[id].fPosition[2] },
            maxViewDist = pool.textLabel[id].fMaxViewDistance,
            showBehindWalls = pool.textLabel[id].byteShowBehindWalls,
            attachedPlayerId = pool.textLabel[id].sAttachedToPlayerID,
            attachedVehicleId = pool.textLabel[id].sAttachedToVehicleID
        }
    else return false end
end

---
local result, array = getTextLabelInfo(id)
if result then
    print(array.color)
else
    print("3d text not exist")
end