Skip to content

Commit 96b4154

Browse files
authored
add '!admin give' command (#154)
1 parent 5308d5f commit 96b4154

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎Essentials/Commands/AdminModule.cs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,5 +298,31 @@ public void ListMute()
298298
var ms = new DialogMessage("Muted Users", content: sb.ToString());
299299
ModCommunication.SendMessageTo(ms, Context.Player.SteamUserId);
300300
}
301+
302+
[Command("give", "Insert an item with a specific quanity into a players inventory")]
303+
[Permission(MyPromoteLevel.Admin)]
304+
public void give(string playerName, string type, string item, int quantity) {
305+
type = "MyObjectBuilder_" + type;
306+
VRage.Game.MyDefinitionId.TryParse(type, item, out VRage.Game.MyDefinitionId defID);
307+
if (defID.ToString().Contains("null")) {
308+
Context.Respond("Invalid item type");
309+
return;
310+
}
311+
if (playerName != "*") {
312+
var p = Utilities.GetPlayerByNameOrId(playerName);
313+
if (p == null) {
314+
Context.Respond("Player not found");
315+
return;
316+
}
317+
Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.IdentityId, defID, quantity);
318+
}
319+
320+
else {
321+
foreach (var p in MySession.Static.Players.GetOnlinePlayers()) {
322+
Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.Identity.IdentityId, defID, quantity);
323+
}
324+
}
325+
Context.Respond("Item(s) given!");
326+
}
301327
}
302328
}

0 commit comments

Comments
 (0)