Skip to content

Commit

Permalink
Fixed vehiclefeatures all
Browse files Browse the repository at this point in the history
  • Loading branch information
TH3AL3X committed Oct 26, 2024
1 parent 815e0de commit 4ee1dcb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/Commands/CommandDestroy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
using Essentials.Api.Command;
using Essentials.Api.Command.Source;
using Essentials.I18n;
using Rocket.Unturned.Chat;
using SDG.Unturned;
using UnityEngine;

Expand Down
39 changes: 29 additions & 10 deletions src/Commands/MiscCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,17 +456,36 @@ private CommandResult VehicleFeaturesCommand(ICommandSource src, ICommandArgs ar
if (!src.HasPermission($"{cmd.Permission}.all")) {
return CommandResult.NoPermission($"{cmd.Permission}.all");
}
if (toggleVal.Value) {
component.AutoRepair = true;
component.AutoRefuel = true;
EssLang.Send(src, "AUTO_REPAIR_ENABLED");
EssLang.Send(src, "AUTO_REFUEL_ENABLED");
} else {
component.AutoRepair = false;
component.AutoRefuel = false;
EssLang.Send(src, "AUTO_REPAIR_DISABLED");
EssLang.Send(src, "AUTO_REFUEL_DISABLED");

var players = new List<UPlayer>(UServer.Players);

if (players.Count == 0)
{
return CommandResult.LangError("NO_PLAYERS_FOR_KICK");
}

var reason = args.IsEmpty
? EssLang.Translate("KICK_NO_SPECIFIED_REASON")
: args.Join(0);

players.ForEach(player => {
var component_all = player.GetComponent<VehicleFeatures>() ?? player.AddComponent<VehicleFeatures>();

if (toggleVal.Value)
{
component_all.AutoRepair = true;
component_all.AutoRefuel = true;
EssLang.Send(src, "AUTO_REPAIR_ENABLED");
EssLang.Send(src, "AUTO_REFUEL_ENABLED");
}
else
{
component_all.AutoRepair = false;
component_all.AutoRefuel = false;
EssLang.Send(src, "AUTO_REPAIR_DISABLED");
EssLang.Send(src, "AUTO_REFUEL_DISABLED");
}
});
break;

default:
Expand Down

0 comments on commit 4ee1dcb

Please sign in to comment.