There is a way to make it better?
#3

Your string size:
Код:
new Achieve[19000];
Your whole code size, including the braces and all: 4229
Calculating one of your dialogs content, it is 402, let's say 500, but not 19K!

Have a look at SA-MP's limits: https://sampwiki.blast.hk/wiki/Limits
Код:
Info (Main text) 	4096
You can't even have a dialog with more than 4K characters, which means, if a dialog will ever exceed that, you should use more than one dialog.

Furthermore, you're showing the dialog multiple times under different conditions, e.g.

It'll show a dialog under this condition:
Код:
if(userdata[playerid][settings] == 1)
And this:
Код:
if(userdata[playerid][help] == 1)
And so on... till the last condition.

Further from that, indent your code, so not that:
Код:
if(userdata[playerid][settings] == 1)
{
format(Achieve,sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n{00FF00}2). Settings - аъвш: двгшеъ дощъощ [Completed]\n{FF0000}3). Help - аъвш: дфтмъ дфчегд мтжшд [Uncompleted]\n{FF0000}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Uncompleted]",Achieve);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
}
But this:
Код:
if(userdata[playerid][settings] == 1)
{
	format(Achieve, sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n\
	{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n\
	{00FF00}2). Settings - аъвш: двгшеъ дощъощ [Completed]\n\
	{FF0000}3). Help - аъвш: дфтмъ дфчегд мтжшд [Uncompleted]\n\
	{FF0000}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Uncompleted]", Achieve);
	ShowPlayerDialog(playerid, 7966, DIALOG_STYLE_LIST, " AchieveDM - шщйоъ даъвшйн", Achieve, "бзш", "бйием");
}
Also you can simply do:
Код:
if(userdata[playerid][settings])
Instead of:
Код:
if(userdata[playerid][settings] == 1)
The same work it does.

This is how you can simply do it:
Код:
if(!strcmp(cmd, "/Achievements", true) || !strcmp(cmd, "/Achieve", true))
{
	new Achieve[500];
	format(Achieve, sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n\
	{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n\
	{00FF00}2). Settings - аъвш: двгшеъ дощъощ [%s]\n\
	{FF0000}3). Help - аъвш: дфтмъ дфчегд мтжшд [%s]\n\
	{FF0000}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [%s]",
	(userdata[playerid][settings] == 1) ? ("Completed") : ("Incomplete"),
	(userdata[playerid][help] == 1) ? ("Completed") : ("Incomplete"),
	(userdata[playerid][agra] == 1) ? ("Completed") : ("Incomplete"));
	ShowPlayerDialog(playerid, 7966, DIALOG_STYLE_LIST, " AchieveDM - шщйоъ даъвшйн", Achieve, "бзш", "бйием");

	return 1;
}
Better right? Use ternay operator instead of if condition if you want to sum everything up together.

Ternay Operator:

(a == b) ? Yes : No

a: is the variable you're checking it's value. e.g. userdata[playerid][settings]
b: is the value/number. Just like if (condition == 1) where 1 is the value.
Yes: if a equals b.
No: if a != b.


Next time use http://string-functions.com/length.aspx instead of 19K string size, haha.
Reply


Messages In This Thread
There is a way to make it better? - by SaMuRy - 27.09.2018, 12:23
Re: There is a way to make it better? - by CodeStyle175 - 27.09.2018, 13:27
Re: There is a way to make it better? - by Variable™ - 27.09.2018, 14:06
Re: There is a way to make it better? - by SaMuRy - 27.09.2018, 14:56
Re: There is a way to make it better? - by KinderClans - 27.09.2018, 14:59
Re: There is a way to make it better? - by Variable™ - 27.09.2018, 15:32

Forum Jump:


Users browsing this thread: 2 Guest(s)