SA-MP Forums Archive
Formatting in dialog. - 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: Formatting in dialog. (/showthread.php?tid=671017)



Formatting in dialog. - CrystalMethod - 04.12.2019

All screenshots taken at the same. We ruled out different resolutions being the issue and the version of 0.3.7 we were using. The user Naldo is the only one where the dialogs display exactly the way they should.

IMAGE

Code:
command(achievements,playerid,params[])
{
	new string[400],Dodo1[40],Cargo1[40],Heli1[40],Big1[40],Army1[40],Shamal1[40],Skimmer1[40],Van1[40];
	if(PlayerInfo[playerid][Dodo] > 499) strmid(Dodo1,"{00FF00}Completed",0,20,20);
		else strmid(Dodo1,"{FF0000}Not completed",0,30,30);
	if(PlayerInfo[playerid][Cargo] > 499) strmid(Cargo1,"{00FF00}Completed",0,20,20);
	    else strmid(Cargo1,"{FF0000}Not completed",0,30,30);
	if(PlayerInfo[playerid][Helicopter] > 499) strmid(Heli1,"{00FF00}Completed",0,20,20);
	    else strmid(Heli1,"{FF0000}Not completed",0,30,30);
	if(PlayerInfo[playerid][AT300] > 499) strmid(Big1,"{00FF00}Completed",0,20,20);
		else strmid(Big1,"{FF0000}Not completed",0,30,30);
	if(PlayerInfo[playerid][Miltary] > 499) strmid(Army1,"{00FF00}Completed",0,20,20);
	    else strmid(Army1,"{FF0000}Not completed",0,30,30);
	if(PlayerInfo[playerid][Shamal] > 499) strmid(Shamal1,"{00FF00}Completed",0,20,20);
	    else strmid(Shamal1,"{FF0000}Not completed",0,30,30);
 	if(PlayerInfo[playerid][Skimmer] > 499) strmid(Skimmer1,"{00FF00}Completed",0,20,20);
	    else strmid(Skimmer1,"{FF0000}Not completed",0,30,30);
    if(PlayerInfo[playerid][Van] > 499) strmid(Van1,"{00FF00}Completed",0,20,20);
	    else strmid(Skimmer1,"{FF0000}Not completed",0,30,30);
    format(string,sizeof(string),"Dodo:\t\t%s\nCargo:\t\t%s\nHelicopter:\t%s\nAT-400:\t\t%s\nMilitary:\t\t%s\nShamal:\t\t%s\nSkimmer:\t%s\nCourier:\t%s",Dodo1,Cargo1,Heli1,Big1,Army1,Shamal1,Skimmer1,Van1);
	ShowPlayerDialog(playerid, LICENSES,DIALOG_STYLE_LIST,"Achievements",string,"Ok","");
	return 1;
}
command(licenses,playerid,params[])
{
	new string[300],dodostring[40],shamalstring[40],maverickstring[50],nevadastring[40];
	if(PlayerInfo[playerid][dLicense] == 1) strmid(dodostring,"{00FF00}Completed",0,20,20);
	    else strmid(dodostring,"{FF0000}Not Completed",0,30,30);
	if(PlayerInfo[playerid][sLicense] == 1) strmid(shamalstring,"{00FF00}Completed",0,20,20);
	    else strmid(shamalstring,"{FF0000}Not Completed",0,30,30);
	if(PlayerInfo[playerid][mLicense] == 1) strmid(maverickstring,"{00FF00}Completed",0,25,25);
		else strmid(maverickstring,"{FF0000}Not Completed",0,30,30);
	if(PlayerInfo[playerid][nLicense] == 1) strmid(nevadastring,"{00FF00}Completed",0,25,25);
		else strmid(nevadastring,"{FF0000}Not Completed",0,30,30);
	format(string,sizeof(string),"Dodo License\t\t%s\nShamal License\t\t%s\nMaverick License\t%s\nNevada License\t\t%s",dodostring,shamalstring,maverickstring,nevadastring);
	ShowPlayerDialog(playerid, LICENSES,DIALOG_STYLE_LIST,"Your Licenses",string,"Ok","");
	return 1;
}
Basically need to make sure these dialogs all display like naldos.


Re: Formatting in dialog. - SiNaGaMeR - 04.12.2019

Test that:
PHP Code:
if(PlayerInfo[playerid][Dodo] > 499Dodo1="{00FF00}Completed";
else 
Dodo1="{FF0000}Not completed"
If it works, change all of them to this type


Re: Formatting in dialog. - Calisthenics - 04.12.2019

DIALOG_STYLE_TABLIST does what you need.

But why `strmid` and not `strcat`?


Re: Formatting in dialog. - CXdur - 04.12.2019

As Calisthenics pointed out, you could check out DIALOG_STYLE_TABLIST.

I would also suggest you rewrite your code to improve its readability and make it easier to work on for others. You can also get rid of unnecessary variables and function calls (strmid).

Here's an example of how you could format the info[] parameter of the dialog:

Code:
new confirmed[] = "{199e05}Confirmed";
new notConfirmed[] = "{c40024}Not confirmed";

new info[420];
format(info, sizeof(info), 
	"Dodo license: \t\t%s\n\
	Shamal license: \t\t%s\n\
	Maverick license: \t\t%s\n\
	Nevada license: \t\t%s\n",
	PlayerInfo[playerid][dLicense] ? confirmed : notConfirmed,
	PlayerInfo[playerid][sLicense] ? confirmed : notConfirmed,
	PlayerInfo[playerid][mLicense] ? confirmed : notConfirmed,
	PlayerInfo[playerid][nLicense] ? confirmed : notConfirmed
);
I haven't tested the code above! It's only there to serve as an example of a way to better structure your code.