meta-hub / fivem-target

Mostly re-written version of bt-target.
15 stars 7 forks source link

support interior type #10

Open AstroNext opened 2 years ago

AstroNext commented 2 years ago

Hi I think this resource missed interior support. I edit my resource with these codes.

exports

exports('AddTargetInterior',function(opts) 
    if not opts or not opts.name or not opts.label or not opts.interiorId or not opts.options then error("Invalid opts for AddTargetInterior",1) return end
    table.insert(allTargets,{
        typeof        = "interior",
        name          = opts.name,
        label         = opts.label,
        icon          = opts.icon or "fas fa-question",
        interiorId    = opts.interiorId,
        onInteract    = opts.onInteract,
        options       = opts.options,
        vars          = opts.vars,
        resource      = GetInvokingResource()
    })
end)

Loop

if v.typeof == "interior" then
    if GetInteriorFromEntity(PlayerPedId()) == v.interiorId then
        targets[v.name] = v
        if not activeTargets[v.name] then
            updateTargets = true
        end
    else
        if activeTargets[v.name] then
            activeTargets[v.name] = false
            updateTargets = true
        end
    end
end

Command

RegisterCommand('interiorid', function()
    local ped = PlayerPedId()
    local interior = GetInteriorFromEntity(ped)
    if IsValidInterior(interior) then
        local group = GetInteriorGroupId(interior)
        local heading = GetInteriorHeading(interior)
        local coords, hash = GetInteriorLocationAndNamehash(interior)
        print('Id : ' .. interior, 'Group : ' ..group,'Heading : '..heading, 'Coords : ' .. coords,"Hash : " ..hash)
    end
end)