Inserting '%' into the string -
dominik523 - 19.11.2013
Hello everybody! I wanted to insert a symbol % into the string, but I get each time some strange numbers? Here's the code I tried:
Код:
format(name,sizeof(name), "10%s off on business purchase", "%");
How can I insert it?
Re: Inserting '%' into the string -
Ayham - 19.11.2013
format(name,sizeof(name), "10% off on business purchase", "%");
Try To Remove " S " and lets see ...
Re: Inserting '%' into the string -
Pottus - 19.11.2013
I usually just use %c then get the ascii value here
http://www.asciitable.com/
But i'm not sure if that character will show in SendClientMessage(); would have to test it.
AW: Inserting '%' into the string -
Skimmer - 19.11.2013
Nevermind.
Re: Inserting '%' into the string -
PrivatioBoni - 19.11.2013
You add the symbol/variable name there. For instance:
pawn Код:
format(string,sizeof(string),"Skin set to %d",skinid);
Don't get put off by the %d, it's just decimal as opposed to string. Maybe I misunderstood.
Re: Inserting '%' into the string -
dominik523 - 19.11.2013
Pottus, so something like this?
Код:
format(string,sizeof(string), "You've used your coupon and got 10%c discount on purchase.", 25);
SendClientMessage(playerid, COLOR_WHITE, string);
you need to use hex number, right?
Re: Inserting '%' into the string -
Macluawn - 19.11.2013
"%%"
Re: Inserting '%' into the string -
Konstantinos - 19.11.2013
Use it double such as "10%% off on business purchase".
This is how it works and it must be used.
Re: Inserting '%' into the string -
dominik523 - 19.11.2013
I've already tried like that, and it didn't work. I will try to do it again. Thanks
EDIT: I tried this:
Код:
format(string,sizeof(string), "You got 10%s discount", "%%");
This one worked. Thank you again
Re: Inserting '%' into the string -
Pottus - 19.11.2013
It won't work you can send the percent symbol in a client message test this.
#include <a_samp>
#include <zcmd>
pawn Код:
CMD:testpercent(playerid, arg[])
{
new line[128];
format(line, sizeof(line), "You get 10%% off!");
SendClientMessage(playerid, -1, line);
print(line);
format(line, sizeof(line), "You get 10%c off!", 37);
SendClientMessage(playerid, -1, line);
print(line);
return 1;
}
Prints in game:
You get off!
You get off!
(Better believe I get off)
The print however is this
[16:01:54] You get %10 off!
[16:01:54] You get %10 off!