I’m trying to create a command that will contact a player but before doing so I would like to check if the playerID is online and if not send an error message.
Current Code: (Simplified code)
server.js
AddEventHander('chatMessage', function(from, name, message)
local playerID = 2
-- How to check that the playerID actually exists in the server?
if (????) then
TriggerClientEvent('MY:CustomEvent', playerID, from)
else
TriggetClientEvent('chatMessage', from, '', {0,0,0}, "No user found."
end
end)
I’ve tried the below but it doesn’t seem to work.
if (NetworkIsPlayerActive(playerID)