Пример #1
0
        //*********************************************************************************************
        // DisconnectUser / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Desconectar o jogador.
        //*********************************************************************************************
        public static void disconnectUser(int clientid)
        {
            //EXTEND
            if (Extensions.ExtensionApp.extendMyApp
                    (MethodBase.GetCurrentMethod().Name, clientid) != null)
            {
                return;
            }

            //CÓDIGO
            //LOL
            if ((Clients.Count <= 0) || (clientid > Clients.Count - 1))
            {
                return;
            }
            //Se estiver morto, resetar posição
            //PlayerStruct.tempplayer[Clients[clientid].s].isDead = false;

            //Sai da troca
            if (PlayerStruct.tempplayer[Clients[clientid].s].InTrade > 0)
            {
                TradeRelations.giveTrade(Clients[clientid].s);
                TradeRelations.giveTrade(PlayerStruct.tempplayer[Clients[clientid].s].InTrade);

                //Verificar se o jogador não se desconectou no processo
                if (Clients[(UserConnection.getS(PlayerStruct.tempplayer[Clients[clientid].s].InTrade))].IsConnected)
                {
                    SendData.sendPlayerG(PlayerStruct.tempplayer[Clients[clientid].s].InTrade);
                    SendData.sendTradeClose(PlayerStruct.tempplayer[Clients[clientid].s].InTrade);
                    SendData.sendInvSlots(PlayerStruct.tempplayer[Clients[clientid].s].InTrade, PlayerStruct.player[PlayerStruct.tempplayer[Clients[clientid].s].InTrade].SelectedChar);
                }

                TradeRelations.clearTempTrade(PlayerStruct.tempplayer[Clients[clientid].s].InTrade);
                TradeRelations.clearTempTrade(Clients[clientid].s);
            }

            //Sai do Craft
            if (PlayerStruct.tempplayer[Clients[clientid].s].InCraft)
            {
                for (int i = 1; i < Globals.Max_Craft; i++)
                {
                    if (PlayerStruct.craft[Clients[clientid].s, i].num > 0)
                    {
                        InventoryRelations.giveItem(Clients[clientid].s, PlayerStruct.craft[Clients[clientid].s, i].type, PlayerStruct.craft[Clients[clientid].s, i].num, PlayerStruct.craft[Clients[clientid].s, i].value, PlayerStruct.craft[Clients[clientid].s, i].refin, PlayerStruct.craft[Clients[clientid].s, i].exp);
                    }
                }
            }

            //Salva o jogador SE PRECISAR
            if (PlayerStruct.tempplayer[Clients[clientid].s].ingame)
            {
                Database.Characters.saveCharacter(Clients[clientid].s, PlayerStruct.player[Clients[clientid].s].Email, PlayerStruct.player[Clients[clientid].s].SelectedChar);
                Database.Banks.saveBank(Clients[clientid].s);
                Database.FriendLists.saveFriendList(Clients[clientid].s);
            }

            //Sai do grupo
            if (PlayerStruct.tempplayer[Clients[clientid].s].Party > 0)
            {
                PartyRelations.kickParty(Clients[clientid].s, Clients[clientid].s, true);
            }

            //Vamos avisar ao mapa que o jogador saiu
            SendData.sendPlayerLeft(PlayerStruct.character[Clients[clientid].s, PlayerStruct.player[Clients[clientid].s].SelectedChar].Map, Clients[clientid].s);

            //Apagamos o banco
            Database.Banks.clearBank(Clients[clientid].s);

            Console.WriteLine(lang.player_cleared + " " + clientid + Clients[clientid].s);

            //Fecha a conexão
            Clients[clientid].Async.Close();

            //Limpa dados sobre o jogador
            Clients[clientid].Async = null;

            //Limpa dados temporários sobre o jogador
            PlayerStruct.clearPlayer(Clients[clientid].s, true);
            PlayerStruct.clearTempPlayer(Clients[clientid].s);

            //Limpa informações gerais da conexão
            Clients[clientid].s = -1;

            //Remova da lista de clientes do servidor
            Clients.RemoveAt(clientid);

            //Zerar o Player_Highs pra evitar problemas
            Globals.Player_Highs = 0;

            //Vamos atualizar o Player_Highs sem frescura
            for (int i = 0; i < WinsockAsync.Clients.Count(); i++)
            {
                if (Clients[i].s > Globals.Player_Highs)
                {
                    Globals.Player_Highs = Clients[i].s;
                }
            }

            //Vamos atualizar o Player_Highs para todos os jogadores
            SendData.sendUpdatePlayerHighs();

            Log(lang.player_disconnected + " " + clientid);
        }
Пример #2
0
        //*********************************************************************************************
        // Main / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Iniciamos o servidor aqui.
        //*********************************************************************************************
        static void Main(string[] args)
        {
            loadLang();
            Console.WriteLine("");
            Console.WriteLine("///////////////////////////////////////////////////////");
            Console.WriteLine("/                                                     /");
            Console.WriteLine(@"/        ___          _                               /");
            Console.WriteLine(@"/       / __\__  _ __(_) ___ _ __ _   _ _ __ ___      /");
            Console.WriteLine(@"/      / _\/ _ \| '__| |/ _ \ '__| | | | '_ ` _ \     /");
            Console.WriteLine(@"/     / / | (_) | |  | |  __/ |  | |_| | | | | | |    /");
            Console.WriteLine(@"/     \/   \___/|_| _/ |\___|_|   \__,_|_| |_| |_|    /");
            Console.WriteLine(@"/                  |__/                               /");
            Console.WriteLine("/                                                     /");
            Console.WriteLine("/                 http://4tabern.com                  /");
            Console.WriteLine("/         Copyright (C) 2016 Allyson S. Bacon         /");
            Console.WriteLine("/                                                     /");
            Console.WriteLine("///////////////////////////////////////////////////////");

            Console.WriteLine("");
            Console.WriteLine(lang.making_the_query_extensions_in_project);
            Extensions.ExtensionApp.instanceTypes();

            //EXTEND
            if (Extensions.ExtensionApp.extendMyApp
                    (MethodBase.GetCurrentMethod().Name, args) != null)
            {
                return;
            }

            //CÓDIGO PARA RESETAR JOGADORES
            //PlayerStruct.InitializePlayerArrays();
            //Database.ResetAndGiveExp();

            Log(Languages.LStruct.lang.starting_server);
            Log(lang.setting_global_names);
            Globals.GAME_NAME = Database.Handler.getGameName();
            Globals.MOTD      = Database.Handler.getMOTD();
            Globals.NOTICE    = Database.Handler.getNotice();
            Log(lang.starting_server);
            Log(lang.client_defined);
            Log("");
            Log(lang.starting_player_arrays);
            PlayerStruct.initializePlayerArrays();
            Log(lang.starting_guild_arrays);
            GuildStruct.initializeGuildArrays();
            Log(lang.arrays_started);
            Log("");
            Log(lang.loading_enemies);
            Database.Enemies.loadEnemies();
            Log(lang.loaded);
            Log(lang.loading_maps_monsters_and_missions);
            Database.Maps.loadAll();
            Log(lang.loaded);
            Log(lang.loading_items);
            Database.Items.loadItems();
            Log(lang.loaded);
            Log(lang.loading_weapons);
            Database.Weapons.loadWeapons();
            Log(lang.loaded);
            Log(lang.loading_armors);
            Database.Armors.loadArmors();
            Log(lang.loaded);
            Log(lang.loading_skills);
            Database.Skills.loadSkills();
            Log(lang.loaded);
            Log(lang.loading_shops);
            Database.Shops.loadShops();
            //Rudimentar :/
            Database.Manual.loadShopsRud();
            Log(lang.loaded);
            Log(lang.loading_recipes);
            Database.Manual.loadRecipes();
            Log(lang.loaded);
            Log(lang.loading_guilds);
            Database.Guilds.loadGuilds();
            Log(lang.loaded);
            Log(lang.loading_classes);
            Database.Handler.defineClassesData();
            Log(lang.loaded);
            Log("");
            Log(lang.setting_variables);
            rdn = new Random();
            Log(lang.OK);
            Log("");
            Log(lang.starting_server_loop);
            Log(lang.starting_tcpip_connection);

            WinsockAsync.start();
        }