16.08.2016, 18:15
(
Last edited by RodrigoMSR; 20/08/2016 at 09:36 PM.
)
Funзгo de rank:
Exemplo de uso:
Code:
stock Rank(Scor[], Top[], size, size2) { new scortp; for(new tp = 0; tp < size2; tp++) { scortp = 0; for(new sp = 0; sp < size; sp++) { if(tp == 0) { if(Scor[sp] > scortp) { Top[tp] = sp; scortp = Scor[sp]; } } else { if(Scor[sp] > scortp) { if(Scor[sp] < Scor[Top[tp-1]]) { Top[tp] = sp; scortp = Scor[sp]; } } } } } return 1; }
Code:
#include <a_samp> #include <zcmd> CMD:rank(playerid) { new Scor[MAX_PLAYERS], Top[10], str[600], name[MAX_PLAYER_NAME]; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) Scor[i] = GetPlayerScore(i); } Rank(Scor, Top, sizeof(Scor), sizeof(Top)); for(new i = 0; i < 10; i++) { GetPlayerName(Top[i], name, sizeof(name)); format(str, sizeof(str), "%s\n%02dє - %s (%i) - %d scores", str, i+1, name, Top[i], Scor[Top[i]]); } ShowPlayerDialog(playerid, 2131, DIALOG_STYLE_MSGBOX, "Rank", str, "Fechar", ""); return 1; }