All pastes #158200 Raw Edit

Someone

public text v1 · immutable
·published 2006-09-02 00:41 UTC
rendered paste body
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[101] = 0;
        new Player_Draw_Array_Count = 0;
        new Debug_Enabled = 1;
        new A_Score_Is_Found = 0;

        //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;
                                A_Score_Is_Found = 1;
                        }
                }
        }

if(A_Score_Is_Found == 1) {

//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_Count++;
                                        Player_Draw_Array[Player_Draw_Array_Count] = i;
                                        
                                        //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[512] = "";
        new strDrawPlayerName[MAX_PLAYER_NAME] = "";
        new strAnnouncer[512] = "";

        //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=1; i<Player_Draw_Array_Count; 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, 512, "%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, 512, "Players who are drawing for the lead: %s", strDrawArray);
                SendClientMessageToAll(COLOR_PINK, 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);
        }
}else{
SendClientMessageToAll(COLOR_YELLOW, "No one is currently in the lead!");
}
SendClientMessageToAll(COLOR_RED, "FINIE");
}