Hello everyone!
I got this in my log and program:
Code
0:00 [26.02.11 17:12:35] PHP-Error: Warning in :\Users\Highground\Desktop\Új mappa\adminmod\plugins\logkickbans.php:4 => fopen(logC:/Users/Highground/Desktop/Új mappa/adminmod/log/kickbans.log): failed to open stream: Invalid argument
and this:
Code
48:57 [26.02.11 20:40:34] PHP-Error: Warning in :\Users\Highground\Desktop\Új mappa\adminmod\plugins\logkickbans.php:29 => fopen(logC:/Users/Highground/Desktop/Új mappa/adminmod/log/kickbans.log): failed to open stream: Invalid argument
48:57 [26.02.11 20:40:34] PHP-Error: Warning in :\Users\Highground\Desktop\Új mappa\adminmod\plugins\logkickbans.php:37 => fwrite() expects parameter 1 to be resource, boolean given
What is wrong? I don't understand PHP language
here is my full "logkickbans.php":
Spoiler anzeigen
PHP
<?php
$logkickbans_filehandle = fopen(LOGDIR . "C:/Users/Highground/Desktop/Új mappa/adminmod/log/kickbans.log", "a");
$mod->registerEvent("playerKicked", "logkickbans_kick");
$mod->registerEvent("playerBanned", "logkickbans_ban");
$mod->registerEvent("playerTempBanned", "logkickbans_tempban");
function logkickbans_kick($args) {
global $logkickbans_filehandle;
list($player, $reason, $kicker) = $args;
$date = date("[d.m.y H:i:s]");
$nickname = $GLOBALS['players'][$player]->getName();
if (!$kicker) {
$str = "$date Player \"$nickname\" ($player) got AUTO KICKED for reason: $reason\n";
}
else {
$kicker = $GLOBALS['players'][$kicker]->getName();
$str = "$date Player \"$nickname\" ($player) got KICKED by \"$kicker\" for reason: $reason\n";
}
fwrite($logkickbans_filehandle, $str);
}
function logkickbans_ban($args) {
list($player, $reason, $kicker) = $args;
$date = date("[d.m.y H:i:s]");
$nickname = $GLOBALS['players'][$player]->getName();
if (!$kicker) {
$logkickbans_filehandle = fopen(LOGDIR . "C:/Users/Highground/Desktop/Új mappa/adminmod/log/kickbans.log", "a");
$str = "$date Player \"$nickname\" ($player) got AUTO BANNED for reason: $reason\n";
}
else {
$logkickbans_filehandle = fopen(LOGDIR . "C:/Users/Highground/Desktop/Új mappa/adminmod/log/kickbans.log", "a");
$kicker = $GLOBALS['players'][$kicker]->getName();
$str = "$date Player \"$nickname\" ($player) got BANNED by \"$kicker\" for reason: $reason\n";
}
fwrite($logkickbans_filehandle, $str);
}
function logkickbans_tempban($args) {
global $logkickbans_filehandle;
list($player, $reason, $time, $kicker) = $args;
$date = date("[d.m.y H:i:s]");
$nickname = $GLOBALS['players'][$player]->getName();
if (!$kicker) {
$str = "$date Player \"$nickname\" ($player) got AUTO TEMPBANNED ($time mins) for reason: $reason\n";
}
else {
$kicker = $GLOBALS['players'][$kicker]->getName();
$str = "$date Player \"$nickname\" ($player) got TEMPBANNED ($time mins) by \"$kicker\" for reason: $reason\n";
}
fwrite($logkickbans_filehandle, $str);
}
?>
Alles anzeigen
And +1:
How can i add a weapon to "weponrestrictions" that is not in your list of available weapons?
Thats how my config is look like:
Code
[weaponrestrictions]
enabled = 1
weapons = "gl,m79_mp"
warnstokick = 1
mode = "tempban"
kickreason = "Used a restricted weapon: <WEAPON>"
I'm try to add "thumper" from mw2,but nothing happen if someone uses it
My "weaponrestrictions.php":
Spoiler anzeigen
PHP
<?php
/*
PLUGIN: Weaponrestrictions
================
Kicks players automatically when they are using a restricted weapon
CONFIG:
-------
[weaponrestrictions]
enabled = 1 ;Enable plugin
weapons = "gl,m79_mp" ;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("playerJoined", "weaponrestrictions_playerInit");
$mod->registerEvent("playerKill", "weaponrestrictions_main");
$mod->registerEvent("playerTeamKill", "weaponrestrictions_main");
//Init Players because playerJoined isn't called at startup
array_map("weaponrestrictions_playerInit", array_keys($players));
function weaponrestrictions_main($parameters) {
global $mod;
global $players;
global $logging;
list($killer_guid, $victim_guid, $weapon) = $parameters;
if (!$mod->getCV("weaponrestrictions", "enabled")) {
return;
}
if ($players[$killer_guid]->isProtected()) {
return;
}
$restricted = false;
$weapons = explode(",", strtolower($mod->getCV("weaponrestrictions", "weapons")));
if ($weapon[1] == "MOD_MELEE") {
if (in_array("knife", $weapons)) {
$restricted = true;
}
else {
//Dont warn when player knived while he had a restricted weapon
return;
}
}
else {
$weapmod = $weapon[0];
foreach ($weapons as $value) {
if (strpos($weapmod, $value . "_") === 0) {
$restricted = true;
break;
}
}
}
if (!$restricted) return;
$players[$killer_guid]->weaponrestrictions_warns ++;
$weaponlong = $mod->getLongWeaponName($weapon);
if ($players[$killer_guid]->weaponrestrictions_warns >= $mod->getCV("weaponrestrictions", "warnstokick")) {
switch ($mod->getCV("weaponrestrictions", "mode")) {
case "tempban":
$players[$killer_guid]->tempBan(str_replace("<WEAPON>", $weaponlong, $mod->getCV("weaponrestrictions", "kickreason")));
break;
case "kick":
$players[$killer_guid]->kick(str_replace("<WEAPON>", $weaponlong, $mod->getCV("weaponrestrictions", "kickreason")));
break;
case "ban":
$players[$killer_guid]->ban(str_replace("<WEAPON>", $weaponlong, $mod->getCV("weaponrestrictions", "kickreason")));
break;
}
}
else {
$players[$killer_guid]->say($mod->getLngString("usedRestrictedWeapon", array("<WEAPON>", "<WARNS>", "<MAXWARNS>"), array($weaponlong, $players[$killer_guid]->weaponrestrictions_warns, $mod->getCV("weaponrestrictions", "warnstokick"))));
$logging->write(MOD_NOTICE, "Player '".$players[$killer_guid]->getName()."' has been warned for using restricted weapon: $weapon, PID: ".$players[$killer_guid]->getPID().", GUID: ".$killer_guid);
}
}
function weaponrestrictions_playerInit($guid) {
$GLOBALS['players'][$guid]->weaponrestrictions_warns = 0;
}
?>
Alles anzeigen
Thanks for your help!