readme didnt update for some reason :(

This commit is contained in:
Mycroft
2022-08-07 00:06:47 +01:00
parent 536ef75789
commit e935a9a6b6
2 changed files with 73 additions and 36 deletions
+36 -34
View File
@@ -1,46 +1,48 @@
local InProgress = false
local function Progressbar(message,length,Options)
if Options.animation then
if Options.animation.type == "anim" then
ESX.Streaming.RequestAnimDict(Options.animation.dict, function()
TaskPlayAnim(ESX.PlayerData.ped, Options.animation.dict, Options.animation.lib, 1.0, 1.0, length, 1, 1.0, false,false,false)
RemoveAnimDict(Options.animation.dict)
end)
elseif Options.animation.type == "Scenario" then
TaskStartScenarioInPlace(ESX.PlayerData.ped, Options.animation.Scenario, 0, true)
end
end
if Options.FreezePlayer then FreezeEntityPosition(PlayerPedId(),Options.FreezePlayer) end
SendNuiMessage(json.encode({
type = "Progressbar",
length = length or 3000,
message = message or "ESX-Framework"
}))
if Options.onCancel then
local le = length or 3000
while le > 0 do
Wait(0)
le -= 1
if IsControlJustPressed(0, 178) then
Options.onCancel()
break
if not InProgress then
if Options.animation then
if Options.animation.type == "anim" then
ESX.Streaming.RequestAnimDict(Options.animation.dict, function()
TaskPlayAnim(ESX.PlayerData.ped, Options.animation.dict, Options.animation.lib, 1.0, 1.0, length, 1, 1.0, false,false,false)
RemoveAnimDict(Options.animation.dict)
end)
elseif Options.animation.type == "Scenario" then
TaskStartScenarioInPlace(ESX.PlayerData.ped, Options.animation.Scenario, 0, true)
end
end
if Options.FreezePlayer then FreezeEntityPosition(PlayerPedId(),Options.FreezePlayer) end
SendNuiMessage(json.encode({
type = "Close"
type = "Progressbar",
length = length or 3000,
message = message or "ESX-Framework"
}))
ClearPedTasks(ESX.PlayerData.ped)
if Options.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end
if Options.onFinish then Options.onFinish() end
else
SetTimeout(length, function()
if Options.onCancel then
local le = length or 3000
while le > 0 do
Wait(0)
le -= 1
if IsControlJustPressed(0, 178) then
SendNuiMessage(json.encode({
type = "Close"
}))
Options.onCancel()
break
end
end
ClearPedTasks(ESX.PlayerData.ped)
if Options.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end
if Options.onFinish then Options.onFinish() end
end)
InProgress = false
else
SetTimeout(length, function()
ClearPedTasks(ESX.PlayerData.ped)
if Options.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end
if Options.onFinish then Options.onFinish() end
InProgress = false
end)
end
end
end
exports('Progressbar', Progressbar)
+37 -2
View File
@@ -16,6 +16,7 @@
```
* Export
```lua
exports["esx_progressbar"]:Progressbar("Unlocking Storage", 3000,{
FreezePlayer = true,
@@ -27,5 +28,39 @@
onFinish = function()
--Code here
end})
```
```
* Cancel
```lua
ESX.Progressbar("Unlocking Storage", 3000,{
FreezePlayer = true,
animation ={
type = "anim",
dict = "anim@mp_player_intmenu@key_fob@",
lib ="fob_click"
},
onFinish = function()
--Code here
end, OnCancel = function()
--Code here
end
})
```
* Scenario
```lua
ESX.Progressbar("Unlocking Storage", 3000,{
FreezePlayer = true,
animation ={
type = "Scenario",
Scenario = "PROP_HUMAN_BUM_BIN",
},
onFinish = function()
--Code here
end, OnCancel = function()
--Code here
end
})
```