Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 5:08 AM] lowheartrate: Anyone have any experience using NativeUILua-Reloaded? I am having an issue trying to use the progress bar: https://github.com/iTexZoz/NativeUILua_Reloaded/issues/54
- [5:16 AM] JohnAA12: Did you include the progress bar files?
- [5:17 AM] JohnAA12: ex: client_scripts {
- "@NativeUILua-Reloaded/UIProgressBar/UIProgressBarPool.lua",
- "@NativeUILua-Reloaded/UIProgressBar/items/UIProgressBarItem.lua"
- }
- [5:18 AM] lowheartrate: @JohnAA12 This is my __resource.lua: https://pastebin.com/BBg82VLg
- [5:21 AM] JohnAA12:
- RegisterNetEvent('NativeUI:progress')
- AddEventHandler('NativeUI:progress', function()
- local _progressBarPool = NativeUI.ProgressBarPool()
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- _ProgressBarPool:Draw()
- end
- end)
- local Item = NativeUI.CreateProgressBarItem("Récolte en cours...")
- _ProgressBarPool:Add(Item)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- if (progress >= 100) then
- progress = 0
- else
- progress = progress + 0.1
- end
- Item:SetPercentage(progress)
- end
- end)
- end)
- [5:22 AM] JohnAA12: when you make the progress bar pool you use _progressBarPool
- [5:22 AM] JohnAA12: but you're calling _ProgressBarPool
- [5:23 AM] JohnAA12: also you need to define progress
- [5:28 AM] lowheartrate: progess is define in the if / else statements.
- [5:28 AM] JohnAA12: You need to define it first
- [5:28 AM] JohnAA12: progress is nil by default
- [5:28 AM] JohnAA12: if (nil >= 100) will error
- [5:29 AM] lowheartrate: I am trying to make the progress bar run until the player is done washing their money (delay of 3.5 minutes).
- [5:29 AM] JohnAA12: You have to call local progress = 0 outside of the while true loop for the progress
- [5:30 AM] JohnAA12: or it won't move at all
- [5:30 AM] lowheartrate: gotcha, something like this look better?
- RegisterNetEvent('NativeUI:progress')
- AddEventHandler('NativeUI:progress', function()
- local _progressBarPool = NativeUI.ProgressBarPool()
- local progress = 0
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- _progressBarPool:Draw()
- end
- end)
- local Item = NativeUI.CreateProgressBarItem("RĂ©colte en cours...")
- _progressBarPool:Add(Item)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- if (progress >= 100) then
- progress = 0
- else
- progress = progress + 0.1
- end
- Item:SetPercentage(progress)
- end
- end)
- end)
- [5:30 AM] JohnAA12: you still have _ProgressBarPool instead of _progressBarPool
- [5:31 AM] lowheartrate: edited
- [5:31 AM] JohnAA12: Okay? That should work
- [5:31 AM] lowheartrate: I'll go try it out.
- [5:31 AM] JohnAA12: But that progress is not in any way 3.5 minutes
- [5:31 AM] JohnAA12: you'll have to adjust the math for it
- [5:31 AM] lowheartrate: Gotcha
- [5:35 AM] lowheartrate: I'm getting this error now: https://i.imgur.com/MKxWCJm.png
- [5:36 AM] JohnAA12: you need to add manifest version to __resource.lua
- [5:37 AM] JohnAA12: resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
- [5:37 AM] lowheartrate: That one specifically or the latest?
- resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
- [5:38 AM] JohnAA12: Any works
- [5:38 AM] JohnAA12: From what i've tested
- [5:39 AM] JohnAA12: "Technically" the latest one is05cfa83c-a124-4cfa-a768-c24a5811d8f9
- [5:39 AM] lowheartrate: Awesome works! Just got to get it so the bar takes 3.5 minutes to load, currently it takes just a few seconds and restarts.
- [5:41 AM] lowheartrate: How would I go about changing the amount of time it takes to load? Would I replace
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- if (progress >= 100) then
- progress = 0
- else
- progress = progress + 0.1
- end
- Item:SetPercentage(progress)
- end
- end)
- with something like:
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(< 3.5 MINUTES >)
- if (progress >= 100) then
- progress = 0
- else
- progress = progress + 0.1
- end
- Item:SetPercentage(progress)
- end
- end)
- [5:41 AM] JohnAA12: no
- [5:41 AM] JohnAA12: you would have it way say 1 sec (1000) each time
- [5:42 AM] JohnAA12: and add like 0.28 to the progress
- [5:42 AM] JohnAA12: so after 3.5 minutes it's full
- [5:42 AM] JohnAA12: Because 0.28 * 3.5 = 0.98
- [5:43 AM] JohnAA12: and you times that by 100 which is 98 (the bar is out of 100)
- [5:43 AM] JohnAA12: and pretty much the closest you can get without trailing decimal numbers
- [5:43 AM] lowheartrate: and then
- if (progress >= 100) then
- -- kill progress bar
- else
- [5:44 AM] JohnAA12: If you want to kill it you would have to do something like _progressBarPool.ProgressBar = {}
- [5:44 AM] JohnAA12: So it removes the progress bars
- [5:45 AM] lowheartrate: gotcha, how come it loads so fast as of right now if its only loading progress = progress + 0.1
- [5:45 AM] JohnAA12: Because the wait is only 1/1000 of a second
- [5:45 AM] lowheartrate: Gotcha
- [5:46 AM] JohnAA12: Odd numbers are weird for the progress, as you can't really get exactly 100
- [5:47 AM] JohnAA12: That's not exactly
- [5:47 AM] JohnAA12: as 3.5 * 28.5714285714 is 99.9999999999
- [5:48 AM] lowheartrate: and that would take 3.5 seconds to load wouldn't it lol looking for the amount of seconds it takes.
- [5:48 AM] lowheartrate: Thats why I delete.
- [5:48 AM] JohnAA12: you would have the Citizen.Wait(1000)
- [5:49 AM] JohnAA12: and the progress add 0.285714285714
- [5:49 AM] lowheartrate: 100/210 (seconds) = 0.4761904761904762
- [5:49 AM] lowheartrate: https://i.imgur.com/aCzQicV.png
- [5:50 AM] JohnAA12: Yeah you can try that
- [5:53 AM] lowheartrate: Doesn't seem to show me the progress bar at all anymore:
- RegisterNetEvent('NativeUI:progress')
- AddEventHandler('NativeUI:progress', function()
- local _progressBarPool = NativeUI.ProgressBarPool()
- local progress = 0
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- _progressBarPool:Draw()
- end
- end)
- local Item = NativeUI.CreateProgressBarItem("Washing $" .. accountMoney .. "!")
- _progressBarPool:Add(Item)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1000)
- if (progress >= 100) then
- progress = 0
- else
- -- each second add 0.4761904761904762 to the progress bar - will be at >= 100 in 3.5 minutes
- progress = progress + 0.4761904761904762
- end
- Item:SetPercentage(progress)
- end
- end)
- end)
- [5:54 AM] JohnAA12: probably because the float is so small
- [5:56 AM] JohnAA12: wait
- [5:56 AM] lowheartrate: local Item = NativeUI.CreateProgressBarItem("Washing $" .. accountMoney .. "!")
- [5:56 AM] JohnAA12: where do you define accountMoney
- [5:57 AM] lowheartrate: I define that is in the server event:
- RegisterServerEvent('esx_moneywash:withdraw')
- AddEventHandler('esx_moneywash:withdraw', function(amount)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- local accountMoney = 0
- accountMoney = xPlayer.getAccount('black_money').money
- amount = accountMoney
- if amount == nil or amount <= 0 or amount > accountMoney then
- TriggerClientEvent('esx:showNotification', _source, _U('invalid_amount'))
- else
- TriggerClientEvent('NativeUI:progress', -1)
- xPlayer.removeAccountMoney('black_money', amount)
- -- delay time (1 second = 1000ms) before user gets their clean money
- Citizen.Wait(Config.NotificationLockTime * 1000) -- 3.5 minutes (210000)
- xPlayer.addMoney(amount)
- TriggerClientEvent('esx:showNotification', _source, _U('wash_money') .. amount .. '~s~.')
- TriggerClientEvent('esx_moneywash:closeWASH', _source)
- end
- end)
- [5:57 AM] JohnAA12: You have to send the value to the client
- [5:57 AM] JohnAA12: also why do you have the wash show for all players
- [5:57 AM] JohnAA12: TriggerClientEvent('NativeUI:progress', -1)
- [5:58 AM] lowheartrate: I only want to show the progress bar for the client that has started it but need it to only happen if the amount is not 0/nil
- [5:59 AM] JohnAA12: You need to make the -1 _source for only the client that started it
- [5:59 AM] JohnAA12: and pass the amount in for the triggerclientevent
- [5:59 AM] JohnAA12: then add the value on the client part to show that amount
- [6:00 AM] lowheartrate: so this should go into the client event:
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- local accountMoney = 0
- accountMoney = xPlayer.getAccount('black_money').money
- [6:00 AM] JohnAA12: no
- [6:00 AM] JohnAA12: You just send the amount
- [6:00 AM] JohnAA12: theres no xplayer on the client
- [6:02 AM] JohnAA12:
- RegisterServerEvent('esx_moneywash:withdraw')
- AddEventHandler('esx_moneywash:withdraw', function(amount)
- Citizen.CreateThread(function()
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- local accountMoney = 0
- accountMoney = xPlayer.getAccount('black_money').money
- amount = accountMoney
- if amount == nil or amount <= 0 or amount > accountMoney then
- TriggerClientEvent('esx:showNotification', _source, _U('invalid_amount'))
- else
- TriggerClientEvent('NativeUI:progress', _source, amount)
- xPlayer.removeAccountMoney('black_money', amount)
- local savedPlayer = xPlayer
- -- delay time (1 second = 1000ms) before user gets their clean money
- Citizen.Wait(Config.NotificationLockTime * 1000) -- 3.5 minutes (210000)
- savedPlayer.addMoney(amount)
- TriggerClientEvent('esx:showNotification', _source, _U('wash_money') .. amount .. '~s~.')
- TriggerClientEvent('esx_moneywash:closeWASH', _source)
- end
- end)
- end)
- [6:03 AM] JohnAA12: You need to have the Citizen.Wait() in a thread for it to work properly i think
- [6:03 AM] JohnAA12: and then on the client part
- [6:03 AM] JohnAA12:
- RegisterNetEvent('NativeUI:progress')
- AddEventHandler('NativeUI:progress', function(accountMoney)
- local _progressBarPool = NativeUI.ProgressBarPool()
- local progress = 0
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1)
- _progressBarPool:Draw()
- end
- end)
- local Item = NativeUI.CreateProgressBarItem("Washing $" .. accountMoney .. "!")
- _progressBarPool:Add(Item)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1000)
- if (progress >= 100) then
- progress = 0
- else
- -- each second add 0.4761904761904762 to the progress bar - will be at >= 100 in 3.5 minutes
- progress = progress + 0.4761904761904762
- end
- Item:SetPercentage(progress)
- end
- end)
- end)
- [6:05 AM] lowheartrate: Sorry, but how would I go about getting the client's accountMoney from there if I can't use the xPlayer.
- [6:06 AM] JohnAA12: You send the number on the TriggerClientEvent
- [6:06 AM] JohnAA12: you wouldn't use xPlayer on the client
- [6:06 AM] JohnAA12: I put it there for you it should work
- [6:06 AM] lowheartrate: oh, i don't have to somehow define the accountMoney in the client event then?
- [6:07 AM] JohnAA12: It is defined
- [6:07 AM] JohnAA12: AddEventHandler('NativeUI:progress', function(accountMoney)
- [6:10 AM] lowheartrate: PERFECT!
- [6:10 AM] lowheartrate: thanks so much for all your help :smiley:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement