for all

mail@pastecode.io avatar
unknown
lua
3 years ago
1.9 kB
4
Indexable
function hitShape(shape, dim)
    if (not dim) then return false end
    if ( getElementType( source ) == "player" ) then
        local veh = getPedOccupiedVehicle(source)
        local isSeat = getPedOccupiedVehicleSeat(source)
        if (shape == colD) then
            if (not dot) then
                dot = dxCreateTexture(string.char(255,255,255,255,1,0,1,0))
                --outputChatBox(tostring(dot))
            end
            isInsideArea = true
            addEventHandler("onClientPreRender", root, showDXTiles)
        end
        if (not veh or veh and isSeat ~= 0) then
            return false
        end
        local color = getElementData(source, "color")
        if (not color) then
            return false
        end
        for i, v in pairs(cube) do
            if (shape == v) then
                owned[tiles[tostring(i)]] = color
                if (boost and not isNos) then
                    local bh = tonumber(i) - 1
                    local fr = tonumber(i) + 1
                    --outputChatBox(ls.." "..rs.." "..bh.." "..fr)
                    if (tiles[tostring(bh)]) then
                        owned[tiles[tostring(bh)]] = color
                    end
                    if (tiles[tostring(fr)]) then
                        owned[tiles[tostring(fr)]] = color
                    end
                end
            end
        end
    end
end
addEventHandler( "onClientElementColShapeHit", root, hitShape)

function leaveShape(shape, dim)
    if (not dim) then return end
    if ( getElementType( source ) == "player" ) then
        if (shape == colD) then
            isInsideArea = false
            removeEventHandler("onClientPreRender", root, showDXTiles)
        end
    end
end
addEventHandler("onClientElementColShapeLeave", root, leaveShape)