[EN]
Hi, I search a solution for check if a player is connected for my systeme SMS.
I have just a name of player and I want check if this player is connected.
Event : AddEventHandler(‘ReceiveSMS’, function(targetName, targetNumber, message)
Thx for help.
[FR]
Bonjour, je cherche une solution afin de vérifier si le joueur est connecté pour mon système de SMS.
J’ai le nom du joueur, et avec ça je voudrais vérifier si il est bien connecté.
Événement : AddEventHandler(‘ReceiveSMS’, function(targetName, targetNumber, message)
Merci d’avance
1 Like
Szymon
June 11, 2017, 5:48pm
2
You can for example Ping Player by GetPlayerPing(Id)
2 Likes
I don’t have id of player …
I have only a name
What’s your targetNumber ? a full size phone number or the id ?
Is a number phone of target, like 5551000
You could crawl the list of connected player and check by name like this.
-- Not tested but should look like this
ptable = GetPlayers()
for _, i in ipairs(ptable) do
local name = GetPlayerName(i)
if(name == targetName) then
-- Your code here
else
-- Player not online
end
end
1 Like
This is perfect, thx for help men
So now, if want send a sms with my event is like this :
TriggerClientEvent(‘OpenSMS’, i , result3[1].phone_number, message);
I don’t know for i, if is the source or no !
Don’t worry for result3[1].phone_number is a argument.
NetworkIsPlayerActive(PlayerId()) and NetworkIsSessionStarted()
local playerPed = GetPlayerPed(-1)
if playerPed and playerPed ~= -1 then
I don’t have a playerId …
Just a playerName a simple for _, i in ipairs(var) do => is perfect
Oh whoops. There’s for loops in the server code examples that trigger events for all players. I just forget where ATM.
vRP.isConnected({target_id}) This For Vrp Files
Mailar
January 4, 2023, 3:18pm
14
that’s not good way for asking all the players…