Closed wiruwiru closed 3 weeks ago
It would also be good to add the rebasar (rebufo in Spanish). I think in English it would say something like drafting
Hey, I did some research on repair zone in json file before, but I gave up because I got stuck in the tire wear function. Here are some residual codes, maybe you can use them.
For slipstream (drafting)
Add SetEnableVehicleSlipstreaming(true)
to your script, but since some players don't like this, I won't add it to the script for now. Maybe I will modify the host's room UI in the future to allow the host to customize this option
For openwheel mode
-- server-side code
RaceRoom.ConvertFromUGC = function(currentRace, lapCount)
---
-- other codes
---
currentRace.actualTrack.zones = {}
if currentRace.currentTrackUGC.mission.zone and currentRace.currentTrackUGC.mission.zone.zntp then
local zonetypes = {
[0] = "disable npc and traffic",
[23] = "slowdown",
[37] = "repair",
[40] = "explode"
} -- From gta race modTool
for k, v in pairs(currentRace.currentTrackUGC.mission.zone.zntp) do
table.insert(currentRace.actualTrack.zones, {
x = currentRace.currentTrackUGC.mission.zone.vld[i].x,
y = currentRace.currentTrackUGC.mission.zone.vld[i].y,
z = currentRace.currentTrackUGC.mission.zone.vld[i].z,
type = zonetypes[currentRace.currentTrackUGC.mission.zone.zntp[i]]
})
end
end
end
-- client-side code function SetCar(_car, positionX, positionY, positionZ, heading, engine) local carHash = carTransformed ~= "" and carTransformed or (type(_car) == "number" and _car or _car.model) local ped = PlayerPedId()
if isInOpenWheelRaceMode and GetVehicleClassFromName(carHash) == 22 then
if not IsVehicleDriveable(lastVehicle) then
repairCar(lastVehicle)
end
SetPedIntoVehicle(ped, lastVehicle, -1)
SetEntityCoords(lastVehicle, positionX, positionY, positionZ)
SetEntityHeading(lastVehicle, heading)
SetGameplayCamRelativeHeading(0)
return
end
---
-- other codes
---
end
-- other codes
---
Citizen.CreateThread(function()
while status == "racing" do
---
-- other codes
---
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)
if isInOpenWheelRaceMode and GetVehicleClassFromName(GetEntityModel(vehicle)) == 22 then
tireWear(vehicle)
showVehicleHealthAndTireBar(vehicle)
end
---
-- other codes
---
local checkPointTouched = false
local playerCoords = GetEntityCoords(ped)
local _playerCoords = vector3(playerCoords.x, playerCoords.y, playerCoords.z)
if #(_playerCoords - repair_coords) <= 15 then
if not hasRepairCar and IsPedInAnyVehicle(ped) and GetEntitySpeed(vehicle) <= 5 then
repairCar(vehicle)
hasRepairCar = true
end
else
hasRepairCar = false
end
---
-- other codes
---
Citizen.Wait(0)
end
end)
---
-- other codes
---
end
function repairCar(vehicle) SetVehicleUndriveable(vehicle, false) SetVehicleEngineCanDegrade(vehicle, false) SetVehicleEngineHealth(vehicle, 1000.0) SetVehiclePetrolTankHealth(vehicle, 1000.0) SetVehicleEngineOn(vehicle, true, true) SetVehicleFixed(vehicle) StopEntityFire(vehicle) SetVehicleOilLevel(vehicle, 1.0) SetVehicleDirtLevel(vehicle, 0) SetVehicleDeformationFixed(vehicle) end
function tireWear(vehicle) -- Requires additional scripts to implement -- example: I got stuck here before, so I gave up end
function showVehicleHealthAndTireBar(vehicle) -- Requires additional scripts to implement -- example: https://forum.cfx.re/t/release-carhud-and-helihud-modified-and-better-looking-v-1-9-new-update/97812 end
-- other codes
---
for _, zone in ipairs(track.zones) do
if zone.type == "repair" and not DoesBlipExist(repair_blip) then -- Maybe some JSON has more than 2 repair zones?
CreateCheckpoint(5, zone.x, zone.y, zone.z, 0, 0, 0, 15, 0, 80, 100, 50)
repair_blip = AddBlipForCoord(zone.x, zone.y, zone.z)
SetBlipSprite(repair_blip, 446) -- https://docs.fivem.net/docs/game-references/blips/
isInOpenWheelRaceMode = true
repair_coords = vector3(zone.x, zone.y, zone.z)
end
end
end)
Okey, thank you very much for your answer, it would be nice to implement it as customization options in the room, it would be a good thing for the future, thanks for the help I will try to investigate how I can make the wear of the wheels and show the state of the vehicle in the hud, I'm not really good at lua but if I find a way to do it I will not hesitate to share it.
It would be nice to be able to bring 100% openwheel mode with pits stops and wear of wheels and vehicles, so I was testing the plugin this does not bring it and would be something very new to add to the script.