SA-MP Forums Archive
[Ajuda] /Admins - 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: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] /Admins (/showthread.php?tid=656019)



/Admins - CSSDean - 05.07.2018

Olб! eu gostaria de alinhas meu admins,tipo toda vez que coloco 2 adms e vejo no /admins, ele fica desalinhado,por exemplo:

PHP код:
"Fulano  Nнvel 1/5   Online
"
Fulano2     Nivйl 1/5   Online
e eu gostaria que fosse assim:

PHP код:
Fulano     Nнvel 1/5     Online
Fulano2    Nнvel 1
/5     Online 
Grato a quem me ajudar <3

CMD:

PHP код:
dcmd_admins(playerid,params[]) {
#pragma unused params
//Alertar admins para quem digitar o comando /admins
if(PlayerInfo[playerid][Level] < 1){
new 
pname[MAX_PLAYER_NAME],SACSB[100];GetPlayerName(playeridpnameMAX_PLAYER_NAME);
format(SACSBsizeof(SACSB), "| CMDS-LOG | O(A) jogador(a) %s[%d] usou o comando ( /Admins )"pnameplayerid);
CallRemoteFunction("MessageToAdmins","is",yellow,SACSB);}
//Estrutura do comando /admins
new Adms[650],ADMsDialog[810],ADMsDialog2[810],Name[MAX_PLAYER_NAME],level,admscount;
for(new 
i,GetMaxPlayers();a;i++)
{
    if(
IsPlayerConnected(i))
    {
        if(
PlayerInfo[i][Level] > 0)
        {
            if(
AdmHidden[i] == false || PlayerInfo[playerid][Level] > 0)
            {
            
level PlayerInfo[i][Level];
            
GetPlayerName(iNamesizeof(Name));
            if(
admscount 15format(Admssizeof(Adms), "%s[%i]  \t%i/5 \tOnline\n%s",Name,i,level,Adms);
            
admscount++;
            }
        }
    }
}
if(
admscount 0)
format(ADMsDialogsizeof(ADMsDialog), "%s",Adms);
else
format(ADMsDialog2sizeof(ADMsDialog2), "{FF0000}Nгo hб administradores online no momento!"admscount,Adms);
ShowPlayerDialog(playerid,1000,DIALOG_STYLE_LIST,"Admins",ADMsDialog,"Fechar","");
ShowPlayerDialog(playerid,1000,DIALOG_STYLE_MSGBOX,"Admins",ADMsDialog2,"Fechar","");
return 
1;} 



Re: /Admins - ipsLuan - 05.07.2018

Pq vocк estб mostrando os dois dialogs?


Re: /Admins - CSSDean - 05.07.2018

Quote:
Originally Posted by ipsLuan
Посмотреть сообщение
Pq vocк estб mostrando os dois dialogs?
1 dos dialogs й para informa que nгo ha adms e outro para exibir a lista de adms online.


Re: /Admins - F1N4L - 05.07.2018

Funзгo:
Код:
stock FixAdminList(adm_name[], adm_level, bool:adm_online, fixed_string[])
{
	// formato: 
	// nome do admin (24 char)  nнvel x/x on/offline
	// aaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbb ccccccc

	new len_adm_name = strlen(adm_name);
	new calc_spaces = MAX_PLAYER_NAME - len_adm_name;

	fixed_string[0] = '\0';
	strcat(fixed_string, adm_name, 43);

	for(new x = 0; x < calc_spaces; ++ x)
		strcat(fixed_string, " ", 43);

	format(fixed_string, 43, "%s Nivel %d/5 %s", fixed_string, adm_level, (adm_online ? ("Online") : ("Offline")));
	return 1;
}
Uso:
Код:
new str[43]; // String que receberб a linha fixada
FixAdminList("Fulano", 1, true, str);
print(str); // Output de teste
FixAdminList("Fulano2", 3, false, str);
print(str); // Output de teste
Saнda:
Код:
Fulano                   Nivel 1/5 Online
Fulano2                  Nivel 3/5 Offline



Re: /Admins - CSSDean - 05.07.2018

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Funзгo:
Код:
stock FixAdminList(adm_name[], adm_level, bool:adm_online, fixed_string[])
{
	// formato: 
	// nome do admin (24 char)  nнvel x/x on/offline
	// aaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbb ccccccc

	new len_adm_name = strlen(adm_name);
	new calc_spaces = MAX_PLAYER_NAME - len_adm_name;

	fixed_string[0] = '\0';
	strcat(fixed_string, adm_name, 43);

	for(new x = 0; x < calc_spaces; ++ x)
		strcat(fixed_string, " ", 43);

	format(fixed_string, 43, "%s Nivel %d/5 %s", fixed_string, adm_level, (adm_online ? ("Online") : ("Offline")));
	return 1;
}
Uso:
Код:
new str[43]; // String que receberб a linha fixada
FixAdminList("Fulano", 1, true, str);
print(str); // Output de teste
FixAdminList("Fulano2", 3, false, str);
print(str); // Output de teste
Saнda:
Код:
Fulano                   Nivel 1/5 Online

Fulano2                  Nivel 3/5 Offline
como adapta isso no comando? obg!


Re: /Admins - ipsLuan - 05.07.2018

Coloca o FixAdminList dentro do loop, coloca o nome do jogador, o nнvel e true pra definir que estб online


Re: /Admins - F1N4L - 05.07.2018

Quote:
Originally Posted by CSSDean
Посмотреть сообщение
como adapta isso no comando? obg!
Fiz uma adaptaзгo na funзгo para que ela possa ser utilizada diretamente em uma caixa de diбlogo:

Comando:
Код:
dcmd_admins(playerid,params[])
{ 
	#pragma unused params 
	//Alertar admins para quem digitar o comando /admins 
	if(PlayerInfo[playerid][Level] < 1)
	{ 
		new pname[MAX_PLAYER_NAME],SACSB[100];GetPlayerName(playerid, pname, MAX_PLAYER_NAME); 
		format(SACSB, sizeof(SACSB), "| CMDS-LOG | O(A) jogador(a) %s[%d] usou o comando ( /Admins )", pname, playerid); 
		CallRemoteFunction("MessageToAdmins","is",yellow,SACSB);
	}
	
	//Estrutura do comando /admins 
	new Fixed[43], ADMsDialog[43*15], Name[MAX_PLAYER_NAME], level, admscount; 
	for(new i, a = GetPlayerPoolSize(); i <= a; i++) 
	{ 
	    if(IsPlayerConnected(i)) 
	    { 
	    	level = PlayerInfo[i][Level]; 

	        if(level > 0) 
	        { 
	            if(AdmHidden[i] == false || PlayerInfo[playerid][Level] > 0) 
	            { 
		            GetPlayerName(i, Name, sizeof(Name)); 
		            FixAdminList(Name, 1, true, Fixed);
		            strcat(ADMsDialog, Fixed);
		            admscount++; 
	        	}
	    	} 
		}
	}

	if(admscount > 0) 
		ShowPlayerDialog(playerid,1000,DIALOG_STYLE_MSGBOX,"Admins", ADMsDialog, "Fechar", ""); 
	else 
		ShowPlayerDialog(playerid,1000,DIALOG_STYLE_MSGBOX,"Admins", "{FF0000}Nгo hб administradores online no momento!", "Fechar", ""); 
	return 1;
}
Funзгo adaptada: (Adicionei a quebra de linha)
Код:
stock FixAdminList(adm_name[], adm_level, bool:adm_online, fixed_string[])
{
	// formato: 
	// nome do admin (24 char)  nнvel x/x on/offline
	// aaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbb ccccccc

	new len_adm_name = strlen(adm_name);
	new calc_spaces = MAX_PLAYER_NAME - len_adm_name;

	fixed_string[0] = '\0';
	strcat(fixed_string, adm_name, 43);

	for(new x = 0; x < calc_spaces; ++ x)
		strcat(fixed_string, " ", 43);

	format(fixed_string, 43, "%s Nivel %d/5 %s\n", fixed_string, adm_level, (adm_online ? ("Online") : ("Offline")));
	return 1;
}



Re: /Admins - CSSDean - 05.07.2018

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Fiz uma adaptaзгo na funзгo para que ela possa ser utilizada diretamente em uma caixa de diбlogo:

Comando:
Код:
dcmd_admins(playerid,params[])
{ 
	#pragma unused params 
	//Alertar admins para quem digitar o comando /admins 
	if(PlayerInfo[playerid][Level] < 1)
	{ 
		new pname[MAX_PLAYER_NAME],SACSB[100];GetPlayerName(playerid, pname, MAX_PLAYER_NAME); 
		format(SACSB, sizeof(SACSB), "| CMDS-LOG | O(A) jogador(a) %s[%d] usou o comando ( /Admins )", pname, playerid); 
		CallRemoteFunction("MessageToAdmins","is",yellow,SACSB);
	}
	
	//Estrutura do comando /admins 
	new Fixed[43], ADMsDialog[43*15], Name[MAX_PLAYER_NAME], level, admscount; 
	for(new i, a = GetPlayerPoolSize(); i <= a; i++) 
	{ 
	    if(IsPlayerConnected(i)) 
	    { 
	    	level = PlayerInfo[i][Level]; 

	        if(level > 0) 
	        { 
	            if(AdmHidden[i] == false || PlayerInfo[playerid][Level] > 0) 
	            { 
		            GetPlayerName(i, Name, sizeof(Name)); 
		            FixAdminList(Name, 1, true, Fixed);
		            strcat(ADMsDialog, Fixed);
		            admscount++; 
	        	}
	    	} 
		}
	}

	if(admscount > 0) 
		ShowPlayerDialog(playerid,1000,DIALOG_STYLE_MSGBOX,"Admins", ADMsDialog, "Fechar", ""); 
	else 
		ShowPlayerDialog(playerid,1000,DIALOG_STYLE_MSGBOX,"Admins", "{FF0000}Nгo hб administradores online no momento!", "Fechar", ""); 
	return 1;
}
Funзгo adaptada: (Adicionei a quebra de linha)
Код:
stock FixAdminList(adm_name[], adm_level, bool:adm_online, fixed_string[])
{
	// formato: 
	// nome do admin (24 char)  nнvel x/x on/offline
	// aaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbb ccccccc

	new len_adm_name = strlen(adm_name);
	new calc_spaces = MAX_PLAYER_NAME - len_adm_name;

	fixed_string[0] = '\0';
	strcat(fixed_string, adm_name, 43);

	for(new x = 0; x < calc_spaces; ++ x)
		strcat(fixed_string, " ", 43);

	format(fixed_string, 43, "%s Nivel %d/5 %s\n", fixed_string, adm_level, (adm_online ? ("Online") : ("Offline")));
	return 1;
}
vlw man,mais deu esse erro aq "
PHP код:
C:\Users\Pedro Tramontina\Desktop\Projeto\filterscripts\ladmin4v2.pwn(4797) : error 017undefined symbol "GetPlayerPoolSize" 
"
Linha do erro
PHP код:
for(new iGetPlayerPoolSize(); <= ai++) 



Re: /Admins - F1N4L - 05.07.2018

Quote:
Originally Posted by CSSDean
Посмотреть сообщение
vlw man,mais deu esse erro aq "
PHP код:
C:\Users\Pedro Tramontina\Desktop\Projeto\filterscripts\ladmin4v2.pwn(4797) : error 017undefined symbol "GetPlayerPoolSize" 
"
Linha do erro
PHP код:
for(new iGetPlayerPoolSize(); <= ai++) 
Caso nгo queira atualizar o server para 0.3.7, substitua pela funзгo anterior... (GetMaxPlayers)


Re: /Admins - ipsLuan - 05.07.2018

Faz a mudanзa na funзгo de admlevel por PlayerInfo[playerid][Level].