/// <summary> /// Handles an item drop request from a client /// </summary> static public void Handle_CS_PlayerDrop(CS_PlayerDrop pkt, Player player) { //Allow the player's arena to handle it if (player._arena == null) { Log.write(TLog.Error, "Player {0} sent update packet with no arena.", player); return; } if (player.IsSpectator) { Log.write(TLog.Warning, "Player {0} attempted to drop items from spec.", player); return; } if (player.IsDead) { Log.write(TLog.Warning, "Player {0} attempted to drop items while dead.", player); return; } player._arena.handleEvent(delegate(Arena arena) { player._arena.handlePlayerDrop(player, pkt); } ); }
/// <summary> /// Triggered when a player requests to drop an item /// </summary> public void handlePlayerDrop(Player from, CS_PlayerDrop update) { //Get the item into ItemInfo item = _server._assets.getItemByID(update.itemID); if (item == null) { Log.write(TLog.Warning, "Player requested to drop invalid item. {0}", from); return; } //Perform some sanity checks if (!item.droppable) { return; } if (!Helpers.isInRange(100, from._state.positionX, from._state.positionY, update.positionX, update.positionY)) { return; } //Update his inventory if (from.inventoryModify(item, -update.quantity)) { //Create an item spawn itemSpawn(item, update.quantity, update.positionX, update.positionY); } }
/// <summary> /// Triggered when a player requests to drop an item /// </summary> public virtual void handlePlayerDrop(Player from, CS_PlayerDrop update) { }