#1

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",""); 
Reply
#2

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

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.
Reply
#4

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

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"""); 
Reply
#6

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
Reply
#7

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] = ".."
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)