Ejemplo n.º 1
0
        private static void AttributeAction(WorldClient client, StartupActionRecord action, long characterId)
        {
            if (WorldServer.Instance.IsStatus(ServerStatusEnum.ONLINE))
            {
                try
                {
                    for (int i = 0; i < action.GIds.Count; i++)
                    {
                        ushort     gid      = action.GIds[i];
                        uint       quantity = action.Quantities[i];
                        ItemRecord item     = ItemRecord.GetItem(gid);

                        var character     = client.GetAccountCharacter(characterId);
                        var characterItem = item.GetCharacterItem(characterId, quantity, ITEM_GENERATION_PERFECT);

                        CharacterItemRecord.AddQuietCharacterItem(character, characterItem);
                    }

                    client.Send(new StartupActionFinishedMessage(true, false, action.Id));
                }
                catch (Exception ex)
                {
                    logger.Error("Unable to attribute action to " + client.Account.Username + " :" + ex);
                    client.Send(new StartupActionFinishedMessage(false, false, action.Id));
                }
                finally
                {
                    action.RemoveInstantElement(); // How, its dangerous!
                }
            }
            else
            {
                client.Disconnect();
            }
        }