Closed C4rI0s closed 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
What part of the code needs to be modified?
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
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?
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:
after
RegisterNetEvent("custom_races:startRace", function()
Citizen.CreateThread(function()
status = "starting"
PlaySoundFrontend(-1, "Countdown_3","DLC_Stunt_Race_Frontend_Sounds", 1)
SendNUIMessage({
action = "countdown",
data = "3"
})
Citizen.Wait(1000)
PlaySoundFrontend(-1, "Countdown_2","DLC_Stunt_Race_Frontend_Sounds", 1)
SendNUIMessage({
action = "countdown",
data = "2"
})
Citizen.Wait(1000)
PlaySoundFrontend(-1, "Countdown_1","DLC_Stunt_Race_Frontend_Sounds", 1)
SendNUIMessage({
action = "countdown",
data = "1"
})
Citizen.Wait(1000)
PlaySoundFrontend(-1, "Countdown_Go","DLC_Stunt_Race_Frontend_Sounds", 1)
SendNUIMessage({
action = "countdown",
data = "ya"
})
local ped = PlayerPedId()
while IsEntityPositionFrozen(GetVehiclePedIsIn(ped, false)) do
FreezeEntityPosition(GetVehiclePedIsIn(ped, false), false)
Citizen.Wait(0)
end
if car and GetVehicleClassFromName(car.model) == 16 then
ControlLandingGear(GetVehiclePedIsIn(ped, false), 1)
end
SetVehicleEngineOn(GetVehiclePedIsIn(ped, false), true, true, true)
StartRace()
end)
end)
It was available in the early code, but I modified a lot of places, there may be some minor problems, such as the appearance and disappearance time of the UI conflicting with the second count down
Make it usable with an item or arcade