21.09.2011, 21:01
Bem meu problema й o seguinte.
eu gostaria de criar um comando (/rank) que quando for ativado apareзa um TextDraw com um rank dos 3 primeiros (o q tiver mais score й o 1є).
no topo eu coloquei:
new Text:Textdraw13;
new Text:Textdraw14;
new Text:Textdraw15;
no OnFilterScriptInit:
Textdraw13 = TextDrawCreate(439.000000, 367.000000, "_");
TextDrawBackgroundColor(Textdraw13, 255);
TextDrawFont(Textdraw13, 0);
TextDrawLetterSize(Textdraw13, 0.329999, 1.099999);
TextDrawColor(Textdraw13, -1);
TextDrawSetOutline(Textdraw13, 0);
TextDrawSetProportional(Textdraw13, 1);
TextDrawSetShadow(Textdraw13, 0);
Textdraw14 = TextDrawCreate(446.000000, 367.000000, "_");
TextDrawBackgroundColor(Textdraw14, 255);
TextDrawFont(Textdraw14, 0);
TextDrawLetterSize(Textdraw14, 0.329999, 1.099999);
TextDrawColor(Textdraw14, -1);
TextDrawSetOutline(Textdraw14, 0);
TextDrawSetProportional(Textdraw14, 1);
TextDrawSetShadow(Textdraw14, 0);
Textdraw15 = TextDrawCreate(446.000000, 367.000000, "_");
TextDrawBackgroundColor(Textdraw15, 255);
TextDrawFont(Textdraw15, 0);
TextDrawLetterSize(Textdraw15, 0.329999, 1.099999);
TextDrawColor(Textdraw15, -1);
TextDrawSetOutline(Textdraw15, 0);
TextDrawSetProportional(Textdraw15, 1);
TextDrawSetShadow(Textdraw15, 0);
no OnPlayerCommandText eu criei:
new
cmd[256],
idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/rank", true) == 0)
{
new
ar[MAX_PLAYERS][2],
tmpsize;
tmpsize = fill ( ar );
process( ar , tmpsize );
Primeiro ( ar , tmpsize );
Segundo ( ar , tmpsize );
Terceiro ( ar , tmpsize );
return 1;
}
e no final eu coloquei:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
//************************************************** ***************************
stock PlayerName(playerid)
{
new Name[MAX_PLAYERS];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
//************************************************** ***************************
stock fill ( array[][] )
{
new x_count;
for ( new g = 0; g < MAX_PLAYERS; g++ )
if ( IsPlayerConnected ( g ) )
{
x_count++;
array[g][1] = g;
array[g][0] = GetPlayerScore ( g );
array[g][2] = GetPlayerScore ( g );
array[g][3] = GetPlayerScore ( g );
}
return x_count;
}
//************************************************** ***************************
stock process ( array[][] , size = sizeof ( array ) )
{
if ( size > 1 )
{
new
bool:flag,
tmpx;
do
{
flag = true;
for ( new i = size - 1; i > 0; i-- )
if ( array[i][0] < array[i - 1][0] )
{
tmpx = array[i][3];
array[i][3] = array[i - 1][3];
array[i - 1][3] = tmpx;
tmpx = array[i][2];
array[i][2] = array[i - 1][2];
array[i - 1][2] = tmpx;
tmpx = array[i][0];
array[i][0] = array[i - 1][0];
array[i - 1][0] = tmpx;
tmpx = array[i][1];
array[i][1] = array[i - 1][1];
array[i - 1][1] = tmpx;
flag = false;
}
}
while flag == false;
}
}
//************************************************** ***************************
stock Primeiro ( array[][] , max , count = 1 )
{
new
str[255],
pln[255];
for ( new i = 0; i < ( ( max < count) ? max : count ); i++ )
{
GetPlayerName ( array[i][1] , pln , sizeof ( pln ) );
format( str , sizeof ( str ) , "1 - %s . %d " , pln, array[i][0]);
TextDrawSetString(Textdraw13, str);
TextDrawShowForPlayer(i,Textdraw13);
}
return true;
}
stock Segundo ( array[][] , max , count = 1 )
{
new
strr[255],
plnn[255];
for ( new i = 0; i < ( ( max < count) ? max : count ); i++ )
{
GetPlayerName ( array[i][1] - 1, plnn , sizeof ( plnn ) );
format( strr , sizeof ( strr ) , "2 - %s . %d " , plnn, array[i][2]);
TextDrawSetString(Textdraw14, strr);
TextDrawShowForPlayer(i,Textdraw14);
}
return true;
}
stock Terceiro ( array[][] , max , count = 1 )
{
new
strrr[255],
plnnn[255];
for ( new i = 0; i < ( ( max < count) ? max : count ); i++ )
{
GetPlayerName ( array[i][1] - 2, plnnn , sizeof ( plnnn ) );
format( strrr , sizeof ( strrr ) , "3 - %s . %d " , plnnn, array[i][3]);
TextDrawSetString(Textdraw15, strrr);
TextDrawShowForPlayer(i,Textdraw15);
return 1;
}
return true;
}
Esse Comando eu tirei do prуprio forum, nao lembro quem fez agora, mais fiz umas modificaзхes para tentar alcanзar o q eu queria mais nao consegui =(
Se alguem Souber poderia me ajuda porfavor....
Agadeзo desde jб.
eu gostaria de criar um comando (/rank) que quando for ativado apareзa um TextDraw com um rank dos 3 primeiros (o q tiver mais score й o 1є).
no topo eu coloquei:
new Text:Textdraw13;
new Text:Textdraw14;
new Text:Textdraw15;
no OnFilterScriptInit:
Textdraw13 = TextDrawCreate(439.000000, 367.000000, "_");
TextDrawBackgroundColor(Textdraw13, 255);
TextDrawFont(Textdraw13, 0);
TextDrawLetterSize(Textdraw13, 0.329999, 1.099999);
TextDrawColor(Textdraw13, -1);
TextDrawSetOutline(Textdraw13, 0);
TextDrawSetProportional(Textdraw13, 1);
TextDrawSetShadow(Textdraw13, 0);
Textdraw14 = TextDrawCreate(446.000000, 367.000000, "_");
TextDrawBackgroundColor(Textdraw14, 255);
TextDrawFont(Textdraw14, 0);
TextDrawLetterSize(Textdraw14, 0.329999, 1.099999);
TextDrawColor(Textdraw14, -1);
TextDrawSetOutline(Textdraw14, 0);
TextDrawSetProportional(Textdraw14, 1);
TextDrawSetShadow(Textdraw14, 0);
Textdraw15 = TextDrawCreate(446.000000, 367.000000, "_");
TextDrawBackgroundColor(Textdraw15, 255);
TextDrawFont(Textdraw15, 0);
TextDrawLetterSize(Textdraw15, 0.329999, 1.099999);
TextDrawColor(Textdraw15, -1);
TextDrawSetOutline(Textdraw15, 0);
TextDrawSetProportional(Textdraw15, 1);
TextDrawSetShadow(Textdraw15, 0);
no OnPlayerCommandText eu criei:
new
cmd[256],
idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/rank", true) == 0)
{
new
ar[MAX_PLAYERS][2],
tmpsize;
tmpsize = fill ( ar );
process( ar , tmpsize );
Primeiro ( ar , tmpsize );
Segundo ( ar , tmpsize );
Terceiro ( ar , tmpsize );
return 1;
}
e no final eu coloquei:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
//************************************************** ***************************
stock PlayerName(playerid)
{
new Name[MAX_PLAYERS];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
//************************************************** ***************************
stock fill ( array[][] )
{
new x_count;
for ( new g = 0; g < MAX_PLAYERS; g++ )
if ( IsPlayerConnected ( g ) )
{
x_count++;
array[g][1] = g;
array[g][0] = GetPlayerScore ( g );
array[g][2] = GetPlayerScore ( g );
array[g][3] = GetPlayerScore ( g );
}
return x_count;
}
//************************************************** ***************************
stock process ( array[][] , size = sizeof ( array ) )
{
if ( size > 1 )
{
new
bool:flag,
tmpx;
do
{
flag = true;
for ( new i = size - 1; i > 0; i-- )
if ( array[i][0] < array[i - 1][0] )
{
tmpx = array[i][3];
array[i][3] = array[i - 1][3];
array[i - 1][3] = tmpx;
tmpx = array[i][2];
array[i][2] = array[i - 1][2];
array[i - 1][2] = tmpx;
tmpx = array[i][0];
array[i][0] = array[i - 1][0];
array[i - 1][0] = tmpx;
tmpx = array[i][1];
array[i][1] = array[i - 1][1];
array[i - 1][1] = tmpx;
flag = false;
}
}
while flag == false;
}
}
//************************************************** ***************************
stock Primeiro ( array[][] , max , count = 1 )
{
new
str[255],
pln[255];
for ( new i = 0; i < ( ( max < count) ? max : count ); i++ )
{
GetPlayerName ( array[i][1] , pln , sizeof ( pln ) );
format( str , sizeof ( str ) , "1 - %s . %d " , pln, array[i][0]);
TextDrawSetString(Textdraw13, str);
TextDrawShowForPlayer(i,Textdraw13);
}
return true;
}
stock Segundo ( array[][] , max , count = 1 )
{
new
strr[255],
plnn[255];
for ( new i = 0; i < ( ( max < count) ? max : count ); i++ )
{
GetPlayerName ( array[i][1] - 1, plnn , sizeof ( plnn ) );
format( strr , sizeof ( strr ) , "2 - %s . %d " , plnn, array[i][2]);
TextDrawSetString(Textdraw14, strr);
TextDrawShowForPlayer(i,Textdraw14);
}
return true;
}
stock Terceiro ( array[][] , max , count = 1 )
{
new
strrr[255],
plnnn[255];
for ( new i = 0; i < ( ( max < count) ? max : count ); i++ )
{
GetPlayerName ( array[i][1] - 2, plnnn , sizeof ( plnnn ) );
format( strrr , sizeof ( strrr ) , "3 - %s . %d " , plnnn, array[i][3]);
TextDrawSetString(Textdraw15, strrr);
TextDrawShowForPlayer(i,Textdraw15);
return 1;
}
return true;
}
Esse Comando eu tirei do prуprio forum, nao lembro quem fez agora, mais fiz umas modificaзхes para tentar alcanзar o q eu queria mais nao consegui =(
Se alguem Souber poderia me ajuda porfavor....
Agadeзo desde jб.