SA-MP Forums Archive
How to check if someone is online through php? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to check if someone is online through php? (/showthread.php?tid=302368)



How to check if someone is online through php? - Luis- - 08.12.2011

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"


Re: How to check if someone is online through php? - Calgon - 08.12.2011

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.


Re: How to check if someone is online through php? - JiHost - 08.12.2011

Quote:
Originally Posted by Calgon
Посмотреть сообщение
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.
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).


Re: How to check if someone is online through php? - Calgon - 08.12.2011

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.


Re: How to check if someone is online through php? - JiHost - 08.12.2011

Quote:
Originally Posted by Calgon
Посмотреть сообщение
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.
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.


Re: How to check if someone is online through php? - Calgon - 08.12.2011

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.


Re: How to check if someone is online through php? - JiHost - 08.12.2011

No, but there should be a timer which gives you max. 20 seconds to login or so.


Re: How to check if someone is online through php? - Calgon - 08.12.2011

That's still exploitable then, which was my original point...


Re: How to check if someone is online through php? - Kingunit - 08.12.2011

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.


Re: How to check if someone is online through php? - AndreT - 08.12.2011

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