Skip to content

Commit e2a99d9

Browse files
authored
Add a visible notification for the player to indicate when they have been given items (#155)
1 parent 96b4154 commit e2a99d9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎Essentials/Commands/AdminModule.cs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,25 +301,30 @@ public void ListMute()
301301

302302
[Command("give", "Insert an item with a specific quanity into a players inventory")]
303303
[Permission(MyPromoteLevel.Admin)]
304-
public void give(string playerName, string type, string item, int quantity) {
305-
type = "MyObjectBuilder_" + type;
304+
public void give(string playerName, string itemType, string item, int quantity) {
305+
string type = "MyObjectBuilder_" + itemType;
306306
VRage.Game.MyDefinitionId.TryParse(type, item, out VRage.Game.MyDefinitionId defID);
307+
307308
if (defID.ToString().Contains("null")) {
308309
Context.Respond("Invalid item type");
309310
return;
310311
}
312+
311313
if (playerName != "*") {
312314
var p = Utilities.GetPlayerByNameOrId(playerName);
313315
if (p == null) {
314316
Context.Respond("Player not found");
315317
return;
316318
}
317319
Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.IdentityId, defID, quantity);
320+
ModCommunication.SendMessageTo(new NotificationMessage($"You have been given {quantity} {item} {itemType}", 5000, "Blue"), p.SteamUserId);
318321
}
319322

320323
else {
321324
foreach (var p in MySession.Static.Players.GetOnlinePlayers()) {
325+
var player = Utilities.GetPlayerByNameOrId(p.DisplayName);
322326
Sandbox.Game.MyVisualScriptLogicProvider.AddToPlayersInventory(p.Identity.IdentityId, defID, quantity);
327+
ModCommunication.SendMessageTo(new NotificationMessage($"You have been given {quantity} {item} {itemType}", 5000, "Blue"), player.SteamUserId);
323328
}
324329
}
325330
Context.Respond("Item(s) given!");

0 commit comments

Comments
 (0)