I’ve developed a level system and I need to execute a command with ExecuteCommand and passing some args, any help?
You could also Use TriggerEvents or Callback If I’m not wrong if you want to Communicate from Client to Server or reverse. I think there some YouTube vids or something in the forms about that.
I’ve already tried with TriggerEvent but it doesn’t work, and i search on YT and there’s nothing.
thats how callbacks work
Client to Server:
TriggerServerEvent("requestSomeData")
RegisterNetEvent("receiveSomeData")
AddEventHandler("receiveSomeData", function(data)
-- Handle received data
end)
Server to Client:
RegisterServerEvent("requestSomeData")
AddEventHandler("requestSomeData", function()
local dataToSend = "Some data"
TriggerClientEvent("receiveSomeData", source, dataToSend)
end)
Look, I don’t want to pass any data, I just need to invoke a command that I created in server.lua and pass, by the ExecuteCommand, some args. Your answer it doesn’t seems to do that, and if it does then excuse me but I’m new to FiveM scripting. By any chance you know a method to do that? Thanks in advance
the same way you would write the args in chat. Just write the command and the args in the same string of ExecuteCommand(), separated by space.
The PROBLEM here is that source will not be the player source, but -1, because it’s a script that uses the command, not a player.
You will need to modify the command, and add a second arg that overwrites source, but make sure to only use that arg if source < 1!
Also, please cache the source arg at the start of the command, with something like local src = source and use only src in the command. source is a global variable and CAN and WILL be overwritten by the time the command code is completed


