citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.52k stars 2.07k forks source link

Reorganize KVP natives and fix Lua example for the "find" functions #2511

Closed Mathu-lmn closed 1 month ago

Mathu-lmn commented 4 months ago

Goal of this PR

This PR puts all the KVP related native decls in the kvp folder It also provides a fix for the Lua example script that wasn't working due to a wrong boolean check and a missing Wait

How is this PR achieving the goal

By moving all the KVP files in the KVP folder and fixing the Lua example in both StartFindKvp and StartFindExternalKvp

This PR applies to the following area(s)

Natives

Game builds: X

Platforms: X

Checklist

Mathu-lmn commented 1 month ago

Have you tried it ? I can't right now as I'm away but I can next week if needed !

AvarianKnight commented 1 month ago

Yes, the example works fine, you don't need to wait to get the kvp string though.

Mathu-lmn commented 1 month ago

I wonder why I added it then. I think the client crashed with no wait but I can't check now

AvarianKnight commented 1 month ago

Likely crashed with the until key because there would never be a key so it would be an infinite loop

Mathu-lmn commented 1 month ago

That's why I changed it to until not key 😬

Mathu-lmn commented 1 month ago

But wouldn't the client crash in a loop with no wait ?

AvarianKnight commented 1 month ago

But wouldn't the client crash in a loop with no wait ?

The old loop (which was until key) would crash with a endless loop because it would wait for key to be valid, which it would never be.

The fixed loop (which is until not key) can't crash because if there isn't a key it will break out of the loop.

Mathu-lmn commented 1 month ago

Yes, what I meant is that in regular while loops, if you don't put a Wait(0), the Fivem client freezes and you ultimately crash. I'm wondering if it's the case with the repeat operator too

Mathu-lmn commented 1 month ago

I've tested without the Wait and it works fine, thanks for the feedback @AvarianKnight