i think there was a plugin called geoIP plugin or so but im not sure about that.
edit: Damn to slow
May be this?
Spoiler anzeigen
<?php
/*
===============================================================
===============================================================
== GGGGGG EEEEEEEE OOOOOOOO II PPPPPPP ==
== GG EE OO OO II PP PP ==
== GG GG EEEEEEE OO OO II PPPPPPP ==
== GG GG EE OO OO II PP ==
== GGGGGGGG EEEEEEE OOOOOOOO II PP ==
==============================================================
==============================================================
[geoip]
enabled = 1
message = "Land / Name
host = "localhost"
user = "root"
password = "****"
Ersteller: Fr33g !t
Gibt das Land des Spielers wieder
Changelog:
Version 5:
->Quellcode formatiert
->code gekьrzt
->neue function geoip_main eingefьhrt
*/
$mod->registerCommand("geoip", '~^geoip \S.*$~i' , "geoip" );
$mod->registerCommand("geo", false , "geo" );
$mod->registerEvent("Umwandler", "ipaddress_to_uint32");
$mod->registerEvent("geoipmain", "geoip_main");
$mod->setDefaultCV("geoip", "enabled", 1);
$mod->setDefaultCV("geoip", "message", "Land: <COUNTRY>, Name <NAME>");
$mod->setDefaultCV("geoip", "messageadmin", "Land: <COUNTRY>, Name <NAME>");
$mod->setDefaultCV("geoip", "host", "localhost");
$mod->setDefaultCV("geoip", "user", "root");
$mod->setDefaultCV("geoip", "password", "******");
function geo($guid) { //Function um den Namen und das Land des Spielers auszugeben, ohne einen PArameter !
global $mod;
global $players;
//Ein paar Vatiablen definieren
$player =& $players[$guid];
$guidplayer = $players[$guid]->getGuid();
$pidplayer = $players[$guid]->getPid();
$nameplayer = $players[$guid]->getName();
$status = $mod->rconPlayerList(); //Spielerliste abrufen
foreach ($status as $line) {
if ($line["pid"] == $players[$guidplayer]->getPid() $line["guid"] == $guidplayer) { //Wenn true , dann definiere ip
$ip = $line["ip"];
break;
}
}
$posting = "public"; //Fьr Pulic (say) oder private PM:
$i = ipaddress_to_uint32($ip); //IP in den Uwandler schicken
$geoipvar = geoip_main($i , $nameplayer , $posting); //IP in den Main Teil schicken , wo er verarbeitet wird
$mod->RconSay($geoipvar); //Die ausgabe der Function nun im CoD Chat Posten
}
function geoip($guid, $parameters) { //Fьr Admins
global $mod;
global $players;
//Ein paar Vatiablen definieren
$guidplayer = $players[$guid]->getGuid();
$pidplayer = $players[$guid]->getPid();
$nameplayer = $players[$guid]->getName();
$parameters = implode(" ", $parameters);
$player = $mod->findPlayerGuid($parameters);
if (!$player) {
$players[$guid]->say($mod->getLngString("playerNotFound", array("<SEARCH>"), array($parameters)));
return false;
}
$status = $mod->rconPlayerList(); //siehe oben
foreach ($status as $line) {
if ($line["pid"] == $players[$player]->getPid() $line["guid"] == $player) {
$ip = $line["ip"];
break;
}
}
if (!isset($ip)) {
$players[$guid]->say($mod->getLngString("anyError"));
return;
}
$posting = "privat"; // siehe oben
$i = ipaddress_to_uint32($ip); //IP in den Uwandler schicken
$geoipvar = geoip_main($i , $nameplayer , $posting);
$players[$guid]->Say($geoipvar); //in Cod per PM: schreiben
}
//IP Umwandler
function ipaddress_to_uint32($ip){
list($v4,$v3,$v2,$v1) = explode(".", $ip); //Teile IP in 4 Teile auf
return ($v4*256 *256*256) + ($v3*256*256) + ($v2*256) + ($v1); //malnehmen und fьr DB vorbereiten
}
function geoip_main($i , $nameplayer , $posting){
global $mod;
global $players;
// Mysqll Login
$mysqlhost = $mod->getCV("geoip" , "host");
$mysqluser = $mod->getCV("geoip" , "user");
$mysqlpw = $mod->getCV("geoip" , "password");
$db = mysql_connect($mysqlhost, $mysqluser , $mysqlpw) or die(mysql_error());
//Datenbank auswдhlen
mysql_select_db('mamstats', $db) or die(mysql_error());
//Daten senden und empfangen
$sql = "select * from `csv` where start<= $i and $i <=end;";
$result = mysql_query($sql);
if ($row = mysql_fetch_array($result)){
//Suchen und ersetzen
$search = array(
"<NAME>",
"<COUNTRY>"
);
$replace = array(
$nameplayer,
$row['cn']
);
//Switchen fьr die richtige Ausgabe
switch ($posting) {
case "private":
return str_replace($search, $replace, $mod->getCV("geoip" , "messageadmin"));
break;
case "public":
return str_replace($search, $replace, $mod->getCV("geoip" , "message"));
break;
}
}
}
?>