1 string in a other
#1

Hello.
I like to put a string in a other string.
My first:
Код:
  format(string, sizeof (string), "%s [Rank: %d] - %d Score\n", RankNames[0],Rank[0],RankScore[0]);
second:
Код:
  format(string2, sizeof (string2), "%s [Rank: %d] - %d Score\n", RankNames[1],Rank[1],RankScore[1]);
and so on...

is this possible?
its for the dialog messagebox because i dont like to write all in a string.
Reply
#2

impossible?
Reply
#3

https://sampwiki.blast.hk/wiki/Strcat
Reply
#4

Oh, and dont bump after 1 hour!
Reply
#5

Quote:
Originally Posted by MadeMan
i had tested, but how it work?
example:

pawn Код:
new array[633];
format(string, sizeof (string), "%s [Rank: %d] - %d Score\n", RankNames[0],Rank[0],RankScore[0]);
strcat(array, string, sizeof(array));
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Ranks",array,"OK","Quit");
then i have the same.. array = string..
but i like that the strings are in one string

example

pawn Код:
new array[633];
format(string, sizeof (string), "%s [Rank: %d] - %d Score\n", RankNames[0],Rank[0],RankScore[0]);
format(string2, sizeof (string2), "%s [Rank: %d] - %d Score\n", RankNames[1],Rank[1],RankScore[1]);
string3 = string1 + string2 <- only a example..
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Ranks",string3,"OK","Quit");
Reply
#6

u might can use strins
Reply
#7

thats the same or?
Can you give me an example with my code?
Reply
#8

srry for bump <.<
but i tested strins but doesn't work why?
it comes: SERVER: Unknown command.

first test:
pawn Код:
if(strcmp(cmd,"/test",true)==0)
  {
   new array[633];
   format(string, sizeof (string), "%s [Rank: %d] - %d Score\n", RankNames[0],Rank[0],RankScore[0]);
   strins(array, string, sizeof(array));
   ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Ranks",array,"OK","Quit");
   return 1;
  }
second test:
pawn Код:
if(strcmp(cmd,"/test",true)==0)
  {
    new string[128];
    strins(array, "test", 128);
    ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Ranks",array,"OK","Quit");
    return 1;
  }
please help <.<
Reply
#9

Try out this script (Not tested):
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (!strcmp("/test", cmdtext, true))
	{
		new string[256];
		new string2[256];
		for(new i=0; i < NumberOfRank; i++) //Change "NumberOfRank" the ranks will show
		{
			format(string, sizeof(string), "%s [Rank: %d] - %d Score\n", RankNames[i], Rank[i], RankScore[i]);
			format(string2, sizeof(string2), "%s%s", string2, string);
		}
		ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Ranks",string2,"OK","Quit");
		return 1;
	}
	return 0;
}
Reply
#10

thx for your code.

but it comes a error:
Код:
error 017: undefined symbol "NumberOfRank"
if i do
Код:
new NumberOfRank;
or: for(new i=0; i < 9; i++)

ingame doesn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)