Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

draw dot on target location #70

Merged
merged 1 commit into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local screen = {}
local Config = Config
local listSprite = {}

---------------------------------------
--- Source: https://github.com/citizenfx/lua/blob/luaglm-dev/cfx/libs/scripts/examples/scripting_gta.lua
Expand Down Expand Up @@ -223,6 +224,24 @@ local NetworkGetNetworkIdFromEntity = NetworkGetNetworkIdFromEntity
local GetEntityModel = GetEntityModel
local IsPedAPlayer = IsPedAPlayer

local function DrawTarget()
CreateThread(function()
while not HasStreamedTextureDictLoaded("shared") do Wait(10) RequestStreamedTextureDict("shared", true) end
local wait
while targetActive do
wait = 500
for _, zone in pairs(listSprite) do
wait = 0
SetDrawOrigin(zone.center.x, zone.center.y, zone.center.z, 0)
DrawSprite("shared", "emptydot_32", 0, 0, 0.02, 0.035, 0, 255,255,255, 255.0)
ClearDrawOrigin()
end
Wait(wait)
end
listSprite = {}
end)
end

local function EnableTarget()
if not allowTarget or success or (Config.Framework == 'QB' and not LocalPlayer.state.isLoggedIn) or IsNuiFocused() then return end
if not CheckOptions then CheckOptions = _ENV.CheckOptions end
Expand All @@ -232,6 +251,7 @@ local function EnableTarget()
playerPed = PlayerPedId()
screen.ratio = GetAspectRatio(true)
screen.fov = GetFinalRenderedCamFov()
if Config.DrawSprite then DrawTarget() end

SendNUIMessage({response = 'openTarget'})
CreateThread(function()
Expand Down Expand Up @@ -350,12 +370,20 @@ local function EnableTarget()
end
else sleep += 20 end
if not success then
local closestDis, closestZone
for _, zone in pairs(Zones) do
local closestDis, closestZone, playerCoords
if Config.DrawSprite then playerCoords = GetEntityCoords(playerPed) end
for k, zone in pairs(Zones) do
if distance < (closestDis or Config.MaxDistance) and distance <= zone.targetoptions.distance and zone:isPointInside(coords) then
closestDis = distance
closestZone = zone
end
if Config.DrawSprite then
if #(playerCoords - zone.center) < (zone.targetoptions.drawDistance or Config.DrawDistance) then
listSprite[k] = zone
else
listSprite[k] = nil
end
end
end
if closestZone then
table_wipe(nuiData)
Expand Down
4 changes: 4 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Config.EnableDefaultOptions = true
-- Whether to have the target as a toggle or not
Config.Toggle = false

-- Draw sprite on location
Config.DrawSprite = false
Config.DrawDistance = 10.0

-- Enable outlines around the entity you're looking at
Config.EnableOutline = false

Expand Down