example
example

教程 脚本开发 17:按键设置玩家为布娃娃

  • 主题发起人 主题发起人 Yann
  • 开始时间 开始时间

Yann

站长
管理成员
GTAOS管理组
认证用户
本 月 名 人 榜 最 佳
黄金
585.66 黄金
申明:允许转载,但请注明出处(gtaos.com),谢谢对我们劳动的尊重!



如果喜欢我们的教程,可以点赞评论支持我们,你的支持是我们更新的动力 !谢谢!
 
最后编辑:
打赏用户
FWL
站长,这个只能长按,我想要个按一次倒地,按一次起来的这种
 
站长,这个只能长按,我想要个按一次倒地,按一次起来的这种
你加个变量控制时间就可以了,按第一下倒地,倒地时间给一个很大的数字,如果按第二下的话就给一个很小的时间。
 
  • 喜欢
反馈: FWL
你加个变量控制时间就可以了,按第一下倒地,倒地时间给一个很大的数字,如果按第二下的话就给一个很小的时间。
好的,谢谢站长
 
你加个变量控制时间就可以了,按第一下倒地,倒地时间给一个很大的数字,如果按第二下的话就给一个很小的时间。
站长有比较详细的教程吗,我改了很多次都有问题
 
Lua:
local check = false
Citizen.CreateThread(function()
    while true do    
        Citizen.Wait(0)    
        if IsControlPressed(1, 73 --[[ "x" 键 ]]) then         --检测 x 键是否被按下, countrol ID列表: https://docs.fivem.net/docs/game-references/controls/#controls
            if check then
                SetPedToRagdoll(GetPlayerPed(-1), 1, 1, 0, true, true, false)   --如果 x 被按下就将人物设置为布娃娃,一定时间后恢复(这个ragdoll的操作就会让人物不受控制立刻瘫软倒地)
                check = false
            else
                SetPedToRagdoll(GetPlayerPed(-1), 9999999, 9999999, 0, true, true, false)   --如果 x 被按下就将人物设置为布娃娃,一定时间后恢复(这个ragdoll的操作就会让人物不受控制立刻瘫软倒地)
            end
        end
    end
end)
 
最后编辑:
  • 喜欢
反馈: FWL
Lua:
local check = false
Citizen.CreateThread(function()
    while true do    
        Citizen.Wait(0)    
        if IsControlPressed(1, 73 --[[ "x" 键 ]]) then         --检测 x 键是否被按下, countrol ID列表: https://docs.fivem.net/docs/game-references/controls/#controls
            if check then
                SetPedToRagdoll(GetPlayerPed(-1), 1, 1, 0, true, true, false)   --如果 x 被按下就将人物设置为布娃娃,一定时间后恢复(这个ragdoll的操作就会让人物不受控制立刻瘫软倒地)
                check = true
            else
                SetPedToRagdoll(GetPlayerPed(-1), 9999999, 9999999, 0, true, true, false)   --如果 x 被按下就将人物设置为布娃娃,一定时间后恢复(这个ragdoll的操作就会让人物不受控制立刻瘫软倒地)
            end
        end
    end
end)
我这样试过了站长,他这样直接没反应了
 
我这样试过了站长,他这样直接没反应了
写错了。。。用ResetPedRagdollTimer 试试
Lua:
local check = false
Citizen.CreateThread(function()
    while true do    
        Citizen.Wait(0)    
        if IsControlPressed(1, 73 --[[ "x" 键 ]]) then         --检测 x 键是否被按下, countrol ID列表: https://docs.fivem.net/docs/game-references/controls/#controls
            if check then
                ResetPedRagdollTimer(GetPlayerPed(-1))
                check = false
            else
                SetPedToRagdoll(GetPlayerPed(-1), 9999999, 9999999, 0, true, true, false)   --如果 x 被按下就将人物设置为布娃娃,一定时间后恢复(这个ragdoll的操作就会让人物不受控制立刻瘫软倒地)
            end
        end
    end
end)
 
  • 喜欢
反馈: FWL
写错了。。。用ResetPedRagdollTimer 试试
Lua:
local check = false
Citizen.CreateThread(function()
    while true do   
        Citizen.Wait(0)   
        if IsControlPressed(1, 73 --[[ "x" 键 ]]) then         --检测 x 键是否被按下, countrol ID列表: https://docs.fivem.net/docs/game-references/controls/#controls
            if check then
                ResetPedRagdollTimer(GetPlayerPed(-1))
                check = false
            else
                SetPedToRagdoll(GetPlayerPed(-1), 9999999, 9999999, 0, true, true, false)   --如果 x 被按下就将人物设置为布娃娃,一定时间后恢复(这个ragdoll的操作就会让人物不受控制立刻瘫软倒地)
            end
        end
    end
end)
还不行站长,他这个是不是有限制啊
 
还不行站长,他这个是不是有限制啊

Lua:
local check = false
Citizen.CreateThread(function() 
    while true do     
        Citizen.Wait(0)     
        if IsControlPressed(1, 73 --[[ "x" 键 ]]) then         --检测 x 键是否被按下, countrol ID列表: https://docs.fivem.net/docs/game-references/controls/#controls
            if check then
                --ResetPedRagdollTimer(GetPlayerPed(-1))
                SetPedCanRagdoll(GetPlayerPed(-1), not check)
                check = not check
                print(0)
                Citizen.Wait(1000)
            else
                SetPedCanRagdoll(GetPlayerPed(-1), not check)
                SetPedToRagdoll(GetPlayerPed(-1), 1000*65, 1000*65, 0, 0, 0, 0)
                check = not check
                print(1)
                Citizen.Wait(1000)
            end
        end 
    end
end)
这个可以,我测试过了,时间数值就是有大小限制,因为c++无符号int类型最大接受65535 ,所以我测试就是最大只支持65秒,只能说这些fivem开发者有点傻逼了,用c++写有点为难他们
 
  • 喜欢
反馈: FWL
还不行站长,他这个是不是有限制啊
Lua:
local check = false
Citizen.CreateThread(function()
    while true do   
        Citizen.Wait(0)   
        if IsControlPressed(1, 73 --[[ "x" 键 ]]) then         --检测 x 键是否被按下, countrol ID列表: https://docs.fivem.net/docs/game-references/controls/#controls
            if check then
                check = not check
              
                Citizen.Wait(1000)
                print(0)
            else
                SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
              
                check = not check

                Citizen.Wait(1000)
                print(1)
            end
        end
        if check then
            ResetPedRagdollTimer(GetPlayerPed(-1) --[[ Ped ]])
        end
    end
end)

更完美的解决方案,使用 ResetPedRagdollTimer 去延长时间。
回答一个问题得搭上几个小时。。。。以后就自己遇见问题多探索探索了,不然我得累死。
 
最后编辑:
  • 喜欢
反馈: FWL
Lua:
local check = false
Citizen.CreateThread(function()
    while true do  
        Citizen.Wait(0)  
        if IsControlPressed(1, 73 --[[ "x" 键 ]]) then         --检测 x 键是否被按下, countrol ID列表: https://docs.fivem.net/docs/game-references/controls/#controls
            if check then
                check = not check
             
                Citizen.Wait(1000)
                print(0)
            else
                SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
             
                check = not check

                Citizen.Wait(1000)
                print(1)
            end
        end
        if check then
            ResetPedRagdollTimer(GetPlayerPed(-1) --[[ Ped ]])
        end
    end
end)

更完美的解决方案,使用 ResetPedRagdollTimer 去延长时间。
回答一个问题得搭上几个小时。。。。以后就自己遇见问题多探索探索了,不然我得累死。
好的好的,谢谢站长,麻烦了😃
 
后退
顶部