示例#1
0
        //*********************************************************************************************
        // giveTradeTo
        // Entrega itens da troca para determinado jogador
        //*********************************************************************************************
        public static void giveTradeTo(int s, int intrade)
        {
            //EXTEND
            if (Extensions.ExtensionApp.extendMyApp
                    (MethodBase.GetCurrentMethod().Name, s, intrade) != null)
            {
                return;
            }

            //CÓDIGO
            if (PlayerStruct.tempplayer[s].TradeG > 0)
            {
                PlayerRelations.givePlayerGold(intrade, PlayerStruct.tempplayer[s].TradeG);
            }

            for (int i = 1; i < Globals.MaxTradeOffers; i++)
            {
                if ((PlayerStruct.tradeslot[s, i].item != Globals.NullItem) && (!String.IsNullOrEmpty(PlayerStruct.tradeslot[s, i].item)))
                {
                    string[] splititem = PlayerStruct.tradeslot[s, i].item.Split(',');

                    int itemNum   = Convert.ToInt32(splititem[1]);
                    int itemType  = Convert.ToInt32(splititem[0]);
                    int itemValue = Convert.ToInt32(splititem[2]);
                    int itemRefin = Convert.ToInt32(splititem[3]);
                    int itemExp   = Convert.ToInt32(splititem[4]);

                    InventoryRelations.giveItem(intrade, itemType, itemNum, itemValue, itemRefin, itemExp);

                    PlayerStruct.tradeslot[s, i].item = Globals.NullItem;
                }
            }
        }
示例#2
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);
        }
示例#3
0
        //*********************************************************************************************
        // playerAttackWorkPoint / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
        // Interação com objetos de profissão
        //*********************************************************************************************
        public static void playerAttackWorkPoint(int s, int workpoint)
        {
            //EXTEND
            if (Extensions.ExtensionApp.extendMyApp
                    (MethodBase.GetCurrentMethod().Name, s, workpoint) != null)
            {
                return;
            }

            //CÓDIGO
            if (MapStruct.tempworkpoint[workpoint].vitality <= 0)
            {
                SendData.sendMsgToPlayer(s, lang.resource_empty, Globals.ColorRed, Globals.Msg_Type_Server);
                return;
            }

            int damage  = 0;
            int profnum = 0;


            profnum = PlayerRelations.getPlayerProf(s, MapStruct.workpoint[workpoint].type);

            if (profnum <= 0)
            {
                SendData.sendMsgToPlayer(s, lang.dont_have_prof_to_explore, Globals.ColorRed, Globals.Msg_Type_Server);
                return;
            }

            if (!haveToolToWork(s, MapStruct.workpoint[workpoint].type))
            {
                SendData.sendMsgToPlayer(s, lang.dont_have_tool_to_interact, Globals.ColorRed, Globals.Msg_Type_Server);
                return;
            }

            damage = 1 + Convert.ToInt32(Convert.ToDouble(PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Prof_Level[profnum] * 0.5));
            SendData.sendAnimation(PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Map, Globals.Target_Player, s, WeaponStruct.weapon[28].animation_id);

            if (damage == 0)
            {
                damage = 1;
            }

            MapStruct.tempworkpoint[workpoint].vitality -= 1;
            SendData.sendActionMsg(s, "-" + damage, Globals.ColorWhite, MapStruct.workpoint[workpoint].x, MapStruct.workpoint[workpoint].y, 1, 0, MapStruct.workpoint[workpoint].map);

            if (MapStruct.tempworkpoint[workpoint].vitality <= 0)
            {
                InventoryRelations.giveItem(s, 1, MapStruct.workpoint[workpoint].reward, 1, 0, 0);
                MapStruct.tempworkpoint[workpoint].respawn = Loops.TickCount.ElapsedMilliseconds + (MapStruct.workpoint[workpoint].respawn_timer * 10000);
                PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Prof_Exp[profnum] += MapStruct.workpoint[workpoint].exp;
                //Verificamos se ele subiu de nível
                if ((PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Prof_Exp[profnum] >= LevelRelations.getpProfExpToNextLevel(s, profnum)) && (PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Prof_Level[profnum] < 80))
                {
                    PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Prof_Exp[profnum]   -= LevelRelations.getpProfExpToNextLevel(s, profnum);
                    PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Prof_Level[profnum] += 1;
                    SendData.sendProfLEVEL(s, profnum);
                }
                else
                {
                    //GetExpToNextLevel
                    SendData.sendProfEXP(s, profnum);
                    // SendData.sendPlayerExp(members);
                    //Enviamos uma animação bonitinha de exp :D
                    SendData.sendActionMsg(s, "+" + MapStruct.workpoint[workpoint].exp + lang.pexp, 0, PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].X, PlayerStruct.character[s, PlayerStruct.player[s].SelectedChar].Y, 1, 0, MapStruct.workpoint[workpoint].map);
                }
                SendData.sendEventGraphicToMap(MapStruct.workpoint[workpoint].map, MapStruct.tile[MapStruct.workpoint[workpoint].map, MapStruct.workpoint[workpoint].x, MapStruct.workpoint[workpoint].y].Event_Id, "", 0, 49);
                SendData.sendInvSlots(s, PlayerStruct.player[s].SelectedChar);
            }
        }