There is a way to make it better?
#1

Quote:

if(!strcmp(cmd,"/Achievements", true) || !strcmp(cmd,"/Achieve",true))
{
new Achieve[19000];
format(Achieve,sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n{FF0000}2). Settings - аъвш: двгшеъ дощъощ [Uncompleted]\n{FF0000}3). Help - аъвш: дфтмъ дфчегд мтжшд [Uncompleted]\n{FF0000}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Uncompleted]\n",String);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
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,"бзш","бйием");
}
if(userdata[playerid][help] == 1)
{
format(Achieve,sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n{00FF00}1). AchieveDM - аъвш: дшщод мщшъ\n{FF0000}2). Settings - аъвш: двгшеъ дощъощ [Uncompleted]\n{00FF00}3). Help - аъвш: дфтмъ дфчегд мтжшд [Completed]\n{FF0000}{FF0000}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Uncompleted]",Achieve);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
}
if(userdata[playerid][help] == 1 && userdata[playerid][settings] == 1)
{
format(Achieve,sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n{00FF00}2). Settings - аъвш: двгшеъ дощъощ [Completed]\n{00FF00}3). Help - аъвш: дфтмъ дфчегд мтжшд [Completed]\n{FF0000}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Uncompleted]",Achieve);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
}
if(userdata[playerid][agra] == 1)
{
format(Achieve,sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n{FF0000}2). Settings - аъвш: двгшеъ дощъощ [Uncompleted]\n{FF0000}3). Help - аъвш: дфтмъ дфчегд мтжшд [Uncompleted]\n{00FF00}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Completed]",Achieve);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
}
if(userdata[playerid][agra] == 1 && userdata[playerid][settings] == 1 && userdata[playerid][help] == 1)
{
format(Achieve,sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n{00FF00}2). Settings - аъвш: двгшеъ дощъощ [Completed]\n{00FF00}3). Help - аъвш: дфтмъ дфчегд мтжшд [Completed]\n{00FF00}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Completed]",Achieve);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
}
if(userdata[playerid][agra] == 1 && 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{00FF00}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Completed]",Achieve);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
}
if(userdata[playerid][agra] == 1 && userdata[playerid][help] == 1)
{
format(Achieve,sizeof(Achieve),"{FFFFFF} ---------------- {FFFF00}Easy Achievements: {FFFFFF}----------------\n{00FF00}1). AchieveDM - аъвш: дшщод мщшъ [Completed]\n{00FF00}2). Settings - аъвш: двгшеъ дощъощ [Completed]\n{00FF00}3). Help - аъвш: дфтмъ дфчегд мтжшд [Completed]\n{00FF00}4). DoarIsrael - аъвш: щймен авшъ шйщйеп [Completed]",Achieve);
ShowPlayerDialog(playerid,7966,DIALOG_STYLE_LIST," AchieveDM - шщйоъ даъвшйн",Achieve,"бзш","бйием");
}
return 1;
}

Achievements system, If achievement is completed = 1 and you command /Achievements after you've done achievement it will show you the list "Completed Achievements" = Green Color.
UnCompleted Achievements = Red.
Trying to make it better... to many lines thanks for help !
Reply
#2

why are you using string sized 19000?
Reply
#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
#4

Quote:
Originally Posted by Variable™
Посмотреть сообщение
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.

Wow... I am really apperciate your help sir! thanks for your time ill work on it !
Means alot !
Reply
#5

Quote:
Originally Posted by Variable™
Посмотреть сообщение
Next time use http://string-functions.com/length.aspx instead of 19K string size, haha.
Just saw your post and that link. Do i have to place whole string, like:

pawn Код:
format(string,sizeof(string),"* You have earned a total of "GREEN"%s "WHITE"for completing the pizza boy job.",formatInt(PizzaBoyEarnings[playerid]+PizzaBoyTips[playerid]));
Or just the text inside to calculate it?
Reply
#6

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Just saw your post and that link. Do i have to place whole string, like:

pawn Код:
format(string,sizeof(string),"* You have earned a total of "GREEN"%s "WHITE"for completing the pizza boy job.",formatInt(PizzaBoyEarnings[playerid]+PizzaBoyTips[playerid]));
Or just the text inside to calculate it?
Just the text. Don't forget colors, like "{00FF00}" should be included in the calculation.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)