微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 lua 中无限循环的载具生成菜单

如何解决在 lua 中无限循环的载具生成菜单

Citizen.CreateThread(function()
    while true do 
        Citizen.Wait(0)
        local playerPed = GetPlayerPed()
        local rank = exports.XpM:XPM_GetRank() --Gets the rank of the player from XP system XpM
print('Rank:' .. rank)
        if rank>50 then
          EighthItem(mainMenu) --All the different menu available for the player to choose vehicles from
          FifthItem(mainMenu)
          SixthItem(mainMenu)
          ThirdItem(mainMenu)
          ForuthItem(mainMenu)
          SeventhItem(mainMenu)
          FirstItem(mainMenu)
          SecondItem(mainMenu)
        elseif rank>40 then
          FifthItem(mainMenu)
          SixthItem(mainMenu)
          ThirdItem(mainMenu)
          ForuthItem(mainMenu)
          SeventhItem(mainMenu)
          FirstItem(mainMenu)
          SecondItem(mainMenu)
        elseif rank>30 then
          SixthItem(mainMenu)
          ThirdItem(mainMenu)
          ForuthItem(mainMenu)
          SeventhItem(mainMenu)
          FirstItem(mainMenu)
          SecondItem(mainMenu)
        elseif rank>20 then
          ThirdItem(mainMenu)
          ForuthItem(mainMenu)
          SeventhItem(mainMenu)
          FirstItem(mainMenu)
          SecondItem(mainMenu)
        else
          ForuthItem(mainMenu)
          SeventhItem(mainMenu)
          FirstItem(mainMenu)
          SecondItem(mainMenu)
        end
       _menuPool:RefreshIndex()
    end
end)
Citizen.CreateThread(function()
    while true do   --
        Citizen.Wait(0)
        _menuPool:ProcessMenus()
        if not IsPedInAnyVehicle(PlayerPedId()) and IsControlJustpressed(1,243) then  --Console
            mainMenu:Visible(not mainMenu:Visible())
        elseif IsPedInAnyVehicle(PlayerPedId()) and IsControlJustpressed(1,243) then  --Console
            exports['mythic_notify']:SenDalert('error','Player is in Vehicle')
        end
    end
end)

代码用于通过菜单生成车辆,但运行代码菜单会无限循环。 rank参数用于为一定级别的人打开特定的车辆类别。玩家的排名与XP系统脚本相关联,并在打开菜单前检索以检查排名并相应地提供可用类别

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。