Into dialog topscores
#1

Hey Guys,

How i can put this in dialog but will this 4 top players count ?


Код:
CMD:topscores(playerid,params[]) {
    #pragma unused params
 		new string[128], Slot1 = -1, Slot2 = -1, Slot3 = -1, Slot4 = -1, HighestCash = -9999;
 		SendClientMessage(playerid,COLOR_WHITE,"Top Scorers:");

		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x)) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot1 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot2 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot3 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2 && x != Slot3) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot4 = x;
		}
		format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot1,PlayerName2(Slot1),GetPlayerScore(Slot1), GetRankName(Slot1) );
		SendClientMessage(playerid,COLOR_WHITE,string);
		if(Slot2 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot2,PlayerName2(Slot2),GetPlayerScore(Slot2), GetRankName(Slot2));
			SendClientMessage(playerid,COLOR_WHITE,string);
		}
		if(Slot3 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot3,PlayerName2(Slot3),GetPlayerScore(Slot3), GetRankName(Slot3) );
			SendClientMessage(playerid,COLOR_WHITE,string);
		}
		if(Slot4 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot4,PlayerName2(Slot4),GetPlayerScore(Slot4), GetRankName(Slot4) );
			SendClientMessage(playerid,COLOR_WHITE,string);
		}
		return 1;
}
Reply
#2

Not sure if will work or not , not tested.

Код:
COMMAND:topscores(playerid, params[])
{
new string[128], Slot1 = -1, Slot2 = -1, Slot3 = -1, Slot4 = -1, HighestCash = -9999;
new scores[300];
for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x)) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot1 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot2 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot3 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2 && x != Slot3) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot4 = x;
		}
format(scores, sizeof(scores),"(%d) %s - %d - Rank: %s\n(%d) %s - %d - Rank: %s\n(%d) %s - %d - Rank: %s",Slot1,PlayerName2(Slot1),GetPlayerScore(Slot1), GetRankName(Slot1),Slot2,PlayerName2(Slot2),GetPlayerScore(Slot2), GetRankName(Slot2),Slot3,PlayerName2(Slot3),GetPlayerScore(Slot3), GetRankName(Slot3));
 ShowPlayerDialog(playerid,100,DIALOG_STYLE_LIST,"Top 10 Scores",scores,"Okay","");
}
Reply
#3

Test and this if works or not and tell me
Код:
CMD:topscores(playerid,params[]) {
 		new string[128], Slot1 = -1, Slot2 = -1, Slot3 = -1, Slot4 = -1, HighestCash = -9999;

		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x)) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot1 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot2 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot3 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2 && x != Slot3) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot4 = x;
		}
		format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot1,PlayerName2(Slot1),GetPlayerScore(Slot1), GetRankName(Slot1) );
		SendClientMessage(playerid,COLOR_WHITE,string);
		if(Slot2 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot2,PlayerName2(Slot2),GetPlayerScore(Slot2), GetRankName(Slot2));
			SendClientMessage(playerid,COLOR_WHITE,string);
		}
		if(Slot3 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot3,PlayerName2(Slot3),GetPlayerScore(Slot3), GetRankName(Slot3) );
			SendClientMessage(playerid,COLOR_WHITE,string);
		}
		if(Slot4 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot4,PlayerName2(Slot4),GetPlayerScore(Slot4), GetRankName(Slot4) );
			SendClientMessage(playerid,COLOR_WHITE,string);
			ShowPlayerDialog(playerid,100,DIALOG_STYLE_LIST,"Top 4",string,"Ok","");
		}
		return 1;
}
Reply
#4

No work!
Reply
#5

Anyone else ?
Reply
#6

Код:
CMD:topscores(playerid,params[]) {
 		new string[128], Slot1 = -1, Slot2 = -1, Slot3 = -1, Slot4 = -1, HighestCash = -9999;

		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x)) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot1 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot2 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot3 = x;
		}
		HighestCash = -9999;
		for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2 && x != Slot3) if (GetPlayerScore(x) >= HighestCash) {
			HighestCash = GetPlayerScore(x);
			Slot4 = x;
		}
		format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot1,PlayerName2(Slot1),GetPlayerScore(Slot1), GetRankName(Slot1) );
		SendClientMessage(playerid,COLOR_WHITE,string);
		if(Slot2 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot2,PlayerName2(Slot2),GetPlayerScore(Slot2), GetRankName(Slot2));
			SendClientMessage(playerid,COLOR_WHITE,string);
		}
		if(Slot3 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot3,PlayerName2(Slot3),GetPlayerScore(Slot3), GetRankName(Slot3) );
			SendClientMessage(playerid,COLOR_WHITE,string);
		}
		if(Slot4 != -1)	{
			format(string, sizeof(string), "(%d) %s - %d - Rank: %s", Slot4,PlayerName2(Slot4),GetPlayerScore(Slot4), GetRankName(Slot4) );
			SendClientMessage(playerid,COLOR_WHITE,string);
		
		}
ShowPlayerDialog(playerid,100,DIALOG_STYLE_LIST,"Top 4",string,"Ok","");
		return 1;
}
Test and this one
Reply
#7

Not tested but should be way better than your existing code
PHP код:
CMD:topscores(playerid,params[]) {
    
#define COUNT 4
    
new
        
ijidxtop,
        
score[MAX_PLAYERS] = {-1, ...},
        
player[sizeof score] = {INVALID_PLAYER_ID, ...};
    for(
0sizeof score; ++i) {
        if(
IsPlayerConnected(i)) {
            
score[i] = GetPlayerScore((player[i] = i));
        }
    }
    for(
0COUNT; ++i) {
        
top score[(idx i)];
        while(++
sizeof score) {
            if(
top score[j]) {
                
top score[(idx j)];
            }
        }
        
score[idx] = score[i];
        
score[i] = top;
        
player[idx] = player[i];
        
player[i] = idx;
    }
    for(
score[0] = 0COUNT && (player[i]) != INVALID_PLAYER_ID; ++i) {
        
format(scoresizeof score"%s\n(%d) %s - %d - Rank: %s"jPlayerName2(j), GetPlayerScore(j), GetRankName(j));
    }
    return 
ShowPlayerDialog(playerid100DIALOG_STYLE_LIST"Top " #COUNT, score[1], "Ok", "");
    #undef COUNT

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)