2 strings in 1
#1

Hi,
I got too long line when i tried to make this little system so i tried to do it with more lines and strings with strcat but it's not working
Код:
new string[128], text[128], text1[128],text2[128], name[MAX_PLAYER_NAME];
GetPlayerName(clickedplayerid, name, sizeof(name));
format(text1, sizeof(text1), ""COL_BLUE"DM score: "COL_WHITE"%d\n"COL_BLUE"Deaths: "COL_WHITE"%d\n"COL_BLUE"Race Score: "COL_WHITE"%d\n"COL_BLUE"Reaction test won:"COL_WHITE" %d", PlayerInfo[clickedplayerid][pKills], PlayerInfo[clickedplayerid][pDeaths], PlayerInfo[clickedplayerid][pRscore], PlayerInfo[clickedplayerid][pReaction]);
format(text2, sizeof(text2), ""COL_BLUE"Online:"COL_WHITE" %d Days %d Hours %d Minutes",PlayerInfo[clickedplayerid][pDay], PlayerInfo[clickedplayerid][pHour], PlayerInfo[clickedplayerid][pMin]);
strcat(text, text1);
strcat(text, text2);
format(string, sizeof(string), ""COL_BLUE"STATS | "COL_WHITE"%s"COL_BLUE" |", name);
ShowPlayerDialog(playerid, 1692, DIALOG_STYLE_MSGBOX, string, text, "OK", "");
Reply
#2

You do not need to create neither a second or a third string variable. You can just:

pawn Код:
format(text, sizeof(text), ""COL_BLUE"DM score: "COL_WHITE"%d\n"COL_BLUE"Deaths: "COL_WHITE"%d\n"COL_BLUE"Race Score: "COL_WHITE"%d\n"COL_BLUE"Reaction test won:"COL_WHITE" %d", PlayerInfo[clickedplayerid][pKills], PlayerInfo[clickedplayerid][pDeaths], PlayerInfo[clickedplayerid][pRscore], PlayerInfo[clickedplayerid][pReaction]);
format(text, sizeof(text), ""COL_BLUE"Online:"COL_WHITE" %d Days %d Hours %d Minutes",PlayerInfo[clickedplayerid][pDay], PlayerInfo[clickedplayerid][pHour], PlayerInfo[clickedplayerid][pMin]);
Reply
#3

It is not the truth. I fixed it, I just put [256] instead [128] on variable text...Thanks anyway
Reply
#4

Yes that is the solution for the problem, but i'm just saying you do not need 3 variables, just one. Best regards
Reply
#5

I tried your suggestion and it is not working, so how do i not need 3 variables?
Your code is writing variable text "online:..." over "dm score:...." so it is not working on that way.
Reply
#6

You are absolutely right, i have just tested and confirmed it. This is what happens when i am a cocky asshole
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)