SA-MP Forums Archive
How i make it smaller ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How i make it smaller ? (/showthread.php?tid=635222)



How i make it smaller ? - StR_MaRy - 03.06.2017

Hey guys any idea how to make this smaller ?

this stock activate's command /factions

Код HTML:
stock ShowFactions(playerid)
{
	new stringz2[MAX_STRING], stringz3[MAX_STRING];
 	if(DynamicFactions[1][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", GetFactionMembers(1), DynamicFactions[1][fMaxMembers], DynamicFactions[1][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"{FFFFFF}[%d/%d] %s\n", GetFactionMembers(1), DynamicFactions[1][fMaxMembers], DynamicFactions[1][fName]);
	}
 	if(DynamicFactions[2][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(2), DynamicFactions[2][fMaxMembers], DynamicFactions[2][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(2), DynamicFactions[2][fMaxMembers], DynamicFactions[2][fName]);
	}
	if(DynamicFactions[3][fApplication] > 0)
	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(3), DynamicFactions[3][fMaxMembers], DynamicFactions[3][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(3), DynamicFactions[3][fMaxMembers], DynamicFactions[3][fName]);
	}
 	if(DynamicFactions[4][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(4), DynamicFactions[4][fMaxMembers], DynamicFactions[4][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(4), DynamicFactions[4][fMaxMembers], DynamicFactions[4][fName]);
	}
 	if(DynamicFactions[5][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(5), DynamicFactions[5][fMaxMembers], DynamicFactions[5][fName]);
	}
	else
	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(5), DynamicFactions[5][fMaxMembers], DynamicFactions[5][fName]);
	}
 	if(DynamicFactions[6][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(6), DynamicFactions[6][fMaxMembers], DynamicFactions[6][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(6), DynamicFactions[6][fMaxMembers], DynamicFactions[6][fName]);
	}
 	if(DynamicFactions[8][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(8), DynamicFactions[8][fMaxMembers], DynamicFactions[8][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(8), DynamicFactions[8][fMaxMembers], DynamicFactions[8][fName]);
	}
 	if(DynamicFactions[9][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(9), DynamicFactions[9][fMaxMembers], DynamicFactions[9][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(9), DynamicFactions[9][fMaxMembers], DynamicFactions[9][fName]);
	}
 	if(DynamicFactions[10][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(10), DynamicFactions[10][fMaxMembers], DynamicFactions[10][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(10), DynamicFactions[10][fMaxMembers], DynamicFactions[10][fName]);
	}
 	if(DynamicFactions[11][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(11), DynamicFactions[11][fMaxMembers], DynamicFactions[11][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(11), DynamicFactions[11][fMaxMembers], DynamicFactions[11][fName]);
	}
 	if(DynamicFactions[12][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(12), DynamicFactions[12][fMaxMembers], DynamicFactions[12][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(12), DynamicFactions[12][fMaxMembers], DynamicFactions[12][fName]);
	}
 	if(DynamicFactions[13][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(13), DynamicFactions[13][fMaxMembers], DynamicFactions[13][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(13), DynamicFactions[13][fMaxMembers], DynamicFactions[13][fName]);
	}
 	if(DynamicFactions[14][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]", stringz3, GetFactionMembers(14), DynamicFactions[14][fMaxMembers], DynamicFactions[14][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s", stringz3, GetFactionMembers(14), DynamicFactions[14][fMaxMembers], DynamicFactions[14][fName]);
	}
	if(DynamicFactions[15][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(15), DynamicFactions[15][fMaxMembers], DynamicFactions[15][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(15), DynamicFactions[15][fMaxMembers], DynamicFactions[15][fName]);
	}
 	if(DynamicFactions[16][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(16), DynamicFactions[16][fMaxMembers], DynamicFactions[16][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(16), DynamicFactions[16][fMaxMembers], DynamicFactions[16][fName]);
	}
	if(DynamicFactions[17][fApplication] > 0)
	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(17), DynamicFactions[17][fMaxMembers], DynamicFactions[17][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(17), DynamicFactions[17][fMaxMembers], DynamicFactions[17][fName]);
	}
 	if(DynamicFactions[18][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(18), DynamicFactions[18][fMaxMembers], DynamicFactions[18][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(18), DynamicFactions[18][fMaxMembers], DynamicFactions[18][fName]);
	}
 	if(DynamicFactions[19][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(19), DynamicFactions[19][fMaxMembers], DynamicFactions[19][fName]);
	}
	else
	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(19), DynamicFactions[19][fMaxMembers], DynamicFactions[19][fName]);
	}
 	if(DynamicFactions[20][fApplication] > 0)
  	{
		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s {00FF00}[aplicatii deschise]\n", stringz3, GetFactionMembers(20), DynamicFactions[20][fMaxMembers], DynamicFactions[20][fName]);
	}
	else
	{
 		format(stringz2, sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s\n", stringz3, GetFactionMembers(20), DynamicFactions[20][fMaxMembers], DynamicFactions[20][fName]);
	}
	ShowPlayerDialog(playerid, DIALOG_FACTIONS, DIALOG_STYLE_LIST,"Factions", stringz2, "Select", "Cancel");
	return 1;
}



Re: How i make it smaller ? - Banditul18 - 03.06.2017

PHP код:
ShowFactions(playerid){
    new  
stringz2[MAX_STRING];
    for(new 
1sizeof(DynamicFactions); i++){
        
format(stringz2sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s %s\n"stringz2,GetFactionMembers(i), DynamicFactions[i][fMaxMembers], DynamicFactions[i][fName] , (DynamicFactions[i][fApplication] > 0) ? ("{00FF00}[aplicatii deschise]") : (""));
    }
    
ShowPlayerDialog(playeridDIALOG_FACTIONSDIALOG_STYLE_LIST,"Factions"stringz2"Select""Cancel");

Something like this? (not tested)


Re: How i make it smaller ? - StR_MaRy - 03.06.2017

Quote:
Originally Posted by Banditul18
Посмотреть сообщение
PHP код:
ShowFactions(playerid){
    new  
stringz2[MAX_STRING];
    for(new 
1sizeof(DynamicFactions); i++){
        
format(stringz2sizeof(stringz2),"%s{FFFFFF}[%d/%d] %s %s\n"stringz2,GetFactionMembers(i), DynamicFactions[i][fMaxMembers], DynamicFactions[i][fName] , (DynamicFactions[i][fApplication] > 0) ? ("{00FF00}[aplicatii deschise]") : (""));
    }
    
ShowPlayerDialog(playeridDIALOG_FACTIONSDIALOG_STYLE_LIST,"Factions"stringz2"Select""Cancel");

Something like this? (not tested)
yea but is not working cause dynamicfactions is from a system that read factions from DB and you can't read it in that mode anyw thx i solved


Re: How i make it smaller ? - Banditul18 - 03.06.2017

You can , it's same thing as you used but it's only use a for instead of multiple if's . So practically it's same thing but more tied up. The data it's there.


Re: How i make it smaller ? - Kane - 03.06.2017

Just loop through the factions?

PHP код:
stock ShowFactions(playerid)
{
     new 
string[256];
     
string[0] = EOS;
     for(new 
1sizeof(DynamicFactions); i++){
           if(
DynamicFactions[i][fApplication] > 0){
                  
format(stringsizeof(string), "%s{FFFFFF}[%d/%d] %s\n"stringGetFactionMembers(i), DynamicFactions[i][fMaxMembers], DynamicFactions[i][fName]);
                }
         }
         
ShowPlayerDialog(playeridDIALOG_FACTIONSDIALOG_STYLE_LIST"Factions"string"Select""Cancel");
        return 
1;

Try that?

Edit: Didn't read that you solved!!!