Skip to content

Commit 7048819

Browse files
committed
Add autorepair command
1 parent 29cda66 commit 7048819

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/BF2WebAdmin.Server/Commands/RepairCommands.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ public class RepairAllCommand : BaseCommand
1313
public class RepairCommand : BaseCommand
1414
{
1515
public string Name { get; set; }
16-
}
16+
}
17+
18+
[Command("autorepair|autoheal", Auth.Admin)]
19+
public class AutoRepairCommand : BaseCommand
20+
{
21+
}

src/BF2WebAdmin.Server/Constants/RconScript.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,24 @@ public static class RconScript
409409
"ObjectTemplate.armor.hpLostWhileCriticalDamage 18"
410410
};
411411

412+
public static readonly string[] AutoRepairOn = {
413+
"ObjectTemplate.activeSafe SupplyObject concreteblock_helipad_SupplyObject_helipad",
414+
"ObjectTemplate.radius 1000",
415+
// "ObjectTemplate.workOnSoldiers 1",
416+
// "ObjectTemplate.workOnVehicles 1",
417+
// "ObjectTemplate.healSpeed 3000",
418+
// "ObjectTemplate.refillAmmoSpeed 3000"
419+
};
420+
421+
public static readonly string[] AutoRepairOff = {
422+
"ObjectTemplate.activeSafe SupplyObject concreteblock_helipad_SupplyObject_helipad",
423+
"ObjectTemplate.radius 10",
424+
// "ObjectTemplate.workOnSoldiers 1",
425+
// "ObjectTemplate.workOnVehicles 1",
426+
// "ObjectTemplate.healSpeed 3000",
427+
// "ObjectTemplate.refillAmmoSpeed 3000"
428+
};
429+
412430
//def setFirearmProjectile(firearmTemp, projTemp):
413431
//host.rcon_invoke("ObjectTemplate.active " + firearmTemp)
414432
//host.rcon_invoke("ObjectTemplate.projectileTemplate " + projTemp)

src/BF2WebAdmin.Server/Modules/BF2/BF2Module.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class BF2Module : BaseModule,
2323
IHandleCommand<FlipCommand>,
2424
IHandleCommand<StopCommand>,
2525
IHandleCommand<RepairCommand>,
26+
IHandleCommand<AutoRepairCommand>,
2627
IHandleCommand<KillCommand>,
2728
IHandleCommand<KillIdCommand>,
2829
IHandleCommand<ScoreCommand>,
@@ -305,6 +306,10 @@ public void Handle(ScriptModCommand command)
305306
commands = activate ? RconScript.HeliSupplyFlaresOn : RconScript.HeliFlareDefault;
306307
break;
307308

309+
case "auto-repair":
310+
commands = activate ? RconScript.AutoRepairOn : RconScript.AutoRepairOff;
311+
break;
312+
308313
default:
309314
_gameServer.GameWriter.SendText($"Unknown command: {command.Name}");
310315
return;
@@ -612,7 +617,15 @@ public void Handle(SwitchAllCommand command)
612617
SwitchAll();
613618
}
614619

620+
private bool _autoRepairOn = false;
621+
622+
public void Handle(AutoRepairCommand command)
623+
{
624+
_autoRepairOn = !_autoRepairOn;
615625

626+
_gameServer.GameWriter.SendRcon(_autoRepairOn ? RconScript.AutoRepairOn : RconScript.AutoRepairOff);
627+
_gameServer.GameWriter.SendText(_autoRepairOn ? "Auto repair on": "Auto repair off");
628+
}
616629
}
617630

618631
public class PlayerSnapshot

0 commit comments

Comments
 (0)