Problema con los bucles - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: Problema con los bucles (
/showthread.php?tid=578446)
Problema con los bucles -
Minikole - 19.06.2015
Hola, estaba haciendo un cmd para ver que usuarios son administradores y ponerlo en un dialogo.
El problema es que solo me imprime un nombre y no el resto. Dejare el codigo por si alguien encuentra el error.
Код:
CMD:admins(playerid, params[])
{
new Nombre[MAX_PLAYER_NAME], string[500], string1[30];
format(string1, sizeof string1, "ID\tNombre\n");
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(JugadorInfo[i][jAdmin] > 0)
{
GetPlayerName(i, Nombre, sizeof Nombre);
format(string, sizeof string, "%s%i\t%s\n",string1,i, Nombre);
}
else ShowPlayerDialog(playerid, 76, DIALOG_STYLE_MSGBOX, "SIN RESULTADOS", "SIN RESULTADOS", "ACEPTAR", "CANCELAR");
}
ShowPlayerDialog(playerid, 60, DIALOG_STYLE_TABLIST_HEADERS, "Admins", string, "Aceptar", "Cancelar");
return 1;
}
Saludos !
Respuesta: Problema con los bucles -
Zume - 19.06.2015
PHP код:
CMD:admins(playerid, params[])
{
new
Nombre[MAX_PLAYER_NAME],
string[500],
count;
format(string, sizeof string, "ID\tNombre\n");
for(new i = 0; i <= GetPlayerPoolSize(); i++)
{
if(JugadorInfo[i][jAdmin] < 1)
continue;
GetPlayerName(i, Nombre, sizeof Nombre);
format(string, sizeof string, "%s%i\t%s\n",string,i,Nombre);
count++;
}
if(!count)
return ShowPlayerDialog(playerid, 76, DIALOG_STYLE_MSGBOX, "SIN RESULTADOS", "SIN RESULTADOS", "ACEPTAR", "CANCELAR");
else
ShowPlayerDialog(playerid, 60, DIALOG_STYLE_TABLIST_HEADERS, "Admins", string, "Aceptar", "Cancelar");
return 1;
}
Respuesta: Problema con los bucles -
Minikole - 19.06.2015
Quote:
Originally Posted by _Zume
PHP код:
CMD:admins(playerid, params[])
{
new
Nombre[MAX_PLAYER_NAME],
string[500],
count;
format(string, sizeof string, "ID\tNombre\n");
for(new i = 0; i <= GetPlayerPoolSize(); i++)
{
if(JugadorInfo[i][jAdmin] < 1)
continue;
GetPlayerName(i, Nombre, sizeof Nombre);
format(string, sizeof string, "%s%i\t%s\n",string,i,Nombre);
count++;
}
if(!count)
return ShowPlayerDialog(playerid, 76, DIALOG_STYLE_MSGBOX, "SIN RESULTADOS", "SIN RESULTADOS", "ACEPTAR", "CANCELAR");
else
ShowPlayerDialog(playerid, 60, DIALOG_STYLE_TABLIST_HEADERS, "Admins", string, "Aceptar", "Cancelar");
return 1;
}
|
wow, me ha servido ademas de para terminar el cmd, para aprender mas sobre el uso de los bucles for.
Muchas gracias _Zume