Stop thread if command is run twice

Hi,

So I have started coding lua and I have question regarding the RegisterCommand(..). Inside it there are an Citizen.CreateThread.

I have created a script, so when you run a command it will display a static text.
But I want to make so when the player runs the same command again the text disappear. And when it runs it the third time it appears again etc etc.

//Thanks!

Use this native
GetIdOfThisThread - https://runtime.fivem.net/doc/natives/?_0xC30338E8088E2E21
and
TerminateThread - https://runtime.fivem.net/doc/natives/?_0xC8B189ED9138BCD4
and
IsThreadActive - https://runtime.fivem.net/doc/natives/?_0x46E9AE36D8FA6417

1 Like

Those natives are for GTA script threads, those won’t work with FiveM scheduler threads.

It would probably be better to have one thread running, and then draw the text written in a variable which you can then set from your command.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.