Posts: 3,934
Threads: 353
Joined: Jan 2010
Reputation:
0
I know this isn't a php forum but.. I want to know how I can check if a player is online through my UCP, how can I do this?
Example: "Luis is online" or "Luis is offline"
Posts: 6,129
Threads: 36
Joined: Jan 2009
When a player connects or logs in, update a value setting the player's online status to 1. When the player disconnects, update a value in a table/field setting the player's online status to 0. And in case the server crashes, set all player status values to 0 in OnGameModeInit.
If you don't use MySQL or a similar system, then you're not going to accurately be able to determine if a player is logged in and online, just if they're online using the connection API functions Westie released a few years ago.
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by JiHost
Maybe it would be easier to use PHP query Woet re released and check if string displaying online players contain word "Luis". If it is, you can return true (which means he is online) otherwise false (which means he is not online).
|
Yes, but if you bothered to read my post, you'd realize that you can't accurately determine if the player is actually logged in, as you only can retrieve the player's name, ping and ID.
And I mentioned Westie's API, but I know there's other releases out there, like Woet's version.
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by JiHost
He should get kicked immediately if he didn't log in or someone is trying to impersonate him. So I don't think it would really be a problem.
|
Kicked so soon that they don't get a chance to enter their password? That's very silly.
Posts: 314
Threads: 0
Joined: Sep 2011
Reputation:
0
No, but there should be a timer which gives you max. 20 seconds to login or so.
Posts: 6,129
Threads: 36
Joined: Jan 2009
That's still exploitable then, which was my original point...
Posts: 1,426
Threads: 56
Joined: Dec 2010
Reputation:
0
The best way is saving it in MySQL yes. Ain't that hard - then you can check if the value is 1 or 0. Why checking with a query via the serverlist. That's just sad.
Posts: 966
Threads: 5
Joined: Jul 2011
Reputation:
0
I'm feeling glad about your attempts Luis.
Here's how I do it:
1. Server uses HTTP() to send post data to a PHP script
2. PHP script updates an array stored in cache and updates the APC entry
3. Various pages across the forum system call a specific function
4. The function loads the user list from APC and loops through it to see if the value of any entry's registration ID is the same as the one provided to the function