// TEAMDAMAGE.CS -- original script by DS.Poker
// Modified by Presto for PrestoPak compatibility

Include("presto\\match.cs");
Include("presto\\say.cs");
Include("presto\\event.cs");


$teamDamageFloodTime = 10;	// Only say one team damage related message every 10 seconds.

function TeamDamageOnClientMessage(%client, %msg) {
	if (%client != 0)
		return;

	if (Match::String(%msg, "You just harmed Teammate *")) {
		if (!Flood::Protect("teamdamageMyFault", $teamDamageFloodTime))
			return;

		%str = Match::Result(0);
		if (Match::String(%str, "* with your mine!"))
			Say::Team(sayHey, "Hey "@Match::Result(0)@", be careful of my mines!");
		else	Say::Team(saySorry, "Sorry, "@%str);
		return;
		}
	if (Match::String(%msg, "You took Friendly Fire from *")) {
		if (Flood::Protect("teamdamage", $teamDamageFloodTime))
			Say::Team(yellWatchShooting, "Watch where you're shooting, "@ Match::Result(0) @"!");
		return;
		}
	}

Event::Attach(eventClientMessage, TeamDamageOnClientMessage);
