public void drop_cmd(Player player, string item, int amount) { Character character = player.GetCharacter(); //Get in inv. var sendersItem = DoesInventoryHaveItem(character, item); if (sendersItem.Length != 1 || sendersItem[0].Amount < amount || amount <= 0) { NAPI.Notification.SendNotificationToPlayer(player, "You don't have that item or you don't have that amount or there is more than 1 item with that name."); return; } if (sendersItem[0].CanBeDropped == false) { NAPI.Notification.SendNotificationToPlayer(player, "That item cannot be dropped."); return; } if (sendersItem[0].GetType() == typeof(WeaponCase)) { WeaponCase weaponItem = (WeaponCase)sendersItem[0]; if (weaponItem.OwnerId == character.Id) { player.SendChatMessage("You dropped a weapon case that you're supposed to sell. You've lost 10 renown."); DeleteInventoryItem(character, sendersItem[0].GetType(), amount, x => x == sendersItem[0]); character.WeaponsSold += amount; character.Renown -= 10 * amount; return; } } if (DeleteInventoryItem(character, sendersItem[0].GetType(), amount, x => x == sendersItem[0])) { NAPI.Notification.SendNotificationToPlayer(player, "Item(s) was sucessfully dropped."); //RP ChatManager.RoleplayMessage(player, $"drops an item.", ChatManager.RoleplayMe); LogManager.Log(LogManager.LogTypes.Stats, $"[Drop] {character.CharacterName}[{player.GetAccount().AccountName}] has dropped '{sendersItem[0].LongName}', Amount: '{amount}'."); } }
public void give_cmd(Player player, string id, string item, int amount) { var targetClient = PlayerManager.ParseClient(id); if (targetClient == null) { NAPI.Notification.SendNotificationToPlayer(player, "Target player not found."); return; } Character sender = player.GetCharacter(); Character target = targetClient.GetCharacter(); if (player.Position.DistanceTo(targetClient.Position) > 5f) { NAPI.Notification.SendNotificationToPlayer(player, "You must be near the target player to give him an item."); return; } //Make sure he does have such amount. var sendersItem = DoesInventoryHaveItem(sender, item); if (sendersItem.Length != 1 || sendersItem[0].Amount < amount || amount <= 0) { NAPI.Notification.SendNotificationToPlayer(player, "You don't have that item or you don't have that amount or there is more than 1 item with that name."); return; } if (sendersItem[0].CanBeGiven == false) { NAPI.Notification.SendNotificationToPlayer(player, "That item cannot be given."); return; } if (sendersItem[0].GetType() == typeof(WeaponCase)) { WeaponCase weaponItem = (WeaponCase)sendersItem[0]; if (weaponItem.OwnerId == target.Id) { player.SendChatMessage("You can't give a weapon case back to the gun dealer."); return; } } //Give. switch (GiveInventoryItem(target, sendersItem[0], amount)) { case GiveItemErrors.NotEnoughSpace: NAPI.Notification.SendNotificationToPlayer(player, "The target player doesn't have enough space in his inventory."); NAPI.Notification.SendNotificationToPlayer(targetClient, "Someone has tried to give you an item but failed due to insufficient inventory."); break; case GiveItemErrors.MaxAmountReached: NAPI.Notification.SendNotificationToPlayer(player, "The target player reach max amount of that item."); NAPI.Notification.SendNotificationToPlayer(targetClient, "You have reached the max amount of that item."); break; case GiveItemErrors.Success: NAPI.Notification.SendNotificationToPlayer(player, $"You have sucessfully given ~g~{amount}~w~ ~g~{sendersItem[0].LongName}~w~ to ~g~{target.rp_name()}~w~."); NAPI.Notification.SendNotificationToPlayer(targetClient, $"You have receieved ~g~{amount}~w~ ~g~{sendersItem[0].LongName}~w~ from ~g~{sender.rp_name()}~w~."); if (sendersItem[0].GetType() == typeof(WeaponCase)) { WeaponCase weaponItem = (WeaponCase)sendersItem[0]; if (sender.IsGunrunner && sendersItem[0].GetType() == typeof(WeaponCase) && weaponItem.OwnerId == sender.Id) { player.SendChatMessage("You have sold a weapon and earned 5 renown."); sender.Renown += 5 * amount; sender.WeaponsSold += sender.WeaponsSold * amount; sender.TotalWeaponsSold += amount; } } //Remove from their inv. DeleteInventoryItem(sender, sendersItem[0].GetType(), amount, x => x == sendersItem[0]); //RP ChatManager.RoleplayMessage(player, $"gives an item to {target.rp_name()}", ChatManager.RoleplayMe); LogManager.Log(LogManager.LogTypes.Stats, $"[Give] {sender.CharacterName}[{player.GetAccount().AccountName}] has given {target.CharacterName}[{targetClient.GetAccount().AccountName}] a '{sendersItem[0].LongName}', Amount: '{amount}'."); break; } }