hi
ich will das ein Plugin eine GUID von einem Spieler abruft, der gerade etwas macht
PHP
<?php
/*
PLUGIN: Weaponrestrictions
================
Kicks players automatically when they are using a restricted weapon
CONFIG:
-------
[weaponrestrictions]
enabled = 1 ;Enable plugin
weapons = "gl,frag_grenade_short" ;restricted weapons
warnstokick = 2 ;Warns until players get kicked
mode = "tempban" ;kick/ban/tempban
kickreason = "Used a restricted weapon: <WEAPON>" ;Reason of the kick
NAMESPACE: weaponrestrictions
Functions:
weaponrestrictions_main
weaponrestrictions_playerInit
*/
$mod->setDefaultCV("weaponrestrictions", "enabled", 0);
$mod->setDefaultCV("weaponrestrictions", "weapons", "");
$mod->setDefaultCV("weaponrestrictions", "warnstokick", 2);
$mod->setDefaultCV("weaponrestrictions", "mode", "tempban");
$mod->setDefaultCV("weaponrestrictions", "kickreason", "Used a restricted weapon: <WEAPON>");
$mod->registerEvent("playerKill", "weaponrestrictions_main");
$mod->registerEvent("playerTeamKill", "weaponrestrictions_main");
//Init Players because playerJoined isn't called at startup
function weaponrestrictions_main($parameters) {
global $mod;
global $players;
global $logging;
global $logkickbans_filehandle;
list($killer_guid, $victim_guid, $weapon) = $parameters;
$this->players = &$GLOBALS['players'];
$this->mod = &$GLOBALS['mod'];
$this->logging = &$GLOBALS['logging'];
// if ($weapon[1] == "MOD_MELEE") {
// //Dont warn when player knived while he had a restricted weapon
// return;
// }
$guidplayer = $players[$killer];
$weapon = $weapon[0];
if (!$mod->getCV("weaponrestrictions", "enabled")) {
return;
}
$weapons = explode(",", $mod->getCV("weaponrestrictions", "weapons"));
$restricted = false;
foreach ($weapons as $value) {
if (strpos($weapon, $value . "_") === 0) {
$restricted = true;
break;
}
}
$logkickbans_filehandle = fopen(LOGDIR . "/kickbans.log", "a");
fwrite($logkickbans_filehandle, $weapon);
foreach (array_keys($players) as $guid) {
$mod->addAlias($guid, $players[$guid]->getName());
}
$con = mysql_connect("localhost","root","*_*_*_*_*_*_xD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mamstats", $con);
$sql = "INSERT INTO waffen (guid) VALUES ($guid)
ON DUPLICATE KEY UPDATE $weapon = $weapon +1;";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con);
}
?>
Alles anzeigen