Distribute Attributes Command

02/04/2010 06:06 CIRASH#1
I'm using the 4267 CoFuture source and am trying to code some simple commands. I made this command to distribute dexterity attributes but when i try it, the console gives an error saying the index was outside the bounds od the array.

Heres my code.
Code:
                    if (Splitter[0] == "/dex")
                    {
                        if (Client.Char.StatPoints >= Convert.ToUInt16(Splitter[2]))
                        {
                            Client.Char.StatPoints -= Convert.ToUInt16(Splitter[2]);
                            Client.Char.Dexterity = Convert.ToUInt16(Splitter[2]);
                            Client.SendData(ConquerPacket.Status(Client, Client.Char.Dexterity, Struct.StatusTypes.DexterityStatPoints));
                            Client.SendData(ConquerPacket.Status(Client, Client.Char.StatPoints, Struct.StatusTypes.AttributePoints));
                        }
                    }
Any help or feedback is appreciated.
02/04/2010 06:42 spare2#2
Quote:
Originally Posted by CIRASH View Post
I'm using the 4267 CoFuture source and am trying to code some simple commands. I made this command to distribute dexterity attributes but when i try it, the console gives an error saying the index was outside the bounds od the array.

Heres my code.
Code:
                    if (Splitter[0] == "/dex")
                    {
                        if (Client.Char.StatPoints >= Convert.ToUInt16(Splitter[2]))
                        {
                            Client.Char.StatPoints -= Convert.ToUInt16(Splitter[2]);
                            Client.Char.Dexterity = Convert.ToUInt16(Splitter[2]);
                            Client.SendData(ConquerPacket.Status(Client, Client.Char.Dexterity, Struct.StatusTypes.DexterityStatPoints));
                            Client.SendData(ConquerPacket.Status(Client, Client.Char.StatPoints, Struct.StatusTypes.AttributePoints));
                        }
                    }
Any help or feedback is appreciated.
Should be
Code:
                    if (Splitter[0] == "/dex")
                    {
                        if (Client.Char.StatPoints >= Convert.ToUInt16(Splitter[1]))
                        {
                            Client.Char.StatPoints -= Convert.ToUInt16(Splitter[1]);
                            Client.Char.Dexterity = Convert.ToUInt16(Splitter[1]);
                            Client.SendData(ConquerPacket.Status(Client, Client.Char.Dexterity, Struct.StatusTypes.DexterityStatPoints));
                            Client.SendData(ConquerPacket.Status(Client, Client.Char.StatPoints, Struct.StatusTypes.AttributePoints));
                        }
                    }
02/04/2010 06:55 CIRASH#3
Wow, such a simple problem haha. Thanks Spare
#request close
02/04/2010 07:15 pro4never#4
Yah, always remember that [0] is the initial command, they don't start with 1.

It's even more fun when you're selecting ranges of stuff and trying to figure out why it's not grabbing the right data... then you realize you were counting them up wrong :P
02/04/2010 08:05 CIRASH#5
I'm converting your met/db bank for 1.0 now xD
02/04/2010 08:17 pro4never#6
Ahaha... that's funny because I converted my metbank FROM 1.0.

here's the original code (no met/db scroll functionality cause I didn't have a itemtype editor to add them)



database voids

PHP Code:
public static void SaveMetPoint(Character Char)
        {
            
lock (DatabaseConnection)
            {
                
MySqlCommand Comm = new MySqlCommand("UPDATE `characters` SET `MetPoint` = " Char.MetPoint " WHERE `CharID` = " Char.ID ""DatabaseConnection);
           
            }
            
        }
        public static 
void SaveDbPoint(Character Char)
        {
            
lock (DatabaseConnection)
            {
                
MySqlCommand Comm = new MySqlCommand("UPDATE `characters` SET `DbPoint` = " Char.DbPoint " WHERE `CharID` = " Char.ID ""DatabaseConnection);

            }

        } 
Not sure if you need these but w/e

here's the voids, most should be in source already though


Enjoy.
02/04/2010 08:49 CIRASH#7
Thanks. Saved me quite some time. Testing now.
02/04/2010 09:00 pro4never#8
You might wanna remove some of the console.writeline's. I had them in there when I was first writing it for debug purposes... it's kinda a messy release but it should work.
02/06/2010 01:13 CIRASH#9
Hmm, wont save after logoff even though i added it for saving and loading character.