#snippets-and-stuff
1 messages · Page 1 of 1 (latest)
what is this on right side ? what he show ?
It shows the current leaderboard in the race. So the positions of all racers
thats is in script or just he doing ?
It was half made already. Not sure if he used what was already there or made more. See #racingapp-🏁 for the discussion
anyone have a quick snip of what to put in items.lua for the racing tablet? I would appreciate it
['racing_gps'] = {
label = 'Racing GPS',
weight = 500,
stack = false,
close = true,
description = 'Wroom wroom.',
},
this is for ox
Whoever wants to fix the GPS should replace this function in:
client/main.lua :
local function updateGpsForRace(started)
deleteAllCheckpoints()
if IgnoreRoadsForGps then
ClearGpsCustomRoute()
StartGpsCustomRoute(Config.Gps.color, true)
else
ClearGpsMultiRoute()
StartGpsMultiRoute(Config.Gps.color, true, true)
end
local currentCheckpoint = CurrentRaceData.CurrentCheckpoint or 1
local lastCheckpoint = currentCheckpoint + Config.MarkAmountOfCheckpointsAhead - 1
local totalCheckpoints = #CurrentRaceData.Checkpoints
local isCircuit = CurrentRaceData.TotalLaps > 0
for i = currentCheckpoint, lastCheckpoint do
local checkpointIndex = isCircuit and ((i - 1) % totalCheckpoints) + 1 or i
if checkpointIndex > totalCheckpoints and not isCircuit then break end
local checkpointData = CurrentRaceData.Checkpoints[checkpointIndex]
local coords = checkpointData.coords
if IgnoreRoadsForGps then
AddPointToGpsCustomRoute(coords.x, coords.y, coords.z or 0.0)
else
AddPointToGpsMultiRoute(coords.x, coords.y, coords.z or 0.0)
end
local pileModel = isFinishOrStart(checkpointIndex) and StartAndFinishModel or CheckpointPileModel
checkpointData.pileleft = createPile(checkpointData.offset.left, pileModel)
checkpointData.pileright = createPile(checkpointData.offset.right, pileModel)
if checkpointData.blip then
SetBlipDisplay(checkpointData.blip, 2)
ShowHeightOnBlip(checkpointData.blip, true)
end
end
if IgnoreRoadsForGps then
SetGpsCustomRouteRender(ShowGpsRoute, 16, 16)
else
SetGpsMultiRouteRender(ShowGpsRoute, 16, 16)
end
end
before :
after :
@cerulean stirrup
Made cw-tuning work with qb-inventory and implemented cw-rep into the system for item using your can disable by commenting out the check.
-- Your performance items goes here to server.lua
local perfoItems = {
"turbo1",
"turbo2",
"turbo3",
"turbo4",
"emuffler1",
"emuffler2",
"emuffler3",
"crankshaft1",
"crankshaft2",
"crankshaft3",
"intercooler1",
"intercooler2",
"intercooler3",
"ecu1",
"ecu2",
"ecu3",
"brakes1",
"brakes2",
"brakes3",
"autotrans",
"manualtrans",
"clutch1",
"clutch2",
"clutch3",
"tyres1",
"tyres2",
"tyres3",
"antiroll1",
"antiroll2",
"antiroll3",
"weightreduction1",
"weightreduction2",
"weightreduction3",
}
-- Add this into server.lua
for k, v in pairs(perfoItems) do
QBCore.Functions.CreateUseableItem(v, function(source, item)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local playerSkill = exports["cw-rep"]:fetchSkills(src)
local metadata = item.info
if Player.Functions.GetItemByName(item.name) then
if metadata and metadata.ptype and metadata.variant and metadata.skill then
if metadata.skill > playerSkill['underground'] then
TriggerClientEvent('QBCore:Notify', src, 'You lack '..(metadata.skill - playerSkill['underground'])..' skill points to use this part.', 'error')
return
end
if metadata.tier then
TriggerClientEvent('cw-tuning:client:addTuningPart', src, metadata.ptype, metadata.variant, metadata.tier, item.name)
TriggerEvent('qb-log:server:CreateLog', "tuning", "Tuning Part Used", "red", "**Part:** "..getVariantName(metadata.variant).." T"..metadata.tier.." "..getTypeName(metadata.ptype).." | **Item:** "..item.name .. " | **Player Name:** " .. GetPlayerName(src) .. " | **Player ID:** " .. src .. " | **Skill:** " .. playerSkill['underground'] .. " | **Player Citizen ID:** " .. Player.PlayerData.citizenid)
else
TriggerClientEvent('cw-tuning:client:addTuningPart', src, metadata.ptype, metadata.variant, nil, item.name)
TriggerEvent('qb-log:server:CreateLog', "tuning", "Tuning Part Used", "red", "**Part:** "..getVariantName(metadata.variant).." "..getTypeName(metadata.ptype).." | **Item:** "..item.name .. " | **Player Name:** " .. GetPlayerName(src) .. " | **Player ID:** " .. src .. " | **Skill:** " .. playerSkill['underground'] .. " | **Player Citizen ID:** " .. Player.PlayerData.citizenid)
end
else
TriggerClientEvent('QBCore:Notify', src, 'Error with part data.', 'error')
end
else
TriggerClientEvent('QBCore:Notify', src, 'Item not found in inventory.', 'error')
end
end)
end
-- Remove Item event into server.lua
RegisterNetEvent('cw-tuning:server:removeTuningPart', function(item)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.RemoveItem(item, 1)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove', 1)
end)
Add item argument to addTuningPart(ptype, variant, tier, isMechanic, vehicle, item)
-- Add this into addTuningPart function in client.lua right before 'cw-tuning:server:setMods'
TriggerServerEvent('cw-tuning:server:removeTuningPart', item)
-- Extra check for item validation before setting mods add right on finishing the progress bar
if not QBCore.Functions.HasItem(item) then
notify('You do not have the item', 'error')
Entity(vehicle).state:set('workedOn', false, true)
return end
-- Add skill into item info when creating for example I'm creating the items using cw-crafting
['turbo1'] = {
category = "Turbo Tuning",
toItems = {
turbo1 = 1,
},
materials = {
turboblock = 1, turbosegment = 3, turbocomponent = 1, alloy = 2, bolts = 4,
},
craftingTime= 10000,
metadata = {
ptype = 'turbo',
variant = 'TurboCharger',
skill = 1000,
tier = '1',
},
skillName = 'underground',
craftingSkill= 1000,
customSkillGain = 25,
maxCraft = 1,
tables = {'underground'},
},
racing_gps image already scaled too 100x100 
that's so much nicer than my old chili dog tablet 
mind if I include it in the script?
ofc ofc
I made PR if you need
It's already in, but thanks 
Anyone managed to get cw-performance working with garages? for example, showing the class of the vehicle in the label?
a bit late but you can call getVehicleInfo export to obtain information and then add it to UI
I tried to do that, but due to the way the export works (checks the vehicle the player is in) it doesn't work for "fake" vehicles (just passing the spawncode)
If you only care about the base model, you can spawn an entity that's the same under ground and just run the export on that entity.
If you want to have it with updates in mind, and for a better solution, I suggest adding a column in your garage database to save the class in
i think you only need to forward spawncode since it pulls data from handling.meta
Okay, thank you for your help both
I'll do some testing and post a snippet if I get it working reliably
i think debug print is making it fail
and maybe getvehicleacceleration native since it may require entity to exist on client to get that data
I suggest always checking if entity exists before calling the export
but again those are only for debug prints
The export works by-entity. Not spawn codes
The usecase is detailed in the Readme
https://github.com/Coffeelot/cw-performance/tree/9f32d7ff86f8546150223568ed14179e389ae1b4?tab=readme-ov-file#basic-use
just grab the entity of the spawned vehicle instead of the one the player is in
ive just tested these natives and confirmed that entity has to be spawned in for calculation to work properly, with that being said, i would store this information in the database alongside with vehicle before vehicle gets despawned and "put in garage" as suggested earlier
issue is if you want realistic representation of vehicle class because native for GetVehicleAcceleration changes depending on current upgrades on the vehicle
impact on the calculation should not be too major but in some edge cases it might show different class depending if car has upgrades or not
Turbo adds a shit ton to the PI
Not to promote my own shit in my own server, but cw tuning does a much better job at giving upgrades a readable stat increase.
And even then, that still uses turbos from gta - which are so fucking broken
dno how you are applying values and which values you are applying to the vehicle with those upgrades but i know that, before at least, some values did not apply correctly/consistently to vehicles, maybe they fixed it in later versions although i did not test them in a while
i think i was using SetVehicleHandlingFloat/Int/Field variants and eventually just gave up since it was really inconsistent with multiple people in the server
That's how they are applied in Tuning. Syncing has been one of the main issues. But we've seen very few issues the past months.
Our version is leaps ahead of the Tuning that's released tho