mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
Create GetOnlinePlayers.php
This commit is contained in:
parent
11b5033b53
commit
6ac2996573
31
Tools/PHP/GetOnlinePlayers.php
Normal file
31
Tools/PHP/GetOnlinePlayers.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
Example PHP code - Returns list of online player names.
|
||||
Requires: PHP5 and https://github.com/phpredis/phpredis installed
|
||||
by [VB]AWOL - EpochMod.com
|
||||
|
||||
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
http://creativecommons.org/licenses/by-sa/4.0/
|
||||
*/
|
||||
|
||||
$instance = 'NA123'; // change this to match your servers instanceID
|
||||
|
||||
$redis = new Redis();
|
||||
$redis->pconnect(127.0.0.1, 6379, 2.5, "Server1");
|
||||
$redis->auth("yourlongasspasswordhere");
|
||||
|
||||
$data = $redis->get('PLAYERS:' . $instance);
|
||||
$onlineUIDs = json_decode($data);
|
||||
|
||||
// loop though online player UID's
|
||||
foreach ($onlineUIDs as $key => $UID) {
|
||||
|
||||
// get player name
|
||||
$dataRaw = $redis->get('PlayerData:' . $UID);
|
||||
$data = json_decode($dataRaw);
|
||||
|
||||
// print player name
|
||||
echo '<p>'. $data[0].'</p>';
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user