Closed hellyet closed 1 year ago
what if duration is not specified?
also.. the setTimeout with set to 3000 means it's forced to 3000.. what if i want 5000? i would use duration
parameter for that and would set the EndTextCommandDisplayHelp
last parameter to -1
in this case we can add a check that if duration is not specified it can be set to a default of 3000
Sorry, I forgot to remove the debugging code
---Show a floating help notification
---@param msg string @The message
---@param coords vector3 @The coordinates of the notification
---@param duration number @The display duration in milliseconds
---@return nil
function Notifications:ShowFloatingHelpNotification(msg, coords, duration)
Citizen.CreateThread(function()
local display_notification = true
Citizen.SetTimeout(duration, function() display_notification = false end)
while display_notification do
Citizen.Wait(0)
AddTextEntry("ScaleformUIFloatingHelpText", msg)
SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z)
SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
BeginTextCommandDisplayHelp("ScaleformUIFloatingHelpText")
EndTextCommandDisplayHelp(2, false, false, -1)
end
end)
end
That is how it must to be.
tbh 🤔 i would prefer a simpler function to be called per frame instead of a CreateThread inside a function.. 🤔
to make it multi-pourpose compatible.. i would simply revert it to the original and only remove the duration
parameter adding -1 to its behalf.. could you make it like that?
this way it's more like its ShowHelpNotification
counterpart
Now it's just a function needs to be called every frame.
thanks <3 this will maintain the same code format as the other functions!
Can you edit an WIKI section? Remove "duration" param and add example usage:
local coords = GetEntityCoods(PlayerPedId())
local duration = 3000 -- In milliseconds
Citizen.CreateThread(function()
local display_notification = true
Citizen.SetTimeout(duration, function() display_notification = false end)
while display_notification do
Citizen.Wait(0)
Notifications:ShowFloatingHelpNotification("This message will be removed in 3 seconds", coords)
end
end)
🤔 wiki should be open to PRs too.. will do when i get back home from office :D
See it :)
I've updated wiki.
Sorry for merge commit, it's my mistake