void CharacterJobInfo()
{
//Wrap our function into catcher
try
{
//Set defaul int's to 0
int TotalHunters = 0;
int TotalThiefs = 0;
//Update hunter and thief count.
TotalHunters = MsSQL.GetRowsCount("SELECT * FROM users WHERE jobtype='1'");
TotalThiefs = MsSQL.GetRowsCount("SELECT * FROM users WHERE jobtype='2'");
//Set total count
int jobplayercount = TotalThiefs + TotalHunters;
//Set our null to 1 if this would happen
if (jobplayercount == 0) jobplayercount = 1;
//Calculate our % for the jobs
double thiefpercentage = (double)TotalThiefs / (double)jobplayercount * 100.0;
double hunterpercentage = (double)TotalHunters / (double)jobplayercount * 100.0;
//Send visual packet for job %
PacketWriter writer = new PacketWriter();
//Add opcode
writer.Create(Systems.SERVER_CHARACTERSCREEN);
//Static byte 9
writer.Byte(9);
//Static byte 1
writer.Byte(1);
//Byte total amount of hunters %
writer.Byte((byte)hunterpercentage);
//Byte total amount of thiefs %
writer.Byte((byte)thiefpercentage);
//Send bytes to client
client.Send(writer.GetBytes());
}
//Catch bad exception errors
catch (Exception ex)
{
//Write information to the console
Console.WriteLine("Character job info error {0}", ex);
//Write info to the debug log
Systems.Debugger.Write(ex);
}
}