原贴:https://forum.cfx.re/t/fxprogressbar-free-standalone/5256375
进度条提供一系列可自定义的功能,包括动画、道具、粒子效果和控制设置。
它可以出现在任何脚本中的任何位置。
您可以执行的所有操作的示例:
|实现 qb-core|
如果您想更改 qb-core 中的默认进度条,请转到 qb-core/client/functions.lua 并将 QBCore.Functions.Progressbar 函数替换为:
之后将此“@fx_progressbar/client.lua”添加到shared_scripts中的fxmanifest.lua中。还要确保 fx_progressbar 在 cfg 中的 qb-core 之前得到保证。
功能包括:
- 持续时间和标签:
- duration(数字):设置进度条的长度(以毫秒为单位)。
- label(字符串):自定义进度条上显示的标签。
- 行为控制(可选):
- useWhileDead(布尔值):允许在玩家死亡时执行操作。
- allowRagdoll(布尔值):允许在进程中玩布娃娃。
- allowSwimming(布尔值):在进行过程中启用游泳。
- allowCuffed(布尔值):允许玩家在戴上手铐时进行操作。
- allowFalling(布尔值):当玩家掉落时继续执行操作。
- canCancel (boolean): 让玩家取消进度。
- 动画控件(可选):
- anim(表):定义动画:
- dict(字符串):动画字典。
- Clip(字符串):特定的动画剪辑。
- flag(数字,可选):动画标志,默认为49。
- BlendIn(浮动,可选):混合动画的时间。
- BlendOut(float,可选):混合动画的时间。
- playbackRate(float,可选):动画的速度。
- lockX(布尔值,可选)、lockY(布尔值,可选)、lockZ(布尔值,可选):锁定特定轴上的运动。
- 道具处理(可选):
- prop(桌子):将道具附加到玩家身上:
- model(哈希):Prop 模型哈希。
- bone(数字,可选):附加道具的骨骼,默认为 60309。
- pos(表):位置偏移(x、y、z)。
- rot(表):旋转偏移(x、y、z)。
- rotOrder(数字,可选):应用旋转的顺序。
- prop(桌子):将道具附加到玩家身上:
- 粒子效果(可选):
- particles(表):添加粒子效果:
- assetName(字符串):粒子资源名称。
- effectName(字符串):特定的粒子效果。
- bone(数字,可选):附件的骨骼索引。
- pos(表):位置偏移(x、y、z)。
- rot(表):旋转偏移(x、y、z)。
- 比例(数字,可选):粒子效果的比例。
- particles(表):添加粒子效果:
- 禁用控件(可选):
- 禁用(表):通过禁用来控制玩家操作:
- move(布尔值):移动。
- car(布尔值):汽车控件。
- Combat(布尔值):战斗动作。
- mouse(布尔值):鼠标输入。
- sprint(布尔值):冲刺。
- 禁用(表):通过禁用来控制玩家操作:
- 事件处理程序(可选):
- onFinish(function,可选):成功完成时的回调函数。
- onCancel(function,可选):取消时的回调函数。
|如何使用|
您只需触发此导出:exports['fx_progressbar']:ShowProgressBar()
它可以出现在任何脚本中的任何位置。
您可以执行的所有操作的示例:
lua:
exports['fx_progressbar']:ShowProgressBar({
duration = 10000, -- The duration for which the progress bar will be shown, in milliseconds.
label = "Performing Action...", -- The label displayed on the progress bar.
-- Behavioral Controls
useWhileDead = false, -- Whether the action can be performed while the player is dead.
allowRagdoll = false, -- Whether the player can ragdoll during the progress.
allowSwimming = true, -- Whether the player can swim during the progress.
allowCuffed = false, -- Whether the action can be performed while the player is cuffed.
allowFalling = false, -- Whether the action can continue if the player is falling.
canCancel = true, -- Whether the player can cancel the progress.
-- Animation Controls
anim = {
dict = "amb@world_human_stand_mobile@male@text@base", -- Animation dictionary.
clip = "base", -- Animation clip.
flag = 49, -- Animation flag (default is 49).
blendIn = 3.0, -- Time to blend in the animation.
blendOut = 1.0, -- Time to blend out the animation.
playbackRate = 1.0, -- Speed at which the animation is played.
lockX = true, -- Lock X-axis movement.
lockY = false, -- Lock Y-axis movement.
lockZ = true, -- Lock Z-axis movement.
},
-- Prop Handling
prop = {
{
model = `prop_ld_flow_bottle`, -- Prop model hash.
bone = 60309, -- Bone to attach the prop to (default is 60309).
pos = { x = 0.05, y = 0.0, z = -0.15 }, -- Position offset for the prop.
rot = { x = 0.0, y = 0.0, z = 0.0 }, -- Rotation offset for the prop.
rotOrder = 0, -- Order in which rotations are applied.
}
},
-- Particle Effects
particles = {
{
assetName = "core", -- Particle asset name
effectName = "ent_amb_sparks", -- Particle effect name
bone = 28422, -- Bone to attach the particle to (e.g., right hand)
pos = { x = 0.0, y = 0.0, z = 0.0 }, -- Position offset for the particle
rot = { x = 0.0, y = 0.0, z = 0.0 }, -- Rotation offset for the particle
scale = 1.0, -- Scale of the particle effect
},
{
assetName = "scr_rcbarry2",
effectName = "scr_clown_death",
bone = 24818, -- Another bone index for demonstration (e.g., left hand)
pos = { x = 0.1, y = 0.1, z = 0.0 },
rot = { x = 0.0, y = 0.0, z = 0.0 },
scale = 0.5,
}
},
-- Disable Controls
disable = {
move = true, -- Disable player movement.
car = false, -- Allow entering/exiting cars.
combat = true, -- Disable combat controls.
mouse = true, -- Disable mouse controls.
sprint = true, -- Disable sprinting.
},
-- Event Handlers
onFinish = function()
print("Action completed successfully!")
end,
onCancel = function()
print("Action was canceled.")
end
})
如果您想更改 qb-core 中的默认进度条,请转到 qb-core/client/functions.lua 并将 QBCore.Functions.Progressbar 函数替换为:
lua:
function QBCore.Functions.Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
if exports['fx_progressbar']:IsProgressActive() then QBCore.Functions.Notify('You are already doing something!', 'error', 3000) return end
local disable = {}
if disableControls then
disable.move = disableControls.disableMovement
disable.car = disableControls.disableCarMovement
disable.combat = disableControls.disableCombat
disable.mouse = disableControls.disableMouse
disable.sprint = disableControls.disableSprint
end
local defaultPos = { x = 0.0, y = 0.0, z = 0.0 }
local defaultRot = { x = 0.0, y = 0.0, z = 0.0 }
if prop then
prop.pos = prop.pos or defaultPos
prop.rot = prop.rot or defaultRot
end
if propTwo then
propTwo.pos = propTwo.pos or defaultPos
propTwo.rot = propTwo.rot or defaultRot
end
local props = {}
if prop then table.insert(props, prop) end
if propTwo then table.insert(props, propTwo) end
local anim = nil
if animation then
anim = {
dict = animation.animDict,
clip = animation.anim,
flag = animation.flags,
blendIn = 3.0,
blendOut = 1.0,
playbackRate = animation.playbackRate or 1.0,
lockX = animation.lockX,
lockY = animation.lockY,
lockZ = animation.lockZ,
}
end
exports['fx_progressbar']:ShowProgressBar({
duration = duration,
label = label,
useWhileDead = useWhileDead,
canCancel = canCancel,
disable = disable,
anim = anim,
prop = props,
onFinish = function()
if onFinish then
onFinish()
end
end,
onCancel = function()
if onCancel then
onCancel()
end
end,
})
end