taoletsgo / custom_races

A script for loading GTA:Online races in FiveM.
The Unlicense
13 stars 3 forks source link

.... #2

Closed C4rI0s closed 3 weeks ago

C4rI0s commented 3 weeks ago

Make it usable with an item or arcade

taoletsgo commented 3 weeks ago

Hey dude, you should implement the code by yourself to detect if the player is close to an arcade object and press a keyboard/controller button. Or add the item in your admin/vip/user menu, for example, the menu script in my server includes the item of creating a race. But these cannot be combined with this race script, just like I didn’t create the player tag name and blip during racing in the race script, these should be controlled by other standalone script

C4rI0s commented 3 weeks ago

What part of the code needs to be modified?

taoletsgo commented 3 weeks ago

simple example for admin/vip/user menu: 1.Delete 2533 - 2562 https://github.com/taoletsgo/custom_races/blob/278309d113d0c9a9d4345d08349b5f7e939624e4/main%20script/custom_races/client/main_client.lua#L2533-L2562

2.Add the following code to the bottom of main_client.lua, or use exports, whichever you prefer

AddEventHandler('menu:client:openracemenu', function()
    if not inMenu and canOpenMenu and status == "freemode" and not IsNuiFocused() and not IsPauseMenuActive() then
        SendNUIMessage({
            action = "openMenu",
            races_data_front = races_data_front,
            inrace = false
        })
        SetNuiFocus(true, true)
        inMenu = true
    end
end)

3.Modify your admin/vip/user menu:

if (is_check) then TriggerEvent('menu:client:openracemenu') end
C4rI0s commented 3 weeks ago

Thank you. And why doesn't the countdown appear? I've seen that in the code it calls the functions and it's all fine but why doesn't it work?

taoletsgo commented 3 weeks ago

There is already a count down before showRaceInfo, so the second count down code is discarded. If you want count down to appear after showRaceInfo, you can modify the code as follows: