Exemple #1
0
        public static int AddOrUpdateCharacter(
            ClientConnection pConnection, int pID, string pName, int pUserID, byte pWorldID, byte pChannelID, byte pLevel,
            short pJob, short pStr, short pDex, short pInt, short pLuk,
            int pHP, int pMaxHP, int pMP, int pMaxMP, short pAP, short pSP,
            long pEXP, int pFame, int pMap, byte pMapPos,
            int pHonourLevel, int pHonourEXP, long pMesos, int pDemonMark,
            byte pGender, byte pSkin,
            int pEyes, int pHair,

            byte[] pSlots, string pBoF, string pBoE, string pUE,
            long[] pPetIDs, int[] pTraits,
            string pMarriedWith
            )
        {
            CharacterCacheInfo cci = AccountDataCache.Instance.GetCharInfoByIDAndWorldID(pID, pWorldID);

            if (cci != null)
            {
                int internal_id = cci.InternalID;
                using (UpdateQueryBuilder query = new UpdateQueryBuilder("characters"))
                {
                    query.SetColumn("name", pName);
                    query.SetColumn("userid", pUserID);
                    query.SetColumn("world_id", pWorldID);
                    query.SetColumn("channel_id", pChannelID);
                    query.SetColumn("level", pLevel);
                    query.SetColumn("job", pJob);
                    query.SetColumn("str", pStr);
                    query.SetColumn("dex", pDex);
                    query.SetColumn("int", pInt);
                    query.SetColumn("luk", pLuk);
                    query.SetColumn("chp", pHP);
                    query.SetColumn("mhp", pMaxHP);
                    query.SetColumn("cmp", pMP);
                    query.SetColumn("mmp", pMaxMP);
                    query.SetColumn("ap", pAP);
                    query.SetColumn("sp", pSP);
                    query.SetColumn("exp", pEXP);
                    query.SetColumn("fame", pFame);
                    query.SetColumn("map", pMap);
                    query.SetColumn("pos", pMapPos);
                    query.SetColumn("gender", pGender);
                    query.SetColumn("skin", pSkin);
                    query.SetColumn("eyes", pEyes);
                    query.SetColumn("hair", pHair);
                    query.SetColumn("last_update", MySQL_Connection.NOW);

                    query.SetColumn("honourlevel", pHonourLevel);
                    query.SetColumn("honourexp", pHonourEXP);
                    query.SetColumn("mesos", pMesos);
                    query.SetColumn("demonmark", pDemonMark);

                    query.SetColumn("eqp_slots", pSlots[0]);
                    query.SetColumn("use_slots", pSlots[1]);
                    query.SetColumn("setup_slots", pSlots[2]);
                    query.SetColumn("etc_slots", pSlots[3]);
                    query.SetColumn("cash_slots", pSlots[4]);

                    query.SetColumn("blessingoffairy", pBoF);
                    query.SetColumn("blessingofempress", pBoE);
                    query.SetColumn("ultimateexplorer", pUE);

                    query.SetColumn("petcashid1", pPetIDs[0]);
                    query.SetColumn("petcashid2", pPetIDs[1]);
                    query.SetColumn("petcashid3", pPetIDs[2]);

                    query.SetColumn("trait_charisma", pTraits[0]);
                    query.SetColumn("trait_insight", pTraits[1]);
                    query.SetColumn("trait_willpower", pTraits[2]);
                    query.SetColumn("trait_craft_dili", pTraits[3]);
                    query.SetColumn("trait_empathy", pTraits[4]);
                    query.SetColumn("trait_charm", pTraits[5]);

                    query.SetColumn("married_with", pMarriedWith);

                    query.SetWhereColumn("internal_id", internal_id);

                    int result = query.RunQuery("sql_addorupdate.sql");

                    if (result >= 1)
                    {
                        //pConnection.Logger_WriteLine("Updated character info: {0}", internal_id);
                        return(cci.InternalID);
                    }
                    else
                    {
                        pConnection.Logger_WriteLine("Failed to update character info: " + query.ToString());
                    }
                }
            }
            else
            {
                using (InsertQueryBuilder query = new InsertQueryBuilder("characters"))
                {
                    query.OnDuplicateUpdate = false;
                    query.AddColumnWithValue("internal_id", null);

                    query.AddColumnWithValue("id", pID, false);
                    query.AddColumnWithValue("name", pName);
                    query.AddColumnWithValue("userid", pUserID);
                    query.AddColumnWithValue("world_id", pWorldID);
                    query.AddColumnWithValue("channel_id", pChannelID);
                    query.AddColumnWithValue("level", pLevel);
                    query.AddColumnWithValue("job", pJob);
                    query.AddColumnWithValue("str", pStr);
                    query.AddColumnWithValue("dex", pDex);
                    query.AddColumnWithValue("int", pInt);
                    query.AddColumnWithValue("luk", pLuk);
                    query.AddColumnWithValue("chp", pHP);
                    query.AddColumnWithValue("mhp", pMaxHP);
                    query.AddColumnWithValue("cmp", pMP);
                    query.AddColumnWithValue("mmp", pMaxMP);
                    query.AddColumnWithValue("ap", pAP);
                    query.AddColumnWithValue("sp", pSP);
                    query.AddColumnWithValue("exp", pEXP);
                    query.AddColumnWithValue("fame", pFame);
                    query.AddColumnWithValue("map", pMap);
                    query.AddColumnWithValue("pos", pMapPos);
                    query.AddColumnWithValue("gender", pGender);
                    query.AddColumnWithValue("skin", pSkin);
                    query.AddColumnWithValue("eyes", pEyes);
                    query.AddColumnWithValue("hair", pHair);
                    query.AddColumnWithValue("last_update", MySQL_Connection.NOW);

                    query.AddColumnWithValue("honourlevel", pHonourLevel);
                    query.AddColumnWithValue("honourexp", pHonourEXP);
                    query.AddColumnWithValue("mesos", pMesos);
                    query.AddColumnWithValue("demonmark", pDemonMark);

                    query.AddColumnWithValue("eqp_slots", pSlots[0]);
                    query.AddColumnWithValue("use_slots", pSlots[1]);
                    query.AddColumnWithValue("setup_slots", pSlots[2]);
                    query.AddColumnWithValue("etc_slots", pSlots[3]);
                    query.AddColumnWithValue("cash_slots", pSlots[4]);

                    query.AddColumnWithValue("blessingoffairy", pBoF);
                    query.AddColumnWithValue("blessingofempress", pBoE);
                    query.AddColumnWithValue("ultimateexplorer", pUE);


                    query.AddColumnWithValue("petcashid1", pPetIDs[0]);
                    query.AddColumnWithValue("petcashid2", pPetIDs[1]);
                    query.AddColumnWithValue("petcashid3", pPetIDs[2]);

                    query.AddColumnWithValue("trait_charisma", pTraits[0]);
                    query.AddColumnWithValue("trait_insight", pTraits[1]);
                    query.AddColumnWithValue("trait_willpower", pTraits[2]);
                    query.AddColumnWithValue("trait_craft_dili", pTraits[3]);
                    query.AddColumnWithValue("trait_empathy", pTraits[4]);
                    query.AddColumnWithValue("trait_charm", pTraits[5]);

                    query.AddColumnWithValue("married_with", pMarriedWith);

                    string q = query.ToString();

                    System.IO.File.WriteAllText("sql_addorupdate_insert.sql", q);

                    int result = (int)MySQL_Connection.Instance.RunQuery(q);

                    if (result >= 1)
                    {
                        int internalid = MySQL_Connection.Instance.GetLastInsertId();
                        pConnection.Logger_WriteLine("Inserted character info: {0}", internalid);
                        return(internalid);
                    }
                    else
                    {
                        pConnection.Logger_WriteLine("Failed to insert character info: " + q);
                    }
                }
            }

            Logger.WriteLine("ERROR WHILE ADDING OR UPDATING CHARACTER");

            return(-1);
        }
Exemple #2
0
        public static int AddOrUpdateCharacter(
            ClientConnection pConnection, int pID, string pName, int pUserID, byte pWorldID, byte pChannelID, byte pLevel,
            short pJob, short pStr, short pDex, short pInt, short pLuk,
            int pHP, int pMaxHP, int pMP, int pMaxMP, short pAP, short pSP,
            long pEXP, int pFame, int pMap, byte pMapPos,
            int pHonourLevel, int pHonourEXP, long pMesos, int pDemonMark,
            byte pGender, byte pSkin,
            int pEyes, int pHair,

            byte[] pSlots, string pBoF, string pBoE, string pUE,
            long[] pPetIDs, int[] pTraits,
            string pMarriedWith
            )
        {
            CharacterCacheInfo cci = AccountDataCache.Instance.GetCharInfoByIDAndWorldID(pID, pWorldID);
            if (cci != null)
            {
                int internal_id = cci.InternalID;
                using (UpdateQueryBuilder query = new UpdateQueryBuilder("characters"))
                {
                    query.SetColumn("name", pName);
                    query.SetColumn("userid", pUserID);
                    query.SetColumn("world_id", pWorldID);
                    query.SetColumn("channel_id", pChannelID);
                    query.SetColumn("level", pLevel);
                    query.SetColumn("job", pJob);
                    query.SetColumn("str", pStr);
                    query.SetColumn("dex", pDex);
                    query.SetColumn("int", pInt);
                    query.SetColumn("luk", pLuk);
                    query.SetColumn("chp", pHP);
                    query.SetColumn("mhp", pMaxHP);
                    query.SetColumn("cmp", pMP);
                    query.SetColumn("mmp", pMaxMP);
                    query.SetColumn("ap", pAP);
                    query.SetColumn("sp", pSP);
                    query.SetColumn("exp", pEXP);
                    query.SetColumn("fame", pFame);
                    query.SetColumn("map", pMap);
                    query.SetColumn("pos", pMapPos);
                    query.SetColumn("gender", pGender);
                    query.SetColumn("skin", pSkin);
                    query.SetColumn("eyes", pEyes);
                    query.SetColumn("hair", pHair);
                    query.SetColumn("last_update", MySQL_Connection.NOW);

                    query.SetColumn("honourlevel", pHonourLevel);
                    query.SetColumn("honourexp", pHonourEXP);
                    query.SetColumn("mesos", pMesos);
                    query.SetColumn("demonmark", pDemonMark);

                    query.SetColumn("eqp_slots", pSlots[0]);
                    query.SetColumn("use_slots", pSlots[1]);
                    query.SetColumn("setup_slots", pSlots[2]);
                    query.SetColumn("etc_slots", pSlots[3]);
                    query.SetColumn("cash_slots", pSlots[4]);

                    query.SetColumn("blessingoffairy", pBoF);
                    query.SetColumn("blessingofempress", pBoE);
                    query.SetColumn("ultimateexplorer", pUE);

                    query.SetColumn("petcashid1", pPetIDs[0]);
                    query.SetColumn("petcashid2", pPetIDs[1]);
                    query.SetColumn("petcashid3", pPetIDs[2]);

                    query.SetColumn("trait_charisma", pTraits[0]);
                    query.SetColumn("trait_insight", pTraits[1]);
                    query.SetColumn("trait_willpower", pTraits[2]);
                    query.SetColumn("trait_craft_dili", pTraits[3]);
                    query.SetColumn("trait_empathy", pTraits[4]);
                    query.SetColumn("trait_charm", pTraits[5]);

                    query.SetColumn("married_with", pMarriedWith);

                    query.SetWhereColumn("internal_id", internal_id);

                    int result = query.RunQuery("sql_addorupdate.sql");

                    if (result >= 1)
                    {
                        //pConnection.Logger_WriteLine("Updated character info: {0}", internal_id);
                        return cci.InternalID;
                    }
                    else
                    {
                        pConnection.Logger_WriteLine("Failed to update character info: " + query.ToString());
                    }
                }
            }
            else
            {
                using (InsertQueryBuilder query = new InsertQueryBuilder("characters"))
                {
                    query.OnDuplicateUpdate = false;
                    query.AddColumnWithValue("internal_id", null);

                    query.AddColumnWithValue("id", pID, false);
                    query.AddColumnWithValue("name", pName);
                    query.AddColumnWithValue("userid", pUserID);
                    query.AddColumnWithValue("world_id", pWorldID);
                    query.AddColumnWithValue("channel_id", pChannelID);
                    query.AddColumnWithValue("level", pLevel);
                    query.AddColumnWithValue("job", pJob);
                    query.AddColumnWithValue("str", pStr);
                    query.AddColumnWithValue("dex", pDex);
                    query.AddColumnWithValue("int", pInt);
                    query.AddColumnWithValue("luk", pLuk);
                    query.AddColumnWithValue("chp", pHP);
                    query.AddColumnWithValue("mhp", pMaxHP);
                    query.AddColumnWithValue("cmp", pMP);
                    query.AddColumnWithValue("mmp", pMaxMP);
                    query.AddColumnWithValue("ap", pAP);
                    query.AddColumnWithValue("sp", pSP);
                    query.AddColumnWithValue("exp", pEXP);
                    query.AddColumnWithValue("fame", pFame);
                    query.AddColumnWithValue("map", pMap);
                    query.AddColumnWithValue("pos", pMapPos);
                    query.AddColumnWithValue("gender", pGender);
                    query.AddColumnWithValue("skin", pSkin);
                    query.AddColumnWithValue("eyes", pEyes);
                    query.AddColumnWithValue("hair", pHair);
                    query.AddColumnWithValue("last_update", MySQL_Connection.NOW);

                    query.AddColumnWithValue("honourlevel", pHonourLevel);
                    query.AddColumnWithValue("honourexp", pHonourEXP);
                    query.AddColumnWithValue("mesos", pMesos);
                    query.AddColumnWithValue("demonmark", pDemonMark);

                    query.AddColumnWithValue("eqp_slots", pSlots[0]);
                    query.AddColumnWithValue("use_slots", pSlots[1]);
                    query.AddColumnWithValue("setup_slots", pSlots[2]);
                    query.AddColumnWithValue("etc_slots", pSlots[3]);
                    query.AddColumnWithValue("cash_slots", pSlots[4]);

                    query.AddColumnWithValue("blessingoffairy", pBoF);
                    query.AddColumnWithValue("blessingofempress", pBoE);
                    query.AddColumnWithValue("ultimateexplorer", pUE);


                    query.AddColumnWithValue("petcashid1", pPetIDs[0]);
                    query.AddColumnWithValue("petcashid2", pPetIDs[1]);
                    query.AddColumnWithValue("petcashid3", pPetIDs[2]);

                    query.AddColumnWithValue("trait_charisma", pTraits[0]);
                    query.AddColumnWithValue("trait_insight", pTraits[1]);
                    query.AddColumnWithValue("trait_willpower", pTraits[2]);
                    query.AddColumnWithValue("trait_craft_dili", pTraits[3]);
                    query.AddColumnWithValue("trait_empathy", pTraits[4]);
                    query.AddColumnWithValue("trait_charm", pTraits[5]);

                    query.AddColumnWithValue("married_with", pMarriedWith);

                    string q = query.ToString();

                    System.IO.File.WriteAllText("sql_addorupdate_insert.sql", q);

                    int result = (int)MySQL_Connection.Instance.RunQuery(q);

                    if (result >= 1)
                    {
                        int internalid = MySQL_Connection.Instance.GetLastInsertId();
                        pConnection.Logger_WriteLine("Inserted character info: {0}", internalid);
                        return internalid;
                    }
                    else
                    {
                        pConnection.Logger_WriteLine("Failed to insert character info: " + q);
                    }
                }
            }

            Logger.WriteLine("ERROR WHILE ADDING OR UPDATING CHARACTER");

            return -1;
        }