Top Rank Problems!

08/30/2010 23:43 jackpotsvr#1
--->IM USING LOTF 5017<---
NOTE** THIS IS NOT A RELEASE**<---

After following the [Only registered and activated users can see links. Click Here To Register...] of MaryJuana about how to add top rank in your source i was thinking about to make it more advanced so others can see it and you don't have to use the command every time you relog. Now i've coded alot and after hours of work and i finally had a succesfull build, my char was invisible. Only the chars who had the top rank in my database. Now i'll show some of scripts and tell you in where i add them.


Client.cs under Public void SaveRank()
Code:
public void Savetoprank()
        {
            LastSave = DateTime.Now;
            if (MyClient.There)
                if (MyClient.Online)
                {
                    InternalDatabase.SaveChar(this);
                    InternalDatabase.Savetoprank(this);
                }
        }
In character.cs below public byte Rank = 0;
Code:
public byte toprank = 0;
In character.cs below public void SaveRank() ... ... ...
Code:
public void Savetoprank()
        {
            LastSave = DateTime.Now;
            if (MyClient.There)
                if (MyClient.Online)
                {
                    InternalDatabase.SaveChar(this);
                    InternalDatabase.Savetoprank(this);
                }
        }
In Database.cs below Charr.VP = (uint)DR["VP"];
Code:
Charr.toprank = Convert.ToByte((uint)DR["toprank"]);
Also in DatBase.cs below public static void SaveRank(Character Charr) ... ... ...
Code:
public static void Savetoprank(Character Charr)
        {
            MySqlCommand Command = null;
            Command = new MySqlCommand("UPDATE `Characters` SET `toprank` = '" + Charr.toprank + "' WHERE `Account` = '" + Charr.MyClient.Account + "'", ExternalDatabase.Connection);
            Command.ExecuteNonQuery();

        }
In world.CS below if if (Me.MyGuild != null)
Charr.MyClient.SendPacket(General.MyPackets.GuildN ame(Me.GuildID, Me.MyGuild.GuildName));

Quote:
if (Me.toprank == 1)
Charr.MyClient.SendPacket(General.MyPackets.String (Me.UID, 10, "gamefighter"));
if (Me.toprank == 2)
Charr.MyClient.SendPacket(General.MyPackets.String (Me.UID, 10, "gamewarrior"));
if (Me.toprank == 3)
Charr.MyClient.SendPacket(General.MyPackets.String (Me.UID, 10, "gamebow"));
if (Me.toprank == 4)
Charr.MyClient.SendPacket(General.MyPackets.String (Me.UID, 10, "gamewater"));
if (Me.toprank == 5)
Charr.MyClient.SendPacket(General.MyPackets.String (Me.UID, 10, "gamefire"));
In Client.CS below if (MyChar.Rank == 1)... .. ...
Code:
if (MyChar.toprank == 1)
                                    {
                                        SendPacket(General.MyPackets.String(MyChar.UID, 10, "gamefighter"));
                                    }
                                    if (MyChar.toprank == 2)
                                    {
                                        SendPacket(General.MyPackets.String(MyChar.UID, 10, "gamewarrior"));
                                    }
                                    if (MyChar.toprank == 3)
                                    {
                                        SendPacket(General.MyPackets.String(MyChar.UID, 10, "gamebow"));
                                    }
                                    if (MyChar.toprank == 4)
                                    {
                                        SendPacket(General.MyPackets.String(MyChar.UID, 10, "gamewater"));
                                    }
                                    if (MyChar.toprank == 5)
I did added toprank in my database at coproj -> characters.

Also my console give me an error when im logging in using a charr with the

Top Effect.
The console error is
Code:
System.InvalidCastException: Specified cast is not valid.
   at COServer_Project.InternalDatabase.GetCharInfo(Character Charr, String UserName) in O:\BasicCO\COServerProject\COServerProject\DataBase.cs:line 261
Q: Why i want to make this system?
A: So i can make NPC giving it. And because its nice ;)
08/31/2010 00:59 Korvacs#2
Show use what Line 261 of Database.cs is please.
08/31/2010 07:13 jackpotsvr#3
Quote:
Originally Posted by Korvacs View Post
Show use what Line 261 of Database.cs is please.
At the moment im at my laptop but i looked using notepad and it said Line 261 was
Code:
Charr.VP = (uint)DR["VP"];
but i thought yesterday at my Visual Studios it was 1 line after that one ..
Quote:
Charr.toprank = Convert.ToByte((uint)DR["toprank"]);
So its one of that 2 , Hope so you can help me ;)
08/31/2010 08:59 Korvacs#4
Probably do this instead:

Code:
Charr.toprank = (byte)DR["toprank"];
08/31/2010 17:05 jackpotsvr#5
Quote:
Originally Posted by Korvacs View Post
Probably do this instead:

Code:
Charr.toprank = (byte)DR["toprank"];
Thanks, i tried but actually the only differnce was i also couldn't log in chars who actually shouldn't have the effect :S Maybe i have to add codes to other .cs files of the solution? Or my code was to bad :S ,,
Thanks for help i hope so we can fix it :)
08/31/2010 17:07 Korvacs#6
Depends what type the value is being stored as in the database, can you tell me what the column is defined as?
08/31/2010 19:16 jackpotsvr#7
Quote:
Originally Posted by Korvacs View Post
Depends what type the value is being stored as in the database, can you tell me what the column is defined as?
Column is..
Name: toprank
Type: int
Length: 8
Decimals: 0
Allow Null: unvinked
----------------------

Is that wrong?
09/01/2010 05:15 pro4never#8
Quote:
Originally Posted by jackpotsvr View Post
Column is..
Name: toprank
Type: int
Length: 8
Decimals: 0
Allow Null: unvinked
----------------------

Is that wrong?
is the value over 255? if you're loading it as a byte and yet the column in the database is a length 8 int that means you can EASILY have a value over 255... If any of them are this will cause an issue because obviously you can't (byte) something over 255 as that's the max value.
09/01/2010 07:34 jackpotsvr#9
The vavlues and where they stand for
0 for top rank
1 for Tro
2 for War
3 for Archer
4 for Water
5 for Fire
09/10/2010 17:42 jackpotsvr#10
UPDATE*
My LOTF Source has got Noble Rank, when i searched for Rank trough the whole solution i found much more places where i should ad some top rank thingys,, ill update it soon and ill think this willl fix the bug, when i get more trouble ill post here ;)
09/11/2010 18:15 jackpotsvr#11
After i tried a lot its unsolveable