Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ================================================================================
- - Sistema de Ranking por Mortes -
- Criado por: Baiano
- Agradecimentos para: Zeex pelo zcmd.
- Se for usar o código não retire os créditos! :)
- ================================================================================
- */
- #include <a_samp>
- #include <zcmd>
- enum Ranking
- {
- Score, Id
- }
- enum pDados
- {
- pMatou
- }
- new PlayerScore[MAX_PLAYERS][Ranking];
- new PlayerDados[MAX_PLAYERS][pDados];
- public OnFilterScriptInit()
- {
- print("\n----------------------------------");
- print(" Sistema de Ranking Carregado ");
- print(" Feito por BaiaNo. ");
- print("----------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n----------------------------------");
- print(" Sistema de Ranking Descarregado ");
- print(" Feito por BaiaNo. ");
- print("----------------------------------\n");
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- CMD:ranking(playerid)
- {
- new n = 0, Rmsg[1000];
- for (new i = 0; i < MAX_PLAYERS; i++) {
- if (IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- PlayerScore[n][Score] = PlayerDados[i][pMatou];
- PlayerScore[n][Id] = i;
- n++;
- }
- }
- GetPlayerHighestScores(PlayerScore, 0, n);
- for (new i = 10; i > 0; i--)
- if (PlayerScore[i][Id] == PlayerScore[i - 1][Id]) PlayerScore[i][Id] = 999;
- for (new i = 0; i < 10; i++) {
- if (PlayerScore[i][Id] == 999) format(Rmsg, sizeof(Rmsg), "{FFFF00}%s %i - Ninguém.\n", Rmsg, i + 1);
- else {
- new BaianoGTS[MAX_PLAYER_NAME];
- GetPlayerName(PlayerScore[i][Id], BaianoGTS, sizeof(BaianoGTS));
- format(Rmsg, sizeof(Rmsg), "{FFFF00}%s %i - %s | [Matou %i]\n", Rmsg, i + 1, BaianoGTS, PlayerScore[i][Score]);
- }
- }
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "{FF0000}Ranking", Rmsg, "Ok", "");
- return 1;
- }
- stock GetPlayerHighestScores(array[][Ranking], left, right)
- {
- new tempLeft = left, tempRight = right, pivot = array[(left + right) / 2][Score], tempVar;
- while(tempLeft <= tempRight) {
- while(array[tempLeft][Score] > pivot) tempLeft++;
- while(array[tempRight][Score] < pivot) tempRight--;
- if(tempLeft <= tempRight) {
- tempVar = array[tempLeft][Score], array[tempLeft][Score] = array[tempRight][Score], array[tempRight][Score] = tempVar;
- tempVar = array[tempLeft][Id], array[tempLeft][Id] = array[tempRight][Id], array[tempRight][Id] = tempVar;
- tempLeft++, tempRight--;
- }
- }
- if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
- if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
- }
Advertisement
Add Comment
Please, Sign In to add comment