03.07.2012, 13:18
Hmm..I think that was a dialog.
I'll show you an example UNTESTED
1. We define a variable to store score of each player
2. Now, set score of each player to 0 when gamemode start and add 1 after every kill.
3. When GameMode finishes.. we wish to sort them in descending order.
Now under OnGameModeExit add
1. Loop to sort everything in descending order.
2. String's to show in dialog
3. Loop to show Dialog
Full OnGameModeExit :
I'll show you an example UNTESTED
1. We define a variable to store score of each player
pawn Код:
new score[MAX_PLAYERS];
new scoreid[MAX_PLAYERS];//we will use this later
#define DIALOG_TOP 1 //Used to show dialog.
pawn Код:
//----------------------GAME_MODE_START-----------------------------\\
public OnGameModeInit()
{
for(new i=0;i<MAX_PLAYERS;++i) score[i] = 0;
return 1;
}
//--------------------------------AFTER KILLING------------------------------------\\
public OnPlayerDeath(playerid, killerid, reason)
{
score[killerid]++;
return 1;
}
pawn Код:
public OnGameModeExit()
{
return 1;
}
1. Loop to sort everything in descending order.
pawn Код:
new temp;
for(new i = 0;i<MAX_PLAYERS;++i)
{
for(new j = i;j<MAX_PLAYERS;++j)
{
if(score[j] > score[i])
{
temp = score[i];
score[i] = score[j];
score[j] = temp;
temp = scoreid[i];
scoreid[i] = scoreid[j];
scoreid[j] = temp;
}
}
}
pawn Код:
new string[5][200];
for(new i =0;i<5;++i)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(scoreid[i],name,sizeof(name));
format(string[i],200,"{FFFFFF}%d. {DE1868}%s (ID %d) : {3EA63A}%d",i+1,name,scoreid[i],score[i]);
}
new dstring[300];
format(fstring,300,"%s\n%s\n%s\n%s\n%s",string[0],string[1],string[2],string[3],string[4]);
pawn Код:
for(new i=0;i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i))
{
ShowPlayerDialog(i,DIALOG_TOP,0,"TOp 5",dstring,"OK","");
}
}
pawn Код:
public OnGameModeExit()
{
new temp;
for(new i = 0;i<MAX_PLAYERS;++i)
{
for(new j = i;j<MAX_PLAYERS;++j)
{
if(score[j] > score[i])
{
temp = score[i];
score[i] = score[j];
score[j] = temp;
temp = scoreid[i];
scoreid[i] = scoreid[j];
scoreid[j] = temp;
}
}
}
new string[5][200];
for(new i =0;i<5;++i)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(scoreid[i],name,sizeof(name));
format(string[i],200,"{FFFFFF}%d. {DE1868}%s (ID %d) : {3EA63A}%d",i+1,name,scoreid[i],score[i]);
}
new dstring[300];
format(fstring,300,"%s\n%s\n%s\n%s\n%s",string[0],string[1],string[2],string[3],string[4]);
for(new i=0;i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i))
{
ShowPlayerDialog(i,DIALOG_TOP,0,"TOp 5",dstring,"OK","");
}
}
return 1;
}

