• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Exist a function that checks if player are online?

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
I ask that because i have a script that add an event for next 1 minute.
But if player log out, appear a error on console:
"Player not found"

So i need a function that checks if player are online.. this way will add a event for next 1 minute, but after 1 minute, if player are offline, the event will not happen!

EDIT: i am using function onUse
EDIT2: TFS 0.3.7, 8.6
 
Last edited:
Store player name, then check if stored name matches any online.
Code:
getPlayersOnline()
 
Store player name, then check if stored name matches any online.
Code:
getPlayersOnline()
getPlayerOnline will get numbers of all players online, right?

Im my case, i must know if the player that used the item still online, only him!
 
getPlayersOnline() can get every cid of players online.
If you want to get 1 player that fits your requirements you need special loop.
 
getPlayersOnline() can get every cid of players online.
If you want to get 1 player that fits your requirements you need special loop.

Thanks for letting me know!
I really do not know how to do that... maybe a tutorial? maybe u can help me with the code? :rolleyes:
 
I wrote it on the Phone, so no table:
Code:
for _, pid in ipairs(getPlayersOnline()) do
if getCreatureName(pid) == "Printer" then
print("The player is online.")
else
print("The player is offline.")
end
end
 
If you want to check if a specific player is online, you can use isPlayer(cid), if the player isn't online anymore, it will return false.
Code:
if not isPlayer(cid) then
     return true
end
 
Code:
for _, cid in ipairs(getPlayersOnline()) do
        if (getPlayerStorageValue(cid) == 1) then
              print(getPlayerName(cid))
        end
    end
I wrote it on the Phone, so no table:
Code:
for _, pid in ipairs(getPlayersOnline()) do
if getCreatureName(pid) == "Printer" then
print("The player is online.")
else
print("The player is offline.")
end
end
If you want to check if a specific player is online, you can use isPlayer(cid), if the player isn't online anymore, it will return false.
Code:
if not isPlayer(cid) then
     return true
end

ALL codes semms perfect. I choose limos one because its simple and easy to put working on my code...
if isPremium(cid) == true and isPlayer(cid) == true then

THANKS FOR ALLL LOVE UUUUUU ALLLLL <3333 SOLVED
 
Back
Top