fivem scripting I've got an event that triggers a server event how can i check on the…
- User
fivem scripting I've got an event that triggers a server event how can i check on the server that both clients in a list triggered the same event
- Assistant
You can achieve this by keeping track of the clients that triggered the event in a table/array, and then checking if the table/array contains both of the client IDs.
Assuming you have a server-side event called "myEvent", and you have a list of clients that triggered the event called "myClients", you can do the following:
- Add the client IDs to the "myClients" list when the event is triggered:
RegisterServerEvent("myEvent") AddEventHandler("myEvent", function() local source = source table.insert(myClients, source) end)- Check if both clients are in the list:
RegisterServerEvent("checkClients") AddEventHandler("checkClients", function() if #myClients == 2 and table.contains(myClients, clientId1) and table.contains(myClients, clientId2) then -- both clients triggered the event else -- not all clients triggered the event end end)In the code above, "clientId1" and "clientId2" are the IDs of the clients that you want to check. You can replace them with the actual client IDs or use variables to store them.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.