Comandos -
Ts3 - 24.10.2014
Bem galera preciso de uma ajuda...
Primeiro esse meu comando, gostaria de saber como colocar uma mensagem ''
Nгo hб administradores online'', caso nгo tenha nenhum admin online.
pawn Код:
command(admins, playerid, params[])
{
SendClientMessage(playerid, Azul,"Membros da Staff online:");
for(new i; i != MAX_PLAYERS; ++i)
{
if(PlayerInfo[i][pAdmin] >= 3)
{
new string[50];
format(string,sizeof(string),"%s", Nome(i), playerid);
SendClientMessage(playerid,-1,string);
}
}
return 1;
}
E o outro e um pedido, queria um ranking ex:
Eu digito comando:
/score
Entгo iria aparecer um dialog com os 5 players com maior score do servidor, se nгo puder 5 players apenas 1 mesmo o com maior score do servidor.
Jб
procurei/usei vбrios rankings e nenhum funcionou da forma desejada sempre com bugs, alguйm ajuda? :/
Re: Comandos -
ArthurxD - 24.10.2014
Tenta aн, nao testei
pawn Код:
command(admins, playerid, params[])
{
new bool:conectado = false;
SendClientMessage(playerid, Azul,"Membros da Staff online:");
for(new i; i != MAX_PLAYERS; ++i)
{
if(PlayerInfo[i][pAdmin] >= 3 || IsPlayerAdmin(i))
{
conectado = true;
new string[50];
format(string,sizeof(string),"%s", Nome(i), playerid);
SendClientMessage(playerid,-1,string);
}
}
if(conectado == false) return SendClientMessage(playerid, -1, "[Erro]Nгo tem admins online");
return 1;
}
Re: Comandos -
Ts3 - 24.10.2014
Entгo.. deu alguns erros eu corrigi eles, testei o comando e nгo resultou, nгo apareceu mensagem.
Re: Comandos -
ArthurxD - 24.10.2014
Eu editei, tenta agora.
Re: Comandos -
ReyMysterio - 24.10.2014
Fiz aqui um com dialog para vocк:
@EDIT 14:02
Assim й que estб correto
pawn Код:
command(admins, playerid, params[])
{
new
StringCat[1040],
string[80],
ContarStaff
;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 3)
{
format(string,sizeof(string),"%s[%d]\n", Nome(i), i);
strcat(StringCat, string);
ContarStaff++;
}
}
}
if(ContarStaff > 0)
{
ShowPlayerDialog(playerid, /*COLOCA UM ID DE DIALOG*/, DIALOG_STYLE_MSGBOX, "{00FF00}Membros da Staff online", string, "Fechar", #);
return 1;
}
else ShowPlayerDialog(playerid, /*COLOCA O MESMO ID QUE EM CIMA*/, DIALOG_STYLE_MSGBOX, "{FF0000}Membros da Staff online", "{FF0000}Nгo tem membros da staff online no momento!", "Fechar", #);
return 1;
}
Re: Comandos -
Ts3 - 24.10.2014
Gostei desse comando em dialog, obrigado Rey +rep, obrigado tambйm Arthur +rep para vocк
#Edit
Rey nгo consegui dar rep para vocк. '-'
e o rank alguйm pode me ajudar? dei uma pesquisada e achei esse.
pawn Код:
command(reidoscore, playerid, params[])
{
new DDS[230];
for(new i; i <= MAX_PLAYERS; ++i)
{
if(PlayerInfo[i][pScore] >= PlayerInfo[i][pScore])
{
format(DDS, sizeof DDS,"{00FF00}[1°]{000FFF} %s {FFFFFF}-{FF0000} %d {FFFFFF}Pontos\n", Nome(i), PlayerInfo[i][pScore]);
break;
}
}
ShowPlayerDialog(playerid, DIALOG_RANK, DIALOG_STYLE_MSGBOX, "Rank", DDS, "Fechar", "");
return true;
}
Ele estб bugado, vou dar um exemplo..
Se eu logar tendo score
200 digito o comando e tals eu apareзo em 1° no ranking, mas se alguйm com score
300 logar eu ainda fico em 1° no ranking ou seja ele nгo estб atualizando, alguйm poderia me ajudar?
Re: Comandos -
Schocc - 24.10.2014
@Ts3: Vocк precisa usar um algoritimo de
ranking/rating (
classificaзгo). Se procurar no ****** vocк encontra alguns metodos.
Uma forma fбcil de fazer rankings й com MySQL, pois quando usamos SQL podemos fazer as consultas diretamente na ordem que precisamos. MySQL й muito ъtil para sa-mp por esta questгo.
@offTopic: Ainda to vivo HU3HU3
Veja este exemplo feito em
C.
pawn Код:
/*
* C program to accept a set of numbers and arrange them
* in a descending order
*/
#include <stdio.h>
void main ()
{
int number[30];
int i, j, a, n;
printf("Enter the value of N\n");
scanf("%d", &n);
printf("Enter the numbers \n");
for (i = 0; i < n; ++i)
scanf("%d", &number[i]);
/* sorting begins ... */
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (number[i] < number[j])
{
a = number[i];
number[i] = number[j];
number[j] = a;
}
}
}
printf("The numbers arranged in descending order are given below\n");
for (i = 0; i < n; ++i)
{
printf("%d\n", number[i]);
}
}
Re: Comandos -
Ts3 - 24.10.2014
Schocc, nгo teria como fazer um simples para mim? sem ser em
MySQL ou
C..
Bem simples mesmo, que pegasse o player com maior level online no servidor, e que atualizasse acada player que entrasse no servidor.
Re: Comandos -
Ts3 - 25.10.2014
UP, achei um a FS de ranking por mortes alguйm poderia converter ou me dar um exemplo de como eu poderia converte-lo de de
Mortes para o maior
Score.
http://i.imgur.com/BOVDjw2.jpg
pawn Код:
enum Ranking
{
Score, Id
}
enum pDados
{
pMatou
}
new PlayerScore[MAX_PLAYERS][Ranking];
new PlayerDados[MAX_PLAYERS][pDados];
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)[...]
+Rep para quem me ajudar.
Re: Comandos -
JuninTJF - 25.10.2014
Ai amigo pode ser tipo um /recorde ai ele diz o Player com o Nivel mais alto no servidor ?