SA-MP Forums Archive
short - 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: short (/showthread.php?tid=566464)



short - TuNiSiAnO1 - 06.03.2015

Hello is there a way to make this code short

PHP код:
ShowPlayerDialog(playerid,5,DIALOG_STYLE_MSGBOX,"IDs","{FF0080}1 {C0C0C0}Spine\n{FF0080}2 {C0C0C0}Head\n{FF0080}3 {C0C0C0}Left upper arm\n{FF0080}4 {C0C0C0}Right upper arm\n{FF0080}5 {C0C0C0}Left hand\n{FF0080}6 {C0C0C0}Right hand\n{FF0080}7 {C0C0C0}Left thigh\n{FF0080}8 {C0C0C0}Right thigh\n{FF0080}9 {C0C0C0}Left foot\n{FF0080}10 {C0C0C0}Right foot\n{FF0080}11 {C0C0C0}Right calf\n{FF0080}12 {C0C0C0}Left calf\n{FF0080}13 {C0C0C0}Left forearm\n{FF0080}14 {C0C0C0}Right forearm\n{FF0080}15 {C0C0C0}Left clavicle\n{FF0080}16 {C0C0C0}Right clavicle\n{FF0080}17 {C0C0C0}Neck\n{FF0080}18 {C0C0C0}Jaw","Close",""); 



Re: short - CalvinC - 06.03.2015

You can use strcat, although not much reason to if that works fine.


Re: short - Vince - 06.03.2015

You can use an array and a loop to improve readability. Although the question is whether that's viable considering that it is unlikely that any further body parts will be added.


Re: short - TuNiSiAnO1 - 06.03.2015

give me an example please!, i got error "the line is too long" whatever


Respuesta: short - JuanStone - 06.03.2015

You should learn how to use strcat.

PHP код:
new string[543];
strcat(string"{FF0080}1 {C0C0C0}Spine\n");
strcat(string"{FF0080}2 {C0C0C0}Head\n");
strcat(string"{FF0080}3 {C0C0C0}Left upper arm\n");
strcat(string"{FF0080}4 {C0C0C0}Right upper arm\n");
strcat(string"{FF0080}5 {C0C0C0}Left hand\n");
strcat(string"{FF0080}6 {C0C0C0}Right hand\n");
strcat(string"{FF0080}7 {C0C0C0}Left thigh\n");
strcat(string"{FF0080}8 {C0C0C0}Right thigh\n");
strcat(string"{FF0080}9 {C0C0C0}Left foot\n");
strcat(string"{FF0080}10 {C0C0C0}Right foot\n");
strcat(string"{FF0080}11 {C0C0C0}Right calf\n");
strcat(string"{FF0080}12 {C0C0C0}Left calf\n");
strcat(string"{FF0080}13 {C0C0C0}Left forearm\n");
strcat(string"{FF0080}14 {C0C0C0}Right forearm\n");
strcat(string"{FF0080}15 {C0C0C0}Left clavicle\n");
strcat(string"{FF0080}16 {C0C0C0}Right clavicle\n");
strcat(string"{FF0080}17 {C0C0C0}Neck\n");
strcat(string"{FF0080}18 {C0C0C0}Jaw");
//--
ShowPlayerDialog(playerid5DIALOG_STYLE_MSGBOX"IDs"string"Close"""); 



AW: Respuesta: short - Kaliber - 06.03.2015

Quote:
Originally Posted by JuanStone
Посмотреть сообщение
You should learn how to use strcat.
Actually this is much faster, because you only need one operation:

Код:
static string[543] = "{FF0080}1 {C0C0C0}Spine\n \
		      {FF0080}2 {C0C0C0}Head\n\
		      {FF0080}3 {C0C0C0}Left upper arm\n\
		      {FF0080}4 {C0C0C0}Right upper arm\n\
		      {FF0080}5 {C0C0C0}Left hand\n\
		      {FF0080}6 {C0C0C0}Right hand\n\
		      {FF0080}7 {C0C0C0}Left thigh\n\
		      {FF0080}8 {C0C0C0}Right thigh\n\
		      {FF0080}9 {C0C0C0}Left foot\n\
		      {FF0080}10 {C0C0C0}Right foot\n\
		      {FF0080}11 {C0C0C0}Right calf\n\
		      {FF0080}12 {C0C0C0}Left calf\n\
		      {FF0080}13 {C0C0C0}Left forearm\n\
		      {FF0080}14 {C0C0C0}Right forearm\n\
		      {FF0080}15 {C0C0C0}Left clavicle\n";
strcat(string,"{FF0080}16 {C0C0C0}Right clavicle\n\
               {FF0080}17 {C0C0C0}Neck\n{FF0080}18 {C0C0C0}Jaw");
ShowPlayerDialog(0,5,DIALOG_STYLE_MSGBOX,"IDs",string,"Close","");
Greekz


Respuesta: AW: Respuesta: short - JuanStone - 06.03.2015

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Actually this is much faster, because you only need one operation:
What serious ? Perhaps half a millisecond faster, i like your idea.

Код:
]static const string[543] = ".."



AW: Respuesta: AW: Respuesta: short - Kaliber - 06.03.2015

Quote:
Originally Posted by JuanStone
Посмотреть сообщение
const
You can't declare it as const, because the dialog needed a non-constant string