Skip to content

Update race_client.lua #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion [gamemodes]/[race]/race/race_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1259,11 +1259,24 @@ function createCheckpoint(i)
if checkpoint.type == 'ring' and i < #g_Checkpoints then
setMarkerTarget(checkpoint.marker, unpack(g_Checkpoints[i+1].position))
end
checkpoint.blip = createBlip(pos[1], pos[2], pos[3], 0, isCurrent and 2 or 1, color[1], color[2], color[3])
checkpoint.blip = createBlip(pos[1], pos[2], pos[3], 0, isCurrent and 2 or 1, color[1], color[2], color[3], 255)
setBlipOrdering(checkpoint.blip, 1)
return checkpoint.marker
end

function createRadarBlips(i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this function defined but not used anywhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nowadays, we use 3 blips in the race community, to accurately see the next 3cp from a distance.

local checkpoint = g_Checkpoints[i]
if checkpoint.marker then
return
end
local pos = checkpoint.position
local color = checkpoint.color or { 0, 0, 80 }

checkpoint.blip2 = createBlip(pos[1], pos[2], pos[3], 0, isCurrent and 2 or 1, color[1], color[2], color[3], 100)

return checkpoint.marker
end

function makeCheckpointCurrent(i,bOtherPlayer)
local checkpoint = g_Checkpoints[i]
local pos = checkpoint.position
Expand All @@ -1287,10 +1300,22 @@ end

function destroyCheckpoint(i)
local checkpoint = g_Checkpoints[i]
local blip2 = g_Checkpoints[i+1]
local blip3 = g_Checkpoints[i+2]
if checkpoint and checkpoint.marker then
destroyElement(checkpoint.marker)
checkpoint.marker = nil
destroyElement(checkpoint.blip)

if (#g_Checkpoints - i) >= 3 then
--destroyElement(blip2.blip2)
if isElement(blip3.blip2) then
if blip3.blip2 then
destroyElement(blip3.blip2)
end
end
end

Comment on lines +1310 to +1318
Copy link
Member

@Lpsd Lpsd Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These blips are not guaranteed to exist with the current logic, yet you aren't checking if they do exist.

What happens if the last checkpoint in the table was destroyed, but more than 2 checkpoints exist?

Also the inconsistent usage of terms blip and checkpoint is confusing. You're getting a checkpoint from g_Checkpoints, not a blip - so these vars should be local checkpoint2, local checkpoint3, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--destroyElement(blip2.blip2) we should also not be submitting commented out code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codebase from vanilla mta itself throws a warning on -destroyelement, so you should check how to fix that problem. Cause problems on specting mode

checkpoint.blip = nil
if checkpoint.colshape then
destroyElement(checkpoint.colshape)
Expand Down