SA-MP Forums Archive
Ayuda comando - 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: Ayuda comando (/showthread.php?tid=547467)



Ayuda comando - Alvaro89 - 22.11.2014

Hola a todos. Hace un tiempo alguien paso una funcion para leer el contenido de un archivo txt. Dentro de ese txt tiene varios nombre, entonces al usar el comando X se abre en una Box una lista con los names que estan alli.

Hasta alli todo bien. pero me gustaria agregarle algo al lado del nombre. Y no se como hacer, por que no le veo q lleve %s

Aqui el codigo

PHP код:
CMD:admins(playeridparams[])
{
    new 
f[256];
    if(
GZJugador[playerid][PGang] > 0)
    {
       
format(f256"Admins/%d.txt",PlayerInfo[playerid][pAdmin]);
       new 
File:Warns fopen(fio_read);
       if(!
Warns) return 0;
       new 
str[128],warnstr[500],len;
       while((
len fread(Warns,str)))
       {
          
str[len] = 0;
          
strcat(warnstr,str);
       }
       
fclose(Warns);
       if(
warnstr[0] != EOS)
       {
          
ShowPlayerDialog(playerid00"Total Admins"warnstr"Ok""");
       }
    }
    return 
1;

Es como un comando de Admin online. Pero en vez q aparezcan solo los conectados. aparecen todos los de la lista del .txt

EDITO

Es asi como se ve el comando (Ver imagen)


Edito 2

Vi un codigo. q detecta si el jugador esta on o off. Entonces sale al lado del name un texto diciento el estado.




Este es el codigo y me gustaria implementarlo al comando Admins

Quote:

if(strcmp(cmd, "/leaders", true) == 0)
{
new file = ini_openFile("gamefiles/log/leaders.ini");
ini_getString(file,"MARYA",pLeaders[0]);
new ttextt[32];
if(IsPlayerConnected(GetPlayerID(pLeaders[0])))
{
ttextt = "[{22ff00}Online{F2EEF0}]";
}
else if(!IsPlayerConnected(GetPlayerID(pLeaders[0])))
{
ttextt = "[{ff001c}Offline{F2EEF0}]";
}
format(string, sizeof(string), "Мэрия: %s %s", pLeaders[0],ttextt);
ShowPlayerDialog(playerid,8822,DIALOG_STYLE_MSGBOX ,"Лидеры организаций",string,"Скрыть","");
ini_closeFile(file);
return 1;
}




Re: Ayuda comando - spell - 23.11.2014

pawn Код:
CMD:admins(playerid, params[])
{
    new f[256];
    if(GZJugador[playerid][PGang] > 0)
    {
       format(f, 256, "Admins/%d.txt",PlayerInfo[playerid][pAdmin]);
       new File:Warns = fopen(f, io_read);
       if(!Warns) return 0;
       new str[128],warnstr[500],len;
       while((len = fread(Warns,str)))
       {
          str[len] = 0;
          str[len-1] = 0; // Borramos el salto de linea que trae fread por el archivo.

          strcat(warnstr, str); // En primer lugar, agregamos el nombre.

          for (new i, j = GetMaxPlayers(); i  < j; i++) if (IsPlayerConnected(i)) { // Recorremos todos los jugadores para ver si el de la lista estб conectado.
               new name[24]; GetPlayerName(i, name, 24);
               if (!strcmp(name, str, false, strlen(name))) {
                   // El jugador estб conectado. Le agregamos [Online] a su nombre!
                   strcat(warnstr, " [Online]");
                   i = MAX_PLAYERS; // Detenemos el loop, el jugador ya se encontrу.
               }
           }
           // Ya terminamos. Podйs agregar un salto de linea (si es que el archivo no lo trae) asi:
           strcat(warnstr, "\n");
         
       }
       fclose(Warns);
       if(warnstr[0] != EOS)
       {
          ShowPlayerDialog(playerid, 0, 0, "Total Admins", warnstr, "Ok", "");
       }
    }
    return 1;
}



Respuesta: Ayuda comando - Alvaro89 - 23.11.2014

Joder amigo. Eh llevado meses tras meses intentando hacer esto. Mil gracias y muy bien explicado.
Si fuese mujer te diria "Te Amodoro" XD