Remove EvoStats

Being replaced by dtStats
This commit is contained in:
ChocoTaco 2025-01-11 11:51:05 -05:00
parent fa69bce4b7
commit e40131f735
9 changed files with 6 additions and 992 deletions

View file

@ -1,428 +0,0 @@
// Eolk - People like evo's stats a lot... so that's what we'll give them...
$weap_message[1] = "Blaster master";
$weap_message[2] = "Plasma roaster";
$weap_message[3] = "Chainwh0re";
$weap_message[4] = "Disc-O-maniac";
$weap_message[5] = "Grenade puppy";
$weap_message[6] = "Laser turret";
$weap_message[8] = "Mortar maniac";
$weap_message[9] = "Missile lamer";
$weap_message[10] = "Shocklance bee";
$weap_message[11] = "Mine mayhem";
$weap_message[13] = "Road killer";
// Extra Stats
$weap_message[31] = "Demoman";
$weap_message[21] = "Clamp Farmer";
$weap_message[22] = "Spike Farmer";
$weap_message[26] = "Shrike Gunner";
$weap_message[27] = "Tailgunner";
$weap_message[28] = "Bombardier";
$weap_message[29] = "Tank Gunner (chain)";
$weap_message[30] = "Tank Gunner (mortar)";
$weap_message[31] = "Satchel Punk";
$weap_message[50] = "Combo King (mine+disc)";
// Handlers
package EvoStatHandles
{
function Armor::damageObject(%data, %targetObject, %sourceObject, %position, %amount, %damageType, %momVec, %mineSC)
{
Parent::damageObject(%data, %targetObject, %sourceObject, %position, %amount, %damageType, %momVec, %mineSC);
// call the function
if($Host::ClassicEvoStats)
handleDamageStat(%data, %targetObject, %sourceObject, %position, %amount, %damageType, %momVec, %mineSC);
}
function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation)
{
Parent::onClientKilled(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation);
// call the function
if($Host::ClassicEvoStats)
handleKillStat(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation);
}
function ProjectileData::onCollision(%data, %projectile, %targetObject, %modifier, %position, %normal)
{
if(isObject(%targetObject)) // Console spam fix.
{
// call the function
if($Host::ClassicEvoStats)
handleMAStat(%data, %projectile, %targetObject, %modifier, %position, %normal);
}
Parent::onCollision( %data, %projectile, %targetObject, %modifier, %position, %normal );
}
};
// Prevent package from being activated if it is already
if (!isActivePackage(EvoStatHandles))
activatePackage(EvoStatHandles);
// handleDamageStat(%targetObject, %sourceObject, %position, %amount, %damageType)
// Info: Calcs: Damage and SnipeShot detection.
function handleDamageStat(%data, %targetObject, %sourceObject, %position, %amount, %damageType, %momVec, %mineSC)
{
// Reject damage that is not player initiated.
if(%damageType == 7 || %damageType == 12 || %damageType == 14 || %damageType == 24 || %damageType == 25 || %damageType == 33 || %damageType == 35 || %damageType == 36 || %damageType == 98 || %damageType == 99)
return;
// failsafe
if(!isObject(%sourceObject) || %sourceObject $= "" || !isObject(%targetObject) || %targetObject $= "")
return;
// don't count damage done to vehicles
if(%targetObject.isMounted())
return;
// Vehicle Impacts.
if(%damageType == 13){ // run down by vehicle
if(!(%attacker = %sourceObject.getControllingClient()) > 0){
return;
}
}
// Turrets.
else if(%sourceObject.getClassName() $= "Turret" || %sourceObject.getClassName() $= "VehicleTurret" || %sourceObject.getClassName() $= "FlyingVehicle" || %sourceObject.getClassName() $= "HoverVehicle"){
// Controlled
%attacker = %sourceObject.getControllingClient(); //is turret being controlled?
if(%attacker == 0){ // Not controlled.
// Owned
if(isObject(%sourceObject.owner)){
%attacker = %sourceObject.owner;
}
// Automated & no-owner.
else{
return;
}
}
} else { // Pretty much anything else.
%attacker = %sourceObject.client;
}
%victim = %targetObject.client;
// failsafe
if(%attacker $= "" || %victim $= "" || %attacker $= %victim)
return;
// check if it's a tk
if(Game.numTeams > 1 && %attacker.team $= %victim.team)
return;
// store the damage
if($Host::ClassicStatsType == 2)
{
// Teratos: Going to add mine+disc as a category...
// Teratos: Tracking only gets the second batch of damage, but we add 85% of that to make up for the first batch of damage (just a dumb estimate so damage numbers look realistic in post-game).
if(%victim.mineDisc) {
//$stats::weapon_damage[%attacker, 50] += %amount + (%amount * (%damageType == 11 ? 0.87 : 1.41)); // Mine accounts for more than disc.
$stats::weapon_damage[%attacker, 50] += %amount + $stats::last_minedisc[%attacker];
if($stats::weapon_damage[%attacker, 50] > $stats::weap_table[50])
{
$stats::weap_table[50] = $stats::weapon_damage[%attacker, 50];
$stats::client_weap_table[50] = getTaggedString(%attacker.name);
}
}
$stats::last_minedisc[%attacker] = %amount; // Track the last amount of damage so we can add it to the mine+disc.
// Teratos: END Mine+Disc Support.
$stats::weapon_damage[%attacker, %damageType] += %amount;
if($stats::weapon_damage[%attacker, %damageType] > $stats::weap_table[%damageType])
{
$stats::weap_table[%damageType] = $stats::weapon_damage[%attacker, %damageType];
$stats::client_weap_table[%damageType] = getTaggedString(%attacker.name);
}
}
// is it a laser damage?
if(%damageType == 6)
{
// i will consider only shots that have been fired with 60% of total energy
if(%sourceObject.getEnergyLevel() / %sourceObject.getDataBlock().maxEnergy < 0.6)
return;
%distance = mFloor(VectorDist(%position, %sourceObject.getWorldBoxCenter()));
// max distance for sniper (this is the only fix i could find)
// if(%distance > 1000)
// %distance = 1000;
// is it an headshot?
if(%victim.headshot)
{
%attacker.hs++;
if( ( %attacker.showMA $= "" ) || ( %attacker.showMA == 1 ) )
bottomPrint(%attacker, "HEADSHOT (" @ %attacker.hs @ ")! Distance is " @ %distance @ " meters.", 3);
logEcho(%attacker.nameBase @" (pl "@%attacker.player@"/cl "@%attacker@") headshot ("@%distance@")");
if(%attacker.hs > $stats::snipe_counter)
{
$stats::snipe_counter = %attacker.hs;
$stats::snipe_client = getTaggedString(%attacker.name);
}
if(%distance > $stats::snipe_maxdistance)
{
$stats::snipe_maxdistance = %distance;
$stats::snipe_maxdistanceclient = getTaggedString(%attacker.name);
}
}
else // no
{
if(%attacker.showMA $= "" || %attacker.showMA)
bottomPrint(%attacker, "HIT! Distance is " @ %distance @ " meters.", 3);
if(%distance > $stats::snipe_maxdistance)
{
$stats::snipe_maxdistance = %distance;
$stats::snipe_maxdistanceclient = getTaggedString(%attacker.name);
}
}
// this callback will allow players to autoscreenshot the shot
messageClient(%attacker, 'MsgSnipeShot', "", %distance);
}
}
// handleKillStat(%clVictim, %clKiller, %damageType, %implement)
// Info: Calcs: Kills, TeamKills, FC kills
function handleKillStat(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation)
{
if(%damageType == 13) // is a roadkill
%clKiller = %implement.getControllingClient();
if ( !isObject( %clVictim ) || !isObject( %clKiller ) )
return;
// failsafe
if(%clKiller $= "" || %clVictim $= "" || %clKiller $= %clVictim)
return;
// is it a tk?
if(%game.numTeams > 1 && %clKiller.team $= %clVictim.team)
{
$stats::tk[%clKiller]++;
if($stats::tk[%clKiller] > $stats::tk_counter)
{
$stats::tk_counter = $stats::tk[%clKiller];
$stats::tk_client = getTaggedString(%clKiller.name);
}
}
else // no
{
if($Host::ClassicStatsType == 1)
{
$stats::weapon_kills[%clKiller, %damageType]++;
if($stats::weapon_kills[%clKiller, %damageType] > $stats::weap_table[%damageType])
{
$stats::weap_table[%damageType] = $stats::weapon_kills[%clKiller, %damageType];
$stats::client_weap_table[%damageType] = getTaggedString(%clKiller.name);
}
}
// was the victim a fc?
if(%clVictim.plyrDiedHoldingFlag)
{
$stats::fckiller[%clKiller]++;
if($stats::fckiller[%clKiller] > $stats::fckiller_counter)
{
$stats::fckiller_counter = $stats::fckiller[%clKiller];
$stats::fckiller_client = getTaggedString(%clKiller.name);
}
}
}
}
// handleMAStat(%projectile, %targetObject, %position)
// Info: MA detection
function handleMAStat(%data, %projectile, %targetObject, %modifier, %position, %normal)
{
// failsafe
if(!isObject(%targetObject) || %targetObject $= "")
return;
// failsafe
if(!isObject(%projectile.sourceObject) || %projectile.sourceObject $= "")
return;
%victim = %targetObject.client;
%killer = %projectile.sourceObject.client;
// // Altair's method
// %distance = mFloor(VectorDist(%position, %projectile.sourceObject.getWorldBoxCenter()));
// // Evolution Method
%distance = mFloor(VectorDist(%position, %projectile.initialPosition));
// failsafe
if(%victim $= "" || %killer $= "")
return;
%projectileType = %data.getName() !$= "TR2DiscProjectile" ? %data.getName() : "DiscProjectile";
// only disc, plasma, or blaster
if(%projectileType !$= "DiscProjectile" && %projectileType !$= "PlasmaBolt" && %projectileType !$= "EnergyBolt")
return;
// is it a tk?
if(Game.numTeams > 1 && %killer.team $= %victim.team)
return;
// Eolk - changes to MA code
%position = %targetObject.getPosition();
%raycast = containerRaycast(%position, vectorAdd(%position, "0 0 -10"), $TypeMasks::ForceFieldObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType, %targetObject);
if(!isObject(firstWord(%raycast))) // We've got something...
{
switch$(%projectileType)
{
case DiscProjectile:
%killer.midairs++;
if( ( %killer.showMA $= "" ) || ( %killer.showMA == 1 ) )
bottomPrint(%killer, "Midair Disk (" @ %killer.midairs @ ")! Distance is " @ %distance @ " meters.", 3);
// this callback will allow players to autoscreenshot the MA
messageClient(%killer, 'MsgMidAir', "", %distance);
logEcho(%killer.nameBase @" (pl "@%killer.player@"/cl "@%killer@") hit a midair disc shot ("@%distance@")");
if(%killer.midairs > $stats::ma_counter)
{
$stats::ma_counter = %killer.midairs;
$stats::ma_client = getTaggedString(%killer.name);
}
if(%distance > $stats::ma_maxdistance)
{
$stats::ma_maxdistance = %distance;
$stats::ma_maxdistanceclient = getTaggedString(%killer.name);
}
case PlasmaBolt:
%killer.PlaMA++;
if ( ( %killer.showMA $= "" ) || ( %killer.showMA == 1 ) )
bottomPrint(%killer, "Midair Plasma (" @ %killer.PlaMA @ ")! Distance is " @ %distance @ " meters.", 3);
// this callback will allow players to autoscreenshot the MA
messageClient(%killer, 'MsgPlasmaMidAir', "", %distance);
logEcho(%killer.nameBase @" (pl "@%killer.player@"/cl "@%killer@") hit a midair plasma shot ("@%distance@")");
if(%killer.PlaMA > $stats::PlaMA_counter)
{
$stats::PlaMA_counter = %killer.PlaMA;
$stats::PlaMA_client = getTaggedString(%killer.name);
}
if(%distance > $stats::PlaMA_maxdistance)
{
$stats::PlaMA_maxdistance = %distance;
$stats::PlaMA_maxdistanceclient = getTaggedString(%killer.name);
}
case EnergyBolt:
%killer.blaMA++;
if( ( %killer.showMA $= "" ) || ( %killer.showMA == 1 ) )
bottomPrint(%killer, "Midair Blaster (" @ %killer.blaMA @ ")! Distance is " @ %distance @ " meters.", 3);
// this callback will allow players to autoscreenshot the MA
messageClient(%killer, 'MsgBlasterMidAir', "", %distance);
logEcho(%killer.nameBase @" (pl "@%killer.player@"/cl "@%killer@") hit a midair blaster shot ("@%distance@")");
if(%killer.blaMA > $stats::BlaMA_counter)
{
$stats::BlaMA_counter = %killer.BlaMA;
$stats::BlaMA_client = getTaggedString(%killer.name);
}
if(%distance > $stats::BlaMA_maxdistance)
{
$stats::BlaMA_maxdistance = %distance;
$stats::BlaMA_maxdistanceclient = getTaggedString(%killer.name);
}
}
}
}
// sendEvoDebriefing(%client)
// Info: Send Evo stats to the debriefing page
function sendEvoDebriefing(%client)
{
// Eolk - Remove redundant checks
messageClient(%client, 'MsgDebriefAddLine', "", '\n<lmargin:0><spush><color:00dc00>%1 - %2<spop>', $MissionDisplayName, $MissionTypeDisplayName);
if($stats::MaxGrabSpeed || $stats::grabs_counter || $stats::fckiller_counter || $stats::caps_counter || $stats::fastestCap)
{
messageClient(%client, 'MsgDebriefAddLine', "", '\n<lmargin:0><spush><color:00dc00><font:univers condensed:18>FLAG STATS<spop>');
if($stats::fastestCap)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> Fastest Cap</clip><lmargin%%:30><clip%%:60> %1</clip><lmargin%%:60><clip%%:40> %2</clip><spop>', $stats::fastcap_client, $stats::fastcap_time);
if($stats::MaxGrabSpeed)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> Flaming Ass</clip><lmargin%%:30><clip%%:60> %1</clip><lmargin%%:60><clip%%:40> %2 Kph!</clip><spop>', $stats::Grabber, $stats::MaxGrabSpeed);
if($stats::caps_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> Cap Mastah</clip><lmargin%%:30><clip%%:60> %1</clip><lmargin%%:60><clip%%:40> %2</clip><spop>', $stats::caps_client, $stats::caps_counter);
if($stats::grabs_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> Grabz0r</clip><lmargin%%:30><clip%%:60> %1</clip><lmargin%%:60><clip%%:40> %2</clip><spop>', $stats::grabs_client, $stats::grabs_counter);
if($stats::fckiller_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> FC killer</clip><lmargin%%:30><clip%%:60> %1</clip><lmargin%%:60><clip%%:40> %2</clip><spop>', $stats::fckiller_client, $stats::fckiller_counter);
}
if($stats::BlaMA_counter || $stats::ma_counter || $stats::PlaMA_counter)
{
messageClient(%client, 'MsgDebriefAddLine', "", '\n<lmargin:0><spush><color:00dc00><font:univers condensed:18>MID AIR<lmargin%%:30>CHAMPION<lmargin%%:60>DISTANCE<spop>');
if($stats::ma_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> Disk</clip><lmargin%%:30><clip%%:60> %1 (%2)</clip><lmargin%%:60><clip%%:60> %3 (%4 mt)</clip><spop>', $stats::ma_client, $stats::ma_counter, $stats::ma_maxdistanceclient, $stats::ma_maxdistance);
if($stats::PlaMA_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> Plasma</clip><lmargin%%:30><clip%%:60> %1 (%2)</clip><lmargin%%:60><clip%%:60> %3 (%4 mt)</clip><spop>', $stats::PlaMA_client, $stats::PlaMA_counter, $stats::PlaMA_maxdistanceclient, $stats::PlaMA_maxdistance);
if($stats::BlaMA_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> Blaster</clip><lmargin%%:30><clip%%:60> %1 (%2)</clip><lmargin%%:60><clip%%:60> %3 (%4 mt)</clip><spop>', $stats::BlaMA_client, $stats::BlaMA_counter, $stats::BlaMA_maxdistanceclient, $stats::BlaMA_maxdistance);
}
if($stats::snipe_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '\n<lmargin:0><spush><color:00dc00><font:univers condensed:18>Headhunter<lmargin%%:30> %1 (%2)!<spop>', $stats::snipe_client, $stats::snipe_counter);
if($stats::snipe_maxdistance)
{
%x = $stats::snipe_counter ? "" : "\n";
messageClient(%client, 'MsgDebriefAddLine', "", '%3<lmargin:0><spush><color:00dc00><font:univers condensed:18>Longest Snipeshot is %1 meters by %2<spop>', $stats::snipe_maxdistance, $stats::snipe_maxdistanceclient, %x);
}
for(%damageType = 1; %damageType < 51; %damageType++)
{
if(%damageType == 7 || %damageType == 12 || (%damageType > 13 && %damageType < 21) || %damageType == 23 || %damageType == 24 || %damageType == 25) {
continue;
}
if(%damageType > 31 && %damageType < 50) {
continue;
}
if($stats::weap_table[%damageType] > 0)
{
if($Host::ClassicStatsType == 2)
{
if(!%message)
{
messageClient(%client, 'MsgDebriefAddLine', "", '\n<lmargin:0><spush><color:00dc00><font:univers condensed:18>TYPE<lmargin%%:30>PLAYER<lmargin%%:60>TOTAL DAMAGE<spop>');
%message = 1;
}
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> %1</clip><lmargin%%:30><clip%%:60> %2</clip><lmargin%%:60><clip%%:40> %3</clip><spop>', $weap_message[%damageType], $stats::client_weap_table[%damageType], mFormatFloat($stats::weap_table[%damageType], "%.2f"));
}
else if($Host::ClassicStatsType == 1)
{
if(!%message)
{
messageClient(%client, 'MsgDebriefAddLine', "", '\n<lmargin:0><spush><color:00dc00><font:univers condensed:18>TYPE<lmargin%%:30>PLAYER<lmargin%%:60>KILLS<spop>');
%message = 1;
}
messageClient(%client, 'MsgDebriefAddLine', "", '<lmargin:0><spush><color:00dc00><clip%%:40><font:univers condensed:18> %1</clip><lmargin%%:30><clip%%:60> %2</clip><lmargin%%:60><clip%%:40> %3</clip><spop>', $weap_message[%damageType], $stats::client_weap_table[%damageType], $stats::weap_table[%damageType]);
}
}
}
if($stats::tk_counter)
messageClient(%client, 'MsgDebriefAddLine', "", '\n<lmargin:0><spush><color:00dc00><font:univers condensed:18>And the best teamkiller award goes to... %1 (%2)!<spop>', $stats::tk_client, $stats::tk_counter);
}

View file

@ -1,332 +0,0 @@
//$Host::dtBanlist = "prefs/dtBanlist.cs";
//$Host::KickBanTime = 20; is 20 Minutes
//$Host::BanTime = 43200; is One Month
//$Host::BanTime = 129600; is Three Months
//$Host::BanTime = 259200; is Six Months
//$Host::BanTime = 518400; is 1 year
//$Host::BanTime = 1000000; is Until you unban them (Forever)
//$Host::BanTime = BAN; is Until you unban them (Forever)
//$dtBanList::GUID3555379 = "DAY OF THE YEAR BANNED \t YEAR BANNED \t HOUR BANNED \t MINUTE BANNED \t TIME TO BE BANNED";
//$dtBanList::GUID3555379 = "4\t2021\t18\t31\t518400";
//TO UNBAN SOMEONE WITHOUT RESTARTING THE SERVER
//banList();in console
//unbanIndex(%index) %index is the number next to the players name from listBans();
//Example: unbanold(555555,"22.222.222.222"); put ip in quotes
$dtBanList::save =1;
package dtBan
{
//Keep track of gags (Disconnecting and Reconnecting)
function GameConnection::onDrop(%client, %reason)
{
%ip = %client.getAddress();
%ip = getSubStr(%ip, 3, strLen(%ip));
%ip = getSubStr(%ip, 0, strstr(%ip, ":"));
%ip = strReplace(%ip, ".", "_");
$chatGagged[%ip] = $chatGagged[%client.guid] = (%client.isGagged == 1); //save status of this
parent::onDrop(%client, %reason);
}
//Reapply the gag
function GameConnection::onConnect( %client, %name, %raceGender, %skin, %voice, %voicePitch )
{
parent::onConnect( %client, %name, %raceGender, %skin, %voice, %voicePitch );
%ip = %client.getAddress();
%ip = getSubStr(%ip, 3, strLen(%ip));
%ip = getSubStr(%ip, 0, strstr(%ip, ":"));
%ip = strReplace(%ip, ".", "_");
%client.isGagged = ($chatGagged[%ip] || $chatGagged[%client.guid]); //restore status
}
function ClassicLoadBanlist()
{
$ClassicPermaBans = 0;
if(isFile($Host::dtBanlist))
exec($Host::dtBanlist);
$ClassicWhitelists = 0;
exec($Host::ClassicWhitelist);
}
function BanList::add(%guid, %ipAddress, %time){
if(%time > 999999){
%time = "BAN";
}
%name = getClientBanName(%guid, %ipAddress);
if (%guid > 0){
$dtBanList::GUID[%guid] = dtBanMark() TAB %time TAB %name;
}
if (getSubStr(%ipAddress, 0, 3) $= "IP:"){
%bareIP = getSubStr(%ipAddress, 3, strLen(%ipAddress));
%bareIP = getSubStr(%bareIP, 0, strstr(%bareIP, ":"));
%bareIP = strReplace(%bareIP, ".", "_"); // variable access bug workaround
// add IP ban
$dtBanList::IP[%bareIP] = dtBanMark() TAB %time TAB %name;
}
%found = 0;
%eIndex = -1;
for (%i = 0; %i < 100; %i++){
if($dtBanList::NameList[%i] !$= ""){
if(getField($dtBanList::NameList[%i], 0) $= %name){
%found =1;
if(%guid > 0)
$dtBanList::NameList[%i] = setField($dtBanList::NameList[%i], 1, %guid);
if(getSubStr(%ipAddress, 0, 3) $= "IP:")
$dtBanList::NameList[%i] = setField($dtBanList::NameList[%i], 2, %bareIP);
break;
}
}
else if(%eIndex == -1){
%eIndex = %i;
}
}
if(!%found){
if($dtBanList::NameList[%eIndex] $= ""){
$dtBanList::NameList[%eIndex] = %name TAB %guid TAB %bareIP;
}
else{
error("Ban Index is not empty");
}
}
saveBanList();
}
function banList_checkIP(%client){
%ip = %client.getAddress();
%ip = getSubStr(%ip, 3, strLen(%ip));
%ip = getSubStr(%ip, 0, strstr(%ip, ":"));
%ip = strReplace(%ip, ".", "_");
%time = $dtBanList::IP[%ip];
if(getField(%time,4) $= "BAN")
return 1;
if (getFieldCount(%time) > 0){
%delta = getBanCount(getField(%time,0), getField(%time,1),getField(%time,2),getField(%time,3));
if (%delta < getField(%time,4))
return 1;
else{
for (%i = 0; %i < 100; %i++){
if($dtBanList::NameList[%i] !$= ""){
if(getField($dtBanList::NameList[%i], 1) $= %guid){
unbanIndex(%i);
break;
}
}
}
$dtBanList::IP[%ip] = "";
saveBanList();
}
}
return 0;
}
function banList_checkGUID(%guid){
%time = $dtBanList::GUID[%guid];
if(getField(%time,4) $= "BAN")
return 1;
if (getFieldCount(%time) > 0){
%delta = getBanCount(getField(%time,0), getField(%time,1),getField(%time,2),getField(%time,3));
if (%delta < getField(%time,4))
return 1;
else{
for (%i = 0; %i < 100; %i++){
if($dtBanList::NameList[%i] !$= ""){
if(getField($dtBanList::NameList[%i], 1) $= %guid){
unbanIndex(%i);
break;
}
}
}
$dtBanList::GUID[%guid] = "";
saveBanList();
}
}
return 0;
}
function CreateServer(%mission, %missionType)
{
parent::CreateServer(%mission, %missionType);
//Clean timed out bans at startup
schedule(10000,0,"banListClean",0);
}
};
if (!isActivePackage(dtBan)){
activatePackage(dtBan);
}
function saveBanList(){
if(!isEventPending($banEvent))
$banEvent = schedule(1000,0,"export","$dtBanList*", $Host::dtBanlist);
}
function getClientBanName(%guid, %ip){
%found = 0;
for (%i = 0; %i < ClientGroup.getCount(); %i++){
%client = ClientGroup.getObject(%i);
if(%guid > 0 && %client.guid $= %guid){
%found = 1;
break;
}
else if(%client.getAddress() $= %ip){
%found = 1;
break;
}
}
if(%found){
%authInfo = %client.getAuthInfo();
%realName = getField( %authInfo, 0 );
if(%realName !$= "")
%name = %realName;
else
%name = stripChars( detag( getTaggedString( %client.name ) ), "\cp\co\c6\c7\c8\c9\c0" );
return trim(%name);
}
return 0;
}
function getBanCount(%d, %year, %h, %n){
if(%d && %year && %h && %n){
%dif = formattimestring("yy") - %year;
%days += 365 * (%dif-1);
%days += 365 - %d;
%days += dtBanDay();
%ht = %nt = 0;
if(formattimestring("H") > %h){
%ht = formattimestring("H") - %h;
}
else if(formattimestring("H") < %h){
%ht = 24 - %h;
%ht = formattimestring("H")+ %ht;
}
if(formattimestring("n") > %n){
%nt = formattimestring("n") - %n;
}
else if(formattimestring("n") < %n){
%nt = 60 - %n;
%nt = formattimestring("n") + %nt;
}
return mfloor((%days * 1440) + (%ht*60) + %nt);
}
return 0;
//return mfloor((%days * 1440) + (%ht*60) + %nt) TAB (%days * 1440) TAB (%ht*60) TAB %nt;
}
function dtBanDay(){
%date = formattimestring("mm dd yy");
%m = getWord(%date,0);%d = getWord(%date,1);%y = getWord(%date,2);
%count = 0;
if(%y % 4 < 1){%days[2] = "29";}else{%days[2] = "28";} // leap year
%days[1] = "31";%days[3] = "31";
%days[4] = "30"; %days[5] = "31"; %days[6] = "30";
%days[7] = "31"; %days[8] = "31"; %days[9] = "30";
%days[10] = "31"; %days[11] = "30"; %days[12] = "31";
for(%i = 1; %i <= %m-1; %i++){
%count += %days[%i];
}
return %count + %d;
}
function dtBanMark(){
%date = formattimestring("mm dd yy");
%m = getWord(%date,0);%d = getWord(%date,1);%y = getWord(%date,2);
%count = 0;
if(%y % 4 < 1){%days[2] = "29";}else{%days[2] = "28";} // leap year
%days[1] = "31";%days[3] = "31";
%days[4] = "30"; %days[5] = "31"; %days[6] = "30";
%days[7] = "31"; %days[8] = "31"; %days[9] = "30";
%days[10] = "31"; %days[11] = "30"; %days[12] = "31";
for(%i = 1; %i <= %m-1; %i++){
%count += %days[%i];
}
return %count + %d TAB formattimestring("yy") TAB formattimestring("H") TAB formattimestring("n");
}
function banList(){
%found = 0;
for (%i = 0; %i < 100; %i++){
%fieldList = $dtBanList::NameList[%i];
if($dtBanList::NameList[%i] !$= ""){
%found = 1;
error("index:" @ %i SPC "Name:" @ getField(%fieldList,0) SPC "GUID:" @ getField(%fieldList,1) SPC "IP:" @ getField(%fieldList,2));
}
}
if(%found){
error("Use unbanIndex(%index); to unban user from the list ");
}
else{
error("No bans, see" SPC $Host::dtBanlist SPC "for older entries");
}
}
function unbanIndex(%index){
if( $dtBanList::NameList[%index] !$= ""){
%fieldList = $dtBanList::NameList[%index];
%name = getField(%fieldList, 0);
$dtBanList::NameList[%index] = "";
error("Name" SPC getField(%fieldList,0) SPC "UNBANNED");
%guid = getField(%fieldList,1);
if($dtBanList::GUID[%guid] !$= ""){
$dtBanList::GUID[%guid] = "";
error("GUID" SPC %guid SPC "UNBANNED");
}
%ip = getField(%fieldList,2);
if($dtBanList::IP[%ip] !$= ""){
$dtBanList::IP[%ip] = "";
error("IP" SPC %ip SPC "UNBANNED");
}
saveBanList();
return %name;
}
return -1;
}
//old method
function unbanold(%guid,%ip){
%ip = strReplace(%ip, ".", "_");
for (%i = 0; %i < 100; %i++){
if($dtBanList::NameList[%i] !$= ""){
if(getField($dtBanList::NameList[%i], 2) $= %ip || getField($dtBanList::NameList[%i], 1) $= %guid){
unbanIndex(%i);
return;
}
}
}
if($dtBanList::GUID[%guid] !$= ""){
$dtBanList::GUID[%guid] = "";
error("GUID" SPC %guid SPC "UNBANNED");
}
if($dtBanList::IP[%ip] !$= ""){
$dtBanList::IP[%ip] = "";
error("IP" SPC %ip SPC "UNBANNED");
}
saveBanList();
}
//Clean timed out bans at startup
function banListClean(){
%found = 0;
for (%i = 0; %i < 100; %i++){
%fieldList = $dtBanList::NameList[%i];
if($dtBanList::NameList[%i] !$= ""){
%guid = getField($dtBanList::NameList[%i], 1);
%ip = getField($dtBanList::NameList[%i], 2);
%time = $dtBanList::GUID[%guid];
%delta = getBanCount(getField(%time,0), getField(%time,1),getField(%time,2),getField(%time,3));
if (getField(%time,4) !$= "BAN" && %delta > getField(%time,4)){
$dtBanList::NameList[%i] = "";
$dtBanList::GUID[%guid] = "";
$dtBanList::IP[%ip] = "";
error("GUID" SPC %guid SPC "IP" SPC %ip SPC "UNBANNED");
}
}
}
saveBanList();
}

View file

@ -191,10 +191,9 @@ function ALTsendModInfoToClient(%client)
%rapeppl = "<color:" @ $Host::LoadScreenColor1 @ ">Min No Base Rape: <color:" @ $Host::LoadScreenColor2 @ ">" @ $Host::NoBaseRapePlayerCount;
%turrets = "<color:" @ $Host::LoadScreenColor1 @ ">Min Turrets: <color:" @ $Host::LoadScreenColor2 @ ">" @ $Host::EnableTurretPlayerCount;
if($Host::ClassicEvoStats && $Host::ClassicStatsType > 0)
%stats = "<color:" @ $Host::LoadScreenColor1 @ ">Stats based on: <color:" @ $Host::LoadScreenColor2 @ ">" @ ($Host::ClassicStatsType == 1 ? "Kills" : "Damage");
if($dtStats::evoStyleDebrief)
%stats = "<color:" @ $Host::LoadScreenColor1 @ ">Stats based on: <color:" @ $Host::LoadScreenColor2 @ ">" @ "Kills & Damage";
%currentmis = "<color:" @ $Host::LoadScreenColor1 @ ">Current mission: <color:" @ $Host::LoadScreenColor2 @ ">" @ $MissionDisplayName @ " (" @ $MissionTypeDisplayName @ ")";
@ -410,8 +409,8 @@ function NORMALsendModInfoToClient(%client)
%turrets = "<color:" @ $Host::LoadScreenColor1 @ ">Min Turrets: <color:" @ $Host::LoadScreenColor2 @ ">" @ $Host::EnableTurretPlayerCount;
if($Host::ClassicEvoStats && $Host::ClassicStatsType > 0)
%stats = "<color:" @ $Host::LoadScreenColor1 @ ">Stats based on: <color:" @ $Host::LoadScreenColor2 @ ">" @ ($Host::ClassicStatsType == 1 ? "Kills" : "Damage");
if($dtStats::evoStyleDebrief)
%stats = "<color:" @ $Host::LoadScreenColor1 @ ">Stats based on: <color:" @ $Host::LoadScreenColor2 @ ">" @ "Kills & Damage";
//if($Evo::ETMMode && $ETMmode::CurrentMap <= $ETMmode::Counter)
//{