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

Commit

Permalink
feat(client): color configs for DrawSprite
Browse files Browse the repository at this point in the history
  • Loading branch information
BerkieBb committed Apr 19, 2022
1 parent eac143e commit bdcc6e3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
28 changes: 23 additions & 5 deletions client.lua
Expand Up @@ -232,16 +232,30 @@ local RequestStreamedTextureDict = RequestStreamedTextureDict
local function DrawTarget()
CreateThread(function()
while not HasStreamedTextureDictLoaded("shared") do Wait(10) RequestStreamedTextureDict("shared", true) end
local wait
local sleep
local r, g, b, a
while targetActive do
wait = 500
sleep = 500
for _, zone in pairs(listSprite) do
wait = 0
sleep = 0

r = zone.targetoptions.drawColor?[1] or Config.DrawColor[1]
g = zone.targetoptions.drawColor?[2] or Config.DrawColor[2]
b = zone.targetoptions.drawColor?[3] or Config.DrawColor[3]
a = zone.targetoptions.drawColor?[4] or Config.DrawColor[4]

if zone.success then
r = zone.targetoptions.successDrawColor?[1] or Config.SuccessDrawColor[1]
g = zone.targetoptions.successDrawColor?[2] or Config.SuccessDrawColor[2]
b = zone.targetoptions.successDrawColor?[3] or Config.SuccessDrawColor[3]
a = zone.targetoptions.successDrawColor?[4] or Config.SuccessDrawColor[4]
end

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)
DrawSprite("shared", "emptydot_32", 0, 0, 0.02, 0.035, 0, r, g, b, a)
ClearDrawOrigin()
end
Wait(wait)
Wait(sleep)
end
listSprite = {}
end)
Expand Down Expand Up @@ -407,6 +421,7 @@ local function EnableTarget()
if next(nuiData) then
success = true
SendNUIMessage({response = 'validTarget', data = nuiData})
listSprite[closestZone.name].success = true
DrawOutlineEntity(entity, true)
while targetActive and success do
local coords, distance = RaycastCamera(flag)
Expand All @@ -420,6 +435,9 @@ local function EnableTarget()
end
Wait(0)
end
if listSprite[closestZone.name] then -- Check for when the targetActive is false and it removes the zone from listSprite
listSprite[closestZone.name].success = false
end
LeaveTarget()
DrawOutlineEntity(entity, false)
else
Expand Down
14 changes: 11 additions & 3 deletions init.lua
Expand Up @@ -29,14 +29,22 @@ Config.EnableDefaultOptions = true
-- Whether to have the target as a toggle or not
Config.Toggle = false

-- Draw sprite on location
-- Draw a Sprite on the center of a PolyZone to hint where it's located
Config.DrawSprite = false

-- The default distance to draw the Sprite
Config.DrawDistance = 10.0

-- The color of the sprite in rgb, the first value is red, the second value is green, the third value is blue and the last value is alpha (opacity). Here is a link to a color picker to get these values: https://htmlcolorcodes.com/color-picker/
Config.DrawColor = {255, 255, 255, 255}

-- The color of the sprite in rgb when the PolyZone is targeted, the first value is red, the second value is green, the third value is blue and the last value is alpha (opacity). Here is a link to a color picker to get these values: https://htmlcolorcodes.com/color-picker/
Config.SuccessDrawColor = {98, 135, 236, 255}

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

-- The color of the outline in rgb, the first value is red, the second value is green, the third value is blue and the last value is alpha. Here is a link to a color picker to get these values: https://htmlcolorcodes.com/color-picker/
-- The color of the outline in rgb, the first value is red, the second value is green, the third value is blue and the last value is alpha (opacity). Here is a link to a color picker to get these values: https://htmlcolorcodes.com/color-picker/
Config.OutlineColor = {255, 255, 255, 255}

-- Control for key press detection on the context menu, it's the Left Mouse Button by default, controls are found here https://docs.fivem.net/docs/game-references/controls/
Expand All @@ -45,7 +53,7 @@ Config.MenuControlKey = 237
-- Key to open the target eye, here you can find all the names: https://docs.fivem.net/docs/game-references/input-mapper-parameter-ids/keyboard/
Config.OpenKey = 'LMENU' -- Left Alt

-- Supported values: ESX, QB, false
-- Supported values: 'ESX', 'QB', false
Config.Framework = false

-------------------------------------------------------------------------------
Expand Down

0 comments on commit bdcc6e3

Please sign in to comment.