Felladrin submitted a new resource:

AutoDefend - Makes PlayerMobiles automatically counter-attack their closest aggressor.

AutoDefend

This script makes playermobiles to auto defend themselves when attacked. They will always counter-attack the closest aggressor.

It comes enabled for all accounts by default, but players can disable the feature for their accounts by using the command [AutoDefend to toggle it.

To install, just drop this script anywhere inside your Scripts folder.

Read more about this resource...
 
You need to fix the toggle. In the script replace oncommand with this:

static void OnCommand(CommandEventArgs e)
{
PlayerMobile pm = e.Mobile as PlayerMobile;
Account acc = pm.Account as Account;
if (acc == null && pm == null)
{
return;
}

if (acc.GetTag("AutoDefend") == null || acc.GetTag("AutoDefend") == "Enabled")
{
DisabledPlayers.Add(pm.Serial.Value);
acc.SetTag("AutoDefend", "Disabled");
pm.SendMessage(38, "You have disabled the auto-defend feature for your account.");
}

/*
if (acc != null && pm != null)
{
return;
}
*/
else
{
DisabledPlayers.Remove(pm.Serial.Value);
acc.SetTag("AutoDefend", "Enabled");
pm.SendMessage(68, "You have enabled the auto-defend feature for your account.");
}
}
 
Wanted to play around with this, however getting the following error on Pub 57:
C#:
+ Custom/Custom Commands/AutoDefend.cs:
    CS1061: Line 46: 'IDamageable' does not contain a definition for 'GetDistanceToSqrt' and no accessible extension method 'GetDistanceToSqrt' accepting a first argument of type 'IDamageable' could be found (are you missing a using directive or an assembly reference?)
 
Back