2 strings in 1 - 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: 2 strings in 1 (
/showthread.php?tid=500517)
2 strings in 1 -
CroM256 - 13.03.2014
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", "");
Re: 2 strings in 1 -
Ruben_Alonso - 13.03.2014
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]);
Re: 2 strings in 1 -
CroM256 - 13.03.2014
It is not the truth. I fixed it, I just put [256] instead [128] on variable text...Thanks anyway
Re: 2 strings in 1 -
Ruben_Alonso - 13.03.2014
Yes that is the solution for the problem, but i'm just saying you do not need 3 variables, just one. Best regards
Re: 2 strings in 1 -
CroM256 - 13.03.2014
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.
Re: 2 strings in 1 -
Ruben_Alonso - 13.03.2014
You are absolutely right, i have just tested and confirmed it. This is what happens when i am a cocky asshole