example
example

已解决√ 求助 玩家不动3秒的状态下自动触发动作

Q1n77

用户
认证用户
黄金
47.80 黄金
玩家不动3秒的状态下自动触发双手摸头和双手摆手和双手摸脸动作
 
领取红包用户
Q 2407778113 M'J BertonJustin
local PlayerPedId = PlayerPedId
local IsPedActiveInScenario = IsPedActiveInScenario
local IsPedStill = IsPedStill
local Wait = Wait
local IsControlPressed = IsControlPressed
local ClearPedTasks = ClearPedTasks
local TaskStartScenarioInPlace = TaskStartScenarioInPlace

local idle = false
local lastMovement = GetGameTimer()
local idleCheckTime = 3000 -- 3秒
local currentAction = 0
local actionScenarios = {
"WORLD_HUMAN_CHEERING", -- 双手摆手
"PROP_HUMAN_BUM_BIN", -- 双手摸头
"WORLD_HUMAN_STAND_MOBILE" -- 双手摸脸
}

Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
local playerPed = PlayerPedId()

-- 检查玩家是否在移动
if IsPedOnFoot(playerPed) and not IsPedStill(playerPed) then
lastMovement = GetGameTimer()
if idle then
idle = false
ClearPedTasks(playerPed)
currentAction = 0
end
end

-- 检查是否达到闲置时间
if not idle and GetGameTimer() - lastMovement > idleCheckTime then
idle = true
end

-- 如果闲置,播放动作
if idle and not IsPedActiveInScenario(playerPed) then
currentAction = currentAction + 1
if currentAction > #actionScenarios then
currentAction = 1
end

TaskStartScenarioInPlace(playerPed, actionScenarios[currentAction], 0, true)
end
end
end)

-- 如果玩家按任何键,重置闲置计时器
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for i = 0, 350 do
if IsControlPressed(0, i) then
lastMovement = GetGameTimer()
if idle then
idle = false
ClearPedTasks(PlayerPedId())
currentAction = 0
end
break
end
end
end
end)
 
感谢楼主的红包!

M'J领取了您的红包获得了0.26黄金
 
local PlayerPedId = PlayerPedId
local IsPedActiveInScenario = IsPedActiveInScenario
local IsPedStill = IsPedStill
local Wait = Wait
local IsControlPressed = IsControlPressed
local ClearPedTasks = ClearPedTasks
local TaskStartScenarioInPlace = TaskStartScenarioInPlace

local idle = false
local lastMovement = GetGameTimer()
local idleCheckTime = 3000 -- 3秒
local currentAction = 0
local actionScenarios = {
"WORLD_HUMAN_CHEERING", -- 双手摆手
"PROP_HUMAN_BUM_BIN", -- 双手摸头
"WORLD_HUMAN_STAND_MOBILE" -- 双手摸脸
}

Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
local playerPed = PlayerPedId()

-- 检查玩家是否在移动
if IsPedOnFoot(playerPed) and not IsPedStill(playerPed) then
lastMovement = GetGameTimer()
if idle then
idle = false
ClearPedTasks(playerPed)
currentAction = 0
end
end

-- 检查是否达到闲置时间
if not idle and GetGameTimer() - lastMovement > idleCheckTime then
idle = true
end

-- 如果闲置,播放动作
if idle and not IsPedActiveInScenario(playerPed) then
currentAction = currentAction + 1
if currentAction > #actionScenarios then
currentAction = 1
end

TaskStartScenarioInPlace(playerPed, actionScenarios[currentAction], 0, true)
end
end
end)

-- 如果玩家按任何键,重置闲置计时器
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for i = 0, 350 do
if IsControlPressed(0, i) then
lastMovement = GetGameTimer()
if idle then
idle = false
ClearPedTasks(PlayerPedId())
currentAction = 0
end
break
end
end
end
end)
添加到任意client吗
 
感谢楼主的红包!

BertonJustin领取了您的红包获得了3.94黄金
 
local PlayerPedId = PlayerPedId
local IsPedActiveInScenario = IsPedActiveInScenario
local IsPedStill = IsPedStill
local Wait = Wait
local IsControlPressed = IsControlPressed
local ClearPedTasks = ClearPedTasks
local TaskStartScenarioInPlace = TaskStartScenarioInPlace

local idle = false
local lastMovement = GetGameTimer()
local idleCheckTime = 3000 -- 3秒
local currentAction = 0
local actionScenarios = {
"WORLD_HUMAN_CHEERING", -- 双手摆手
"PROP_HUMAN_BUM_BIN", -- 双手摸头
"WORLD_HUMAN_STAND_MOBILE" -- 双手摸脸
}

Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
local playerPed = PlayerPedId()

-- 检查玩家是否在移动
if IsPedOnFoot(playerPed) and not IsPedStill(playerPed) then
lastMovement = GetGameTimer()
if idle then
idle = false
ClearPedTasks(playerPed)
currentAction = 0
end
end

-- 检查是否达到闲置时间
if not idle and GetGameTimer() - lastMovement > idleCheckTime then
idle = true
end

-- 如果闲置,播放动作
if idle and not IsPedActiveInScenario(playerPed) then
currentAction = currentAction + 1
if currentAction > #actionScenarios then
currentAction = 1
end

TaskStartScenarioInPlace(playerPed, actionScenarios[currentAction], 0, true)
end
end
end)

-- 如果玩家按任何键,重置闲置计时器
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for i = 0, 350 do
if IsControlPressed(0, i) then
lastMovement = GetGameTimer()
if idle then
idle = false
ClearPedTasks(PlayerPedId())
currentAction = 0
end
break
end
end
end
end)
"WORLD_HUMAN_CHEERING", -- 双手摆手
"PROP_HUMAN_BUM_BIN", -- 双手摸头
"WORLD_HUMAN_STAND_MOBILE" -- 双手摸脸
这些动作不对
 
后退
顶部