Cps Save // Why my code don't work?

08/08/2009 17:39 leandrorocha#1
Hello, I have some questions, I know that this forum has many people who can help, I hope the same please help me.

-----------------------------------------------------------------------

Q.1.: That's work for CoEmu? Because here don't work:
PS: This code is in database.cs above it has: public static class Database {
Code:
        public static void SaveConquerPoints(Character Client)
        {
            MySqlCommand Command = new MySqlCommand("UPDATE `characters` SET `CPoint` = " + Client.CPs + " WHERE `CharID` = " + Client.ID, DatabaseConnection.NewConnection());
            Command.ExecuteNonQuery();
            Command.Connection.Close();
            Command.Connection.Dispose();
        }
-----------------------------------------------------------------------

Q.2.:Okay, this code will certainly seem ridiculous, but I can say, "I tried!" In several ways, but here I am asking for help.
All help is welcome:
PS: This code is in useitem.cs above it has: case 1002040://Stancher{

Code:
case 723583:
                    {
                        if (CSocket.Client.Model == 11004)
                        {
                            int Model = 11004;
                            Model -= 1;
                        }
                        if (CSocket.Client.Model == 11003)
                        {
                            int Model = 11003;
                            Model += 1;
                        }
                        break;
                    }
I tried this too:
Code:
                        if (CSocket.Client.Model == 11003)
                        {
                            CSocket.Client.Model == 11004;
                        }
-----------------------------------------------------------------------

Q.3.:Realloter NPC ... This code was for LOFT, but I want to put CoEmu.
MyChar there, in place of what should I use?
Sample:
Code:
MyChar.Str = 0;
Here's SendPacket and MyChar:
Code:
SendPacket(General.MyPackets.Vital((long)MyChar.UID, 16, MyChar.Str));
Currently my code is like this:
Code:
case 350050:
                    {
                        if (LinkBack == 0){
                            Text("*Reborn level 70+ players can redistribute their attribute points at the cost of a dragonball.", CSocket);
                            Link("I will reallot my points.", 1, CSocket);
                            Link("let me think it over.", 255, CSocket);
                        if (LinkBack == 1)
                                {
                                    if (CSocket.Client.Reborn >= 1)
                                    {
                                        if (CSocket.Client.Inventory.ContainsKey(1088000))
                                        {
                                            CSocket.Client.Inventory.Remove(1088000);

                                            uint Points = 0;

                                            Points += CSocket.Client.Str;
                                            Points += CSocket.Client.Spi;
                                            Points += CSocket.Client.Agi;
                                            Points += CSocket.Client.vit;

                                            CSocket.Client.StatPoints += (ushort)Points;

                                            MyChar.Str = 0;
                                            MyChar.Spi = 0;
                                            MyChar.Agi = 0;
                                            MyChar.Vit = 0;

                                            SendPacket(General.MyPackets.Vital((long)MyChar.UID, 16, MyChar.Str));
                                            SendPacket(General.MyPackets.Vital((long)MyChar.UID, 17, MyChar.Agi));
                                            SendPacket(General.MyPackets.Vital((long)MyChar.UID, 15, MyChar.Vit));
                                            SendPacket(General.MyPackets.Vital((long)MyChar.UID, 14, MyChar.Spi));
                                            SendPacket(General.MyPackets.Vital((long)MyChar.UID, 5, (ulong)MyChar.Exp));
                                            SendPacket(General.MyPackets.Vital((long)MyChar.UID, 2, MyChar.MaxMana()));
                                            SendPacket(General.MyPackets.GeneralData((long)MyChar.UID, 0, 0, 0, 92));
                                            SendPacket(General.MyPackets.Vital((long)MyChar.UID, 0, MyChar.CurHP));
                                            SendPacket(General.MyPackets.Vital(MyChar.UID, 11, MyChar.StatP));

                                            MyChar.SaveStatPoints();
                                            MyChar.Save();
                                            SendPacket(General.MyPackets.NPCSay("You cannot reallot your stats manually, Please use the /allot command."));
                                            SendPacket(General.MyPackets.NPCSay(" Command Breakdown: /allot [vit, str, agi, spi] [Amount to ADD to the Stat]"));
                                            SendPacket(General.MyPackets.NPCLink("I see, Thanks.", 255));
                                            SendPacket(General.MyPackets.NPCSetFace(30));
                                            SendPacket(General.MyPackets.NPCFinish());
                                        }
                                        else
                                        {
                                            SendPacket(General.MyPackets.NPCSay("You don't have a Dragonball."));
                                            SendPacket(General.MyPackets.NPCLink("I see.", 255));
                                            SendPacket(General.MyPackets.NPCSetFace(30));
                                            SendPacket(General.MyPackets.NPCFinish());
                                        }
                                    }
                                    else
                                    {
                                        SendPacket(General.MyPackets.NPCSay("You cannot reallot your attribute points if you aren't reborn."));
                                        SendPacket(General.MyPackets.NPCLink("I see.", 255));
                                        SendPacket(General.MyPackets.NPCSetFace(30));
                                        SendPacket(General.MyPackets.NPCFinish());
                                    }
                                }
                            }
                        break;
                    }
PS: This code is in npctalk.cs

-----------------------------------------------------------------------

I hope to get help here, and sorry for my English, thanks;
08/08/2009 17:57 12tails#2
lol.... only put this at SaveCharacter

Code:
        public static void SaveCharacter(Character Client)
        {
            MySqlCommand Cmd = new MySqlCommand("UPDATE `characters` SET `Level` = " + Client.Level + ", `WHMoney` = " + Client.WHMoney + ", `PkPoints` = " + Client.PkPoints + ", `xCord` = " + Client.X + ", `yCord` = " + Client.Y + ", `Map` = " + (int)Client.Map + ", `HairStyle` = " + Client.Hair + ", `Class` = " + (int)Client.Class + ", `Exp` = " + Client.Exp + ", `Money` = " + Client.Money + ", `CPoints` = " + Client.CPs + ", `Str` = " + Client.Strength + ",`Vit` = " + Client.Vitality + ", `Spi` = " + Client.Spirit + ", `Dex` = " + Client.Dexterity + ", `StatPoints` = " + Client.StatPoints + ", `FirstLog` = " + 1 + ", `Reborn` = " + Client.Reborn + ", `HP` = " + Client.CurrentHP + ", `MP` = " + Client.CurrentMP + " WHERE `CharID` = " + Client.ID, DatabaseConnection.NewConnection());
            Cmd.ExecuteNonQuery();
            Cmd.Connection.Close();
            Cmd.Connection.Dispose();
            Cmd.Dispose();
        }
EDIT:
Fixed realloter NPC... and works!!


NpcTalk.cs:
Code:
                    case 350050:// Reallot Stats
                    {
                        if (LinkBack == 0)
                        {
                            Text("Reborn players who are level 70 or higher can redistribute their attribute points at the cost of a Dragonball.", CSocket);
                            Link("I will reallot my points.", 1, CSocket);
                            Link("Let me think it over.", 225, CSocket);
                            End(CSocket);

                        }
                        else if (LinkBack == 1)
                        {
                            if (CSocket.Client.Level >= 70)
                            {
                                if (CSocket.Client.Reborn >= 1)
                                {
                                    int uid = 0;
                                    bool cont = false;

                                    foreach (Struct.ItemInfo Item in CSocket.Client.Inventory.Values)
                                    {
                                        if (Item.ItemID == 1088000)
                                        {
                                            uid = Item.UID;
                                            cont = true;
                                            break;
                                        }
                                    }

                                    if (cont)
                                    {
                                        CSocket.Client.Inventory.Remove(uid);
                                        CSocket.Send(ConquerPacket.ItemUsage(uid, 255, Struct.ItemUsage.RemoveItem));
                                        Database.Database.DeleteItem(uid);
                                        while (!CSocket.Send(ConquerPacket.ItemUsage(uid, 255, Struct.ItemUsage.RemoveItem)))
                                        {
                                            CSocket.Client.Inventory.Remove(uid);
                                            CSocket.Send(ConquerPacket.ItemUsage(uid, 255, Struct.ItemUsage.RemoveItem));
                                            Database.Database.DeleteItem(uid);
                                        }

                                        CSocket.Client.StatPoints += CSocket.Client.Strength;
                                        CSocket.Client.StatPoints += CSocket.Client.Spirit;
                                        CSocket.Client.StatPoints += CSocket.Client.Dexterity;
                                        CSocket.Client.StatPoints += CSocket.Client.Vitality;

                                        CSocket.Client.Strength = 0;
                                        CSocket.Client.Dexterity = 0;
                                        CSocket.Client.Vitality = 0;
                                        CSocket.Client.Spirit = 0;

                                        CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Dexterity, Struct.StatusTypes.DexterityStatPoints));
                                        CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Spirit, Struct.StatusTypes.ManaStatPoints));
                                        CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Vitality, Struct.StatusTypes.VitalityStatPoints));
                                        CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Strength, Struct.StatusTypes.StrengthStatPoints));
CSocket.Disconnect();
                                    }
                                    else
                                    {
                                        Text("You do not have a DragonBall.", CSocket);
                                        Link("I see.", 225, CSocket);
                                        End(CSocket);
                                    }
                                }
                                else
                                {
                                    Text("You cannot reallot your attribute points if you aren't reborn.", CSocket);
                                    Link("I see.", 225, CSocket);
                                    End(CSocket);
                                }
                            }
                            else
                            {
                                Text("You do not have the level.", CSocket);
                                Link("I see.", 225, CSocket);
                                End(CSocket);
                            }
                        }
                        break;
                    }