Forkz
Intermediate OT User
- Joined
- Jun 29, 2020
- Messages
- 495
- Solutions
- 15
- Reaction score
- 121
Hi otlander,
I want to use the playeronline api in the otclient background, but I made the settings and it still has 0 online players.
Which link do I have to use in "curl_setopt($ch, CURLOPT_URL"?
I want to use the playeronline api in the otclient background, but I made the settings and it still has 0 online players.
Which link do I have to use in "curl_setopt($ch, CURLOPT_URL"?
LUA:
<?php
$online_otservlist = 0;
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://otservlist.org/ots/1659719");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Retorna os dados em vez de exibir
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Ignora verificação SSL
curl_setopt($ch, CURLOPT_ENCODING, "");
$site = curl_exec($ch);
curl_close($ch);
// Pega a quantidade de jogadores online
if (preg_match('/There are <strong>([0-9]+)<\/strong>/', $site, $matches)) {
$online_otservlist = (int)$matches[1];
}
} catch(Exception $e) {}
$online_discord = 0;
try {
$online_discord = json_decode(file_get_contents("-"))->presence_count;
} catch(Exception $e) {}
$response = array(
"online" => "$online_otservlist Players online",
"discord_online" => $online_discord,
"discord_link" => "https://discord.com/invite/y49gpt5s9w"
);
echo json_encode($response);
?>