citizenfx-reloaded / docs

4 stars 9 forks source link

CreateCheckpoint native seem to not work at all ! #7

Closed K3rhos closed 1 year ago

K3rhos commented 1 year ago

Everything is in the title, I tested the native CreateCheckpoint because I'm making a races script, I put it like this:

CreateCheckpoint(3, race.finish.x, race.finish.y, race.finish.z, 0, 1.0)

On the doc there are missing infos about the last 2 paramaters:

local integer = CreateCheckpoint(type, x, y, z, Unk709, Unk710)

So I checked a bit in GTA 4 decompiled scripts, it seems like the last parameter is always 1.0 but I don't know about the 5th parameter. So I put it to 0, 1, tested even with values like 2.0, 3.0 etc... and nothing, no visual checkpoint is created at the specified coords.

K3rhos commented 1 year ago

Okay so I edited the natives.lua file in CitizenIV\citizen\scripting\lua\natives.lua and I changed the definition of the native ! It's working perfectly now !

img

Here is the original code:

function CreateCheckpoint(type, x, y, z, Unk709, Unk710)
    return _in(0x41F27499, type, x, y, z, Unk709, Unk710, _ri)
end

and here is the fix:

function CreateCheckpoint(type, x1, y1, z1, x2, y2, z2, radius)
    return _in(0x41F27499, type, x1, y1, z1, x2, y2, z2, radius, _ri)
end

x1, y1, z2 is the checkpoint position and x2, y2, z2 is the next checkpoint checkpoint to point to !

I found that curious that in IDA Pro when reversing the game, CREATE_CHECKPOINT native has more parameters than CitizenIV had in his doc, so I tried and yeah it work !