fivem-target icon indicating copy to clipboard operation
fivem-target copied to clipboard

support interior type

Open AstroNext opened this issue 3 years ago • 0 comments

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)

AstroNext avatar Sep 30 '22 23:09 AstroNext