All pastes #158402 Raw Edit

Someone

public text v1 · immutable
·published 2006-09-02 03:22 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[100] = 0;
        new Player_Draw_Array_Count = 0;
        new aPlayer_Has_A_Score = 0;
        new str1[STR_LEN] = "";
        new str2[STR_LEN] = "";
        new str3[STR_LEN] = "";
        new strFirstName[MAX_PLAYER_NAME] = "";
        new strSecondName[MAX_PLAYER_NAME] = "";

        //Some array shit
        new strDrawArray[STR_LEN] = "";
        new strDrawPlayerName[MAX_PLAYER_NAME] = "";

        //Setup the array before use
        for(new i=0; i<100; i++)
        {
                Player_Draw_Array[i] = 101;
        }

        //Array setup and ready to go...

		//Start a loop around max players
        for(new i=0; i<MAX_PLAYERS; i++)
        {
                //Check if the player is connected
                if(IsPlayerConnected(i))
                {
                        //If the players score is higher than the saved score - its a new high score!
                        if (GetPlayerScore(i) > Player_Score_Save) {
                                //save the player details
                                Player_Score_Save = GetPlayerScore(i);
                                Player_Score_ID = i;
                                aPlayer_Has_A_Score = 1;
                        }
                }
        }
        //by this point, the 3 arrays would have been filled with some information
        //or 1 array been filled (if all scores = 0)

        if(aPlayer_Has_A_Score == 1)
        {

	        //Display the winning name
			//strDrawPlayerName = ReadPlayerName(Player_Score_ID);
			//SendClientMessageToAll(COLOR_PINK, "Player with highest score:");
			//SendClientMessageToAll(COLOR_PINK, strDrawPlayerName);
			
		    //Loop around all the players again, looking for the same score.
	        for(new i=0; i<MAX_PLAYERS; i++)
	        {
				if(IsPlayerConnected(i))
				{
		            //if (Player_Score_ID == INVALID_PLAYER_ID) Player_Score_ID = i;

		            //If the current playerID is above the found ID in the first loop.
	                if(Player_Score_ID == i){
	                    //SendClientMessageToAll(COLOR_PINK, "Player Skipped in draw check:");
	                    //strDrawPlayerName = ReadPlayerName(i);
	                    //SendClientMessageToAll(COLOR_PINK, strDrawPlayerName);
						Player_Draw_Array[Player_Draw_Array_Count] = i;
						Player_Draw_Array_Count++;
					}else{
	                    //SendClientMessageToAll(COLOR_PINK, "Player Scanned in draw check:");
	                    //strDrawPlayerName = ReadPlayerName(i);
	                    //SendClientMessageToAll(COLOR_PINK, strDrawPlayerName);
	                    //check if this player has the same score as the winner.
						if (Player_Score_Save == GetPlayerScore(i)) {
							SendClientMessageToAll(COLOR_PINK, "Im Inside the 'Found Same Score' Place!");
						    //This player DOES!
							Player_Draw_Array[Player_Draw_Array_Count] = i;
							Player_Draw_Array_Count++;

							Player_Draw_Check = 1;
						}
	                }
				}
	        }

	        //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) {
	                for(new i=0; i<Player_Draw_Array_Count; i++)
	                {
	                    //format(str3, STR_LEN, "%d", Player_Draw_Array[i]);
	                    //SendClientMessageToAll(COLOR_PINK, str3);
	                        if (Player_Draw_Array[i] != 101)
	                        {
	                                strDrawPlayerName = ReadPlayerName(Player_Draw_Array[i]);
	                                format(str1, STR_LEN, "%s, %s", strDrawPlayerName, str1);
	                        }
	                }
	                //strFirstName = ReadPlayerName(Player_Score_ID);
	                //strSecondName = ReadPlayerName(Player_Score_ID2);
	                format(str1, STR_LEN, "Players who draw: %s", str1);
	                SendClientMessageToAll(COLOR_YELLOW, str1);
	                
	        }else if (Player_Draw_Check == 0) {
	                strFirstName = ReadPlayerName(Player_Score_ID);
	                format(str2, STR_LEN, "Player with the highest score is %s", strFirstName);
	                SendClientMessageToAll(COLOR_YELLOW, str2);
	        }
		}else{
			SendClientMessageToAll(COLOR_YELLOW, "No players have a score above 0 yet!");
		}
}