Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add '!admin give' command
  • Loading branch information
Bishbash777 committed May 11, 2020
commit 48f499d6f8a735a96e478d8aa1a06da0aa3bbb8d
26 changes: 26 additions & 0 deletions Essentials/Commands/AdminModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,31 @@ public void ListMute()
var ms = new DialogMessage("Muted Users", content: sb.ToString());
ModCommunication.SendMessageTo(ms, Context.Player.SteamUserId);
}

[Command("give", "Insert an item with a specific quanity into a players inventory")]
[Permission(MyPromoteLevel.Admin)]
public void give(string playerName, string type, string item, int quantity) {
type = "MyObjectBuilder_" + type;
VRage.Game.MyDefinitionId.TryParse(type, item, out VRage.Game.MyDefinitionId defID);
if (defID.ToString().Contains("null")) {
Context.Respond("Invalid item type");
return;
}
if (playerName != "*") {
var p = Utilities.GetPlayerByNameOrId(playerName);
if (p == null) {
Context.Respond("Player not found");
return;
}
Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.IdentityId, defID, quantity);
}

else {
foreach (var p in MySession.Static.Players.GetOnlinePlayers()) {
Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.Identity.IdentityId, defID, quantity);
}
}
Context.Respond("Item(s) given!");
}
}
}