Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LUA] ShowFloatingHelpNotification Fix #133

Merged
merged 4 commits into from May 15, 2023
Merged

Conversation

hellyet
Copy link
Contributor

@hellyet hellyet commented May 15, 2023

No description provided.

@hellyet
Copy link
Contributor Author

hellyet commented May 15, 2023

Sorry for merge commit, it's my mistake

@manups4e
Copy link
Owner

what if duration is not specified?

@manups4e
Copy link
Owner

manups4e commented May 15, 2023

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

@hellyet
Copy link
Contributor Author

hellyet commented May 15, 2023

Sorry, I forgot to remove the debugging code

@hellyet
Copy link
Contributor Author

hellyet commented May 15, 2023

---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.

@manups4e
Copy link
Owner

manups4e commented May 15, 2023

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

@hellyet
Copy link
Contributor Author

hellyet commented May 15, 2023

Now it's just a function needs to be called every frame.

@manups4e
Copy link
Owner

thanks <3 this will maintain the same code format as the other functions!

@manups4e manups4e merged commit b50cde8 into manups4e:master May 15, 2023
@hellyet
Copy link
Contributor Author

hellyet commented May 15, 2023

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)

@manups4e
Copy link
Owner

🤔 wiki should be open to PRs too.. will do when i get back home from office :D

@hellyet
Copy link
Contributor Author

hellyet commented May 15, 2023

See it :)

@hellyet
Copy link
Contributor Author

hellyet commented May 15, 2023

I've updated wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants