Optimizar Funciуn [AYUDA]
#1

Hola amigos del samp estoy haciendo una funciуn para detectar los Admins online y funciona correctamen osea esta:

PHP код:
COMMAND:admins(playeridparams[]){
new 
Strong[512];
for(new 
i=0t=GetMaxPlayers(); i<ti++){
if(
IsPlayerConnected(i) && cuenta[i][pAdmin] == 0){
ShowPlayerDialog(playeridDialog_DefaultDIALOG_STYLE_MSGBOX"{FFFF22}|Administradores OnLine|""No, hay admins Online""Aceptar""");
}
else if(
IsPlayerConnected(i) && cuenta[i][pAdmin] >= 1){
format(Strongsizeof(Strong), "%s{FFFFFF}%d.-  %s  {FF0000}AdminNivel: {FFFFFF}%d"StrongiNombre(i), cuenta[i][pAdmin]);
}
}
ShowPlayerDialog(playeridDialog_DefaultDIALOG_STYLE_MSGBOX"{FFFF22}|Administradores OnLine|"Strong"Aceptar""");
return 
1;

Mi pregunta: Como puedo modificar todo esto en menos lineas para que cumpla la misma funciуn.. (OPTIMIZAR)

saludos
Reply
#2

Код:
COMMAND:admins(playerid, params[]){
new Strong[512];
for(new i=0, t=GetMaxPlayers(); i<t; i++){ if(IsPlayerConnected(i) && cuenta[i][pAdmin] == 0){
ShowPlayerDialog(playerid, Dialog_Default, DIALOG_STYLE_MSGBOX, "{FFFF22}|Administradores OnLine|", "No, hay admins Online", "Aceptar", "");}
else if(IsPlayerConnected(i) && cuenta[i][pAdmin] >= 1){
format(Strong, sizeof(Strong), "%s{FFFFFF}%d.-  %s  {FF0000}AdminNivel: {FFFFFF}%d", Strong, i, Nombre(i), cuenta[i][pAdmin]);}}
ShowPlayerDialog(playerid, Dialog_Default, DIALOG_STYLE_MSGBOX, "{FFFF22}|Administradores OnLine|", Strong, "Aceptar", ""); return 1;}
Reply
#3

De primera el comando ya estб mal
Reply
#4

pawn Код:
#include <foreach>

CMD:admins(playerid, params[])
{
    new string[512], count;
    foreach(new i: Player)
    {
        if(cuenta[i][pAdmin] >= 1)
        {
            if(count != 0) format(string, sizeof(string), "%s\n%s (%d) - Nivel: %d", string, i, Nombre(i), cuenta[i][pAdmin]);
            else format(string, sizeof(string), "%s (%d) - Nivel: %d", i, Nombre(i), cuenta[i][pAdmin]);

            count ++;
        }
    }

    if(count == 0) ShowPlayerDialog(playerid, Dialog_Default, DIALOG_STYLE_MSGBOX, "{FFFF22}Administradores", "No hay admins online.", "Aceptar", "");
    else ShowPlayerDialog(playerid, Dialog_Default, DIALOG_STYLE_MSGBOX, "{FFFF22}Administradores", string, "Aceptar", "");
    return 1;
}
Reply
#5

Quote:
Originally Posted by aoEXE
Посмотреть сообщение
De primera el comando ya estб mal
Me puedes decir en que esta mal, me ayudaria aprender mas en pawno.... Ya que a mi, me funciona de maravilla en mi servidor
Reply
#6

Quote:
Originally Posted by Zodiaco
Посмотреть сообщение
Me puedes decir en que esta mal, me ayudaria aprender mas en pawno.... Ya que a mi, me funciona de maravilla en mi servidor
Lo corrige y todavнa lo ignoras?
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Lo corrige y todavнa lo ignoras?
Disculpa muchas gracias, solo preguntaba que esta mal... ahorita los estoy observando.. muchas gracias por tu ayuda + rept
Reply
#8

PHP код:
COMMAND:admins(playeridparams[]){
    new 
data[512],
        
result[512];
    for(new 
player=0user=GetPlayerPoolSize(); player<=userplayer++){
        if(!
cuenta[player][pAdmin]) strcat(result,"no hay administadores conectados!.");
        else{
            
format(data,sizeof(data), "nombre: %s - nivel: %d \n"Nombre(player), cuenta[player][pAdmin]);
            
strcat(result,data);
        }
    }
    
ShowPlayerDialog(playeridDIALOG_IDDIALOG_STYLE_MSGBOX"{FFFF22}|Administradores OnLine|"result"aceptar""");
    return 
true;

Reply
#9

Quote:
Originally Posted by OTACON
Посмотреть сообщение
PHP код:
COMMAND:admins(playeridparams[]){
    new 
data[512],
        
result[512];
    for(new 
player=0user=GetPlayerPoolSize(); player<=userplayer++){
        if(!
cuenta[player][pAdmin]) strcat(result,"no hay administadores conectados!.");
        else{
            
format(data,sizeof(data), "nombre: %s - nivel: %d \n"Nombre(player), cuenta[player][pAdmin]);
            
strcat(result,data);
        }
    }
    
ShowPlayerDialog(playeridDIALOG_IDDIALOG_STYLE_MSGBOX"{FFFF22}|Administradores OnLine|"result"aceptar""");
    return 
true;

Y lo haz probado? Si el primer jugar o cualquiera no es administrador, agregara "no hay administadores conectados!." cada vez.
Reply
#10

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Y lo haz probado? Si el primer jugar o cualquiera no es administrador, agregara "no hay administadores conectados!." cada vez.
no, eso sucederнa si tuviera \n, pero no lo tiene, en el dialog solo aparecerб el mensaje una vez.
saludos.

pero esto esta mejor...

PHP код:
OMMAND:admins(playeridparams[]){
    new 
data[512],
        
result[512],
        
count;
    for(new 
player=0user=GetPlayerPoolSize(); player<=userplayer++){
        if(
cuenta[player][pAdmin]>0){
            
count++;
            
format(data,sizeof(data), "%d) - nombre: %s - nivel: %d \n"countNombre(player), cuenta[player][pAdmin]);
            
strcat(data,datastrlen(data)));
        }
    }
    if(!
countstrcat(result,"no hay administadores conectados!."strlen(result)));
    else 
format(resultstrlen(data), "%s"data);
    
ShowPlayerDialog(playeridDIALOG_IDDIALOG_STYLE_MSGBOX"{FFFF22}|Administradores OnLine|"result"aceptar""");
    return 
true;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)