strcat +rep, it's really shirt please help quick -
Lirbo - 17.01.2016
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.
Re: strcat +rep, it's really shirt please help quick -
Kqly - 17.01.2016
Try
Код:
format(DoubleString,sizeof(DoubleString),"Skill Name\tDamage Precent\tCurrent Level\tNext Level\n");
format(DoubleString,sizeof(DoubleString),"%s\ttest\ttest2\ttest3",,GetName(playerid));
Re: strcat +rep, it's really shirt please help quick -
Lirbo - 17.01.2016
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
Re: strcat +rep, it's really shirt please help quick -
Infinity - 17.01.2016
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.
Re: strcat +rep, it's really shirt please help quick -
Lirbo - 17.01.2016
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?
Re: strcat +rep, it's really shirt please help quick -
Riddick94 - 17.01.2016
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?
Re: strcat +rep, it's really shirt please help quick -
Lirbo - 17.01.2016
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));
Re: strcat +rep, it's really shirt please help quick -
Infinity - 17.01.2016
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.
Re: strcat +rep, it's really shirt please help quick -
RoboN1X - 17.01.2016
%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).
Re: strcat +rep, it's really shirt please help quick -
Infinity - 17.01.2016
Just change the order. First do the concatenation, then the formatting.