Usefull for some people. But if i am correct you are creating Threads without stopping them and every time a command is entered you create another one without stopping the old ones.
it can lead to a big problem a script looping through a native that runs like 220 times every tick and that stacks every time the command is run, that is already quite a lot after running it like 8 times.
Oh and a Tip for the future you should use PlayerPedId() instead of GetPlayerPed(-1)
and also use PlayerId() instead of GetPlayerServerId(playerPed)
Just FYI the PlayerPedId() or GetPlayerPed(-1) changes whenever you change your ped model. This will cause the resource to not work, when you are referring to the old ped.
Solution: Call PlayerPedId() within the function it needs the player ped.
You may want to build a server.lua because the client side script will only affect the single client who uses it. That way it will work as expected.
To kind of summarize:
Client.lua calls an event in server.lua, example: TriggerServerEvent('infiniteammo:server:toggleServer') (this command should be protected by ACE permissions so only admins can use it)
toggleServer event checks updates a variable to true/false and sends that back to all clients via another receiving event in client.lua
Add a check for player’s joining to grab the current state (another simple event could do this) when they join to ensure they match the current state for infinite ammo
I just noticed and figured I’d point that out since you have the server wide command in the readme. Cheers!
No. I still see that you only call PlayerPedId once. As I said, this will result in an “error” whenever the player changes model. Therefore you need to call the ped whenever you run the command.