strcat +rep, it's really shirt please help quick
#1

PHP код:
format(DoubleString,sizeof(DoubleString),"Skill Name\tDamage Precent\tCurrent Level\tNext Level\n",GetName(playerid));
strcat(DoubleString,"%s\ttest\ttest2\ttest3"); 
I want the %s in the strcat to display the player name, why it doesn't work? I tried to put the GetName(playerid) in the strcat as well:
strcat(DoubleString,"%s\ttest\ttest2\ttest3",GetNa me(playerid));

btw GetName is a stock of GetPlayerName so there's no problem with my GetName function just pretend it's GetPlayerName.
Reply
#2

Try
Код:
format(DoubleString,sizeof(DoubleString),"Skill Name\tDamage Precent\tCurrent Level\tNext Level\n"); 
format(DoubleString,sizeof(DoubleString),"%s\ttest\ttest2\ttest3",,GetName(playerid));
Reply
#3

Quote:
Originally Posted by Kqly
Посмотреть сообщение
Try
Код:
format(DoubleString,sizeof(DoubleString),"Skill Name\tDamage Precent\tCurrent Level\tNext Level\n"); 
format(DoubleString,sizeof(DoubleString),"%s\ttest\ttest2\ttest3",,GetName(playerid));
ehh thanks but it's not working it's giving me an error because of the double "," and why would it work anyway? you're just defining the DoubleString again as something else
Reply
#4

It's not really a surprise your code doesn't show the player name. You first try to insert the name using format, after which you concatenate a string in which you need the player name. Thus, during the format step there's no place for the name to be inserted.
Reply
#5

Quote:
Originally Posted by Infinity
Посмотреть сообщение
It's not really a surprise your code doesn't show the player name. You first try to insert the name using format, after which you concatenate a string in which you need the player name. Thus, during the format step there's no place for the name to be inserted.
so i can't insert the name or?
Reply
#6

Quote:
Originally Posted by Lirbo
Посмотреть сообщение
so i can't insert the name or?
GetName() function is called in your "format" not in your "strcat". How do you expect player's name to be printed out in that case?
Reply
#7

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
GetName() function is called in your "format" not in your "strcat". How do you expect player's name to be printed out in that case?
so that means you didnt read the whole post.
I said i tried both

example:
strcat(DoubleString,"%s",GetName(playerid));
Reply
#8

Quote:
Originally Posted by Lirbo
Посмотреть сообщение
so that means you didnt read the whole post.
I said i tried both

example:
strcat(DoubleString,"%s",GetName(playerid));
You're being a tad rude.

Anyhow, it seems you didn't understand what I said. You're doing it in the wrong order. Formatting is used to insert values into strings. However, the place you want the name to be inserted is not present when you format it, you add it afterwards when you use strcat.
Reply
#9

%s wont work in strcat as it's for format() function. You want to do this instead:
Код:
DoubleString = "Skill Name\tDamage Precent\tCurrent Level\tNext Level"; // I think this is must be first, as it's header
format(DoubleString,sizeof(DoubleString),"%s\n%s\ttest\ttest2\ttest3",DoubleString,GetName(playerid));
the first %s is for DoubleString (the header string), and \n for new line, then %s is the player name. Repeat the 2nd line for the dialog content for the list (not header).
Reply
#10

Just change the order. First do the concatenation, then the formatting.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)