PHP код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Player List</title>
</head>
<body>
<?php
$filename = 'players.txt';
$allowed_ip = "127.0.0.1";
$allowed_user_agent = "SAMP/0.3";
if(isset($_GET['d'])) {
if($_SERVER['REMOTE_ADDR'] == $allowed_ip && $_SERVER['HTTP_USER_AGENT'] == $allowed_user_agent) {
$fp = fopen($filename, 'w');
fwrite($fp, $_GET['d']);
fclose($fp);
}
else {
die("ACCESS DENIED.");
}
}
else
{
if(file_exists($filename)) {
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$players = explode("*", $contents);
foreach($players as $p) {
$inner_data = explode(":", $p);
$name = $inner_data[0];
$score = $inner_data[1];
$playerid = $inner_data[2];
echo("[ID: ".$playerid."] ".$name." - Score: ".$score."<br />\n");
}
}
}
?>
</body>
</html>
pawn Код:
public SendPlayerData() {
new str[3800 + 13], count;
format(str, sizeof(str), "localhost/?d=");
for(new iLP = 0; iLP < MAX_PLAYERS; iLP++) {
if(IsPlayerConnected(iLP)) {
new name[MAX_PLAYER_NAME];
GetPlayerName(iLP, name, MAX_PLAYER_NAME);
if(!count) {
format(str, sizeof(str), "%s%s:%d:%d", str, name, GetPlayerScore(iLP), iLP);
} else {
format(str, sizeof(str), "%s%s:%d:%d*", str, name, GetPlayerScore(iLP), iLP);
}
count++;
}
}
HTTP(0, HTTP_HEAD, str, "", "");
return true;
}
Quote:
|
Originally Posted by players.txt
Norn:0:0*Scooby_Doo:1337:1
|
You can just run that on a timer every 10 minutes, although you'll more than likely need to detect how many names you've added to the string so far and if the amount of data exceeds the max amount if so call http multiple times, just an example I quickly fired up.
I'll look into sockets tomorrow when I've read the documentation, this is just a method I thought of.