18.12.2012, 18:54
їAlguien me da alguna ayuda sobre cуmo hacer algo parecido a йsto?:
Sн, ya habнa visto ese post, pero entre que estб en inglйs y que mis conocimientos de pawn no van mбs allб de los bбsico..
Si alguien me explica cуmo usarlo.. |
enum rankingEnum
{
player_Score,
player_ID
}
stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2][player_Score],
tempVar
;
while(tempLeft <= tempRight)
{
while(array[tempLeft][player_Score] > pivot) tempLeft++;
while(array[tempRight][player_Score] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
stock Nombre(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
new playerScores[MAX_PLAYERS][rankingEnum], index;
for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
playerScores[index][player_Score] = GetPlayerScore(i);
playerScores[index][player_ID] = i;
++index;
}
}
GetPlayerHighestScores(playerScores, 0, index);
for(new i; i != 30; ++i)
{
new string[512];
format(string, sizeof(string), "Jugador: %s Score: %d", Nombre(playerScores[i][player_ID]), playerScores[i][player_Score], i);
TextDrawSetString(Textdraw[i], string);
}
#include <a_samp> new Text:Textdraw; enum rankingEnum { player_Score, player_ID } public OnFilterScriptInit() { Textdraw = TextDrawCreate(499.000000, 15.000000, ""); TextDrawBackgroundColor(Textdraw, 255); TextDrawFont(Textdraw, 1); TextDrawLetterSize(Textdraw, 0.310000, 1.200000); TextDrawColor(Textdraw, -1); TextDrawSetOutline(Textdraw, 0); TextDrawSetProportional(Textdraw, 1); TextDrawSetShadow(Textdraw, 1); TextDrawUseBox(Textdraw, 1); TextDrawBoxColor(Textdraw, 255); TextDrawTextSize(Textdraw, 603.000000, 0.000000); return 1; } public OnPlayerSpawn(playerid) { TextDrawShowForPlayer(playerid, Textdraw); return 1; } stock GetPlayerHighestScores(array[][rankingEnum], left, right) { new tempLeft = left, tempRight = right, pivot = array[(left + right) / 2][player_Score], tempVar ; while(tempLeft <= tempRight) { while(array[tempLeft][player_Score] > pivot) tempLeft++; while(array[tempRight][player_Score] < pivot) tempRight--; if(tempLeft <= tempRight) { tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar; tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar; tempLeft++, tempRight--; } } if(left < tempRight) GetPlayerHighestScores(array, left, tempRight); if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right); } stock Nombre(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); return name; } public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp("/prueba", cmdtext, true) == 0) { new playerScores[MAX_PLAYERS][rankingEnum], index; for(new i; i != MAX_PLAYERS; ++i) { if(IsPlayerConnected(i) && !IsPlayerNPC(i)) { playerScores[index][player_Score] = GetPlayerScore(i); playerScores[index][player_ID] = i; ++index; } } GetPlayerHighestScores(playerScores, 0, index); for(new i; i != 30; ++i) { new string[512]; format(string, sizeof(string), "Jugador: %s Score: %d", Nombre(playerScores[i][player_ID]), playerScores[i][player_Score], i); TextDrawSetString(Textdraw, string); } return 1; } return 0; }
#include <a_samp>
new Text:Textdraw[31];
enum rankingEnum
{
player_Score,
player_ID
}
public OnFilterScriptInit()
{
Textdraw[1] = TextDrawCreate(499.000000, 15.000000, ""); // pos 1
Textdraw[2] = TextDrawCreate(499.000000, 15.000000, ""); // pos 2
Textdraw[3] = TextDrawCreate(499.000000, 15.000000, ""); // pos 3
Textdraw[4] = TextDrawCreate(499.000000, 15.000000, ""); // pos 4
Textdraw[5] = TextDrawCreate(499.000000, 15.000000, ""); // pos 5
// has las posiciones puedes optimizarlas por lineas sumandole a Y y dejar igual X
for(new i = 0; i < 30; i++)
{
TextDrawBackgroundColor(Textdraw[i], 255);
TextDrawFont(Textdraw[i], 1);
TextDrawLetterSize(Textdraw[i], 0.310000, 1.200000);
TextDrawColor(Textdraw[i], -1);
TextDrawSetOutline(Textdraw[i], 0);
TextDrawSetProportional(Textdraw[i], 1);
TextDrawSetShadow(Textdraw[i], 1);
TextDrawUseBox(Textdraw[i], 1);
TextDrawBoxColor(Textdraw[i], 255);
TextDrawTextSize(Textdraw[i], 603.000000, 0.000000);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/prueba", cmdtext, true) == 0)
{
new playerScores[MAX_PLAYERS][rankingEnum], index;
for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
playerScores[index][player_Score] = GetPlayerScore(i);
playerScores[index][player_ID] = i;
++index;
}
}
GetPlayerHighestScores(playerScores, 0, index);
for(new i; i != 30; ++i)
{
new string[512];
format(string, sizeof(string), "Jugador: %s Score: %d", Nombre(playerScores[i][player_ID]), playerScores[i][player_Score], i);
TextDrawSetString(Textdraw[i], string);
TextDrawShowForPlayer(playerid, TextDraw[i]);
}
return 1;
}
return 0;
}
stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2][player_Score],
tempVar
;
while(tempLeft <= tempRight)
{
while(array[tempLeft][player_Score] > pivot) tempLeft++;
while(array[tempRight][player_Score] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
stock Nombre(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
new string[512]; format(string, sizeof(string), "%s", Nombre(playerScores[i][player_ID]), i); TextDrawSetString(Textdraw[i], string); format(string, sizeof(string), "%d", Nombre(playerScores[i][player_ID]), playerScores[i][player_Score], i); TextDrawSetString(Textdraw19[i], string);
new string[512];
format(string, sizeof(string), "%s", Nombre(playerScores[i][player_ID]));
TextDrawSetString(Textdraw[i], string);
format(string, sizeof(string), "%d", playerScores[i][player_Score]);
TextDrawSetString(Textdraw19[i], string);