public FindHighestScore(){
new Player_Score_Save = 0;
new Player_Score_ID = 0;
new Player_Score_ID2 = 0;
new Player_Draw_Check = 0;
new Player_Draw_Array[100] = 0;
new Player_Draw_Array_Count = 0;
new Debug_Enabled = 1;
//Setup the array before use
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Setting up the array"); }
for(new i=0; i<100; i++)
{
Player_Draw_Array[i] = 101;
}
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Setting up the array... DONE"); }
//Array setup and ready to go...
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Searching players for best score!"); }
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (GetPlayerScore(i) > Player_Score_Save) {
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Found a player with a better score than last time!"); }
Player_Score_Save = GetPlayerScore(i);
Player_Score_ID = i;
}
}
}
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Outta the loop - lets loop now for the draw system"); }
Player_Score_ID2 = 101;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(Player_Score_ID != i){
if(IsPlayerConnected(i))
{
if (GetPlayerScore(i) == Player_Score_Save) {
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Found player who has drawn with other player!!!"); }
Player_Draw_Array[Player_Draw_Array_Count] = i;
Player_Draw_Array_Count++;
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Array Count:"); }
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, Player_Draw_Array_Count); }
//Player_Score_ID2 = i; //No longer used - I BUMMED IT TO J00!
Player_Draw_Check = 1;
}
}
}
}
new str1[STR_LEN] = "";
new str2[STR_LEN] = "";
new strFirstName[MAX_PLAYER_NAME] = "";
new strSecondName[MAX_PLAYER_NAME] = "";
//Some array shit
new strDrawArray[1024] = "";
new strDrawPlayerName[MAX_PLAYER_NAME] = "";
//We want a bigger size here, because were adding names in here :D (or thats the idea...)
new strDrawArrayFinish[512] = "";
if (Player_Draw_Check == 1) {
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Its a draw!, PROCESS IT!!!!one!!1111!!o1ne!"); }
for(new i=0; i<(Player_Draw_Array_Count-1); i++)
{
if (Player_Draw_Array[i] != 101)
{
strDrawPlayerName = ReadPlayerName(Player_Draw_Array[i]);
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "Found Playername (in array):"); }
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, strDrawPlayerName); }
format(strDrawArray, STR_LEN, "%s, %s", strDrawPlayerName, strDrawArray);
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "strDrawArray is now"); }
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, strDrawArray); }
}
}
//strFirstName = ReadPlayerName(Player_Score_ID);
//strSecondName = ReadPlayerName(Player_Score_ID2);
SendClientMessageToAll(COLOR_YELLOW, "Players who are drawing for the lead are:");
//format(strDrawArray, STR_LEN, "Players who are drawing for the lead: %s", strDrawArray);
SendClientMessageToAll(COLOR_YELLOW, strDrawArray);
}
if (Player_Draw_Check == 0) {
if(Debug_Enabled) { SendClientMessageToAll(COLOR_YELLOW, "not a draw"); }
strFirstName = ReadPlayerName(Player_Score_ID);
format(str2, STR_LEN, "Player with the highest score: %s", strFirstName);
SendClientMessageToAll(COLOR_YELLOW, str2);
}
SendClientMessageToAll(COLOR_RED, "FINIE");
}