Inserting '%' into the string
#1

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?
Reply
#2

format(name,sizeof(name), "10% off on business purchase", "%");

Try To Remove " S " and lets see ...
Reply
#3

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.
Reply
#4

Nevermind.
Reply
#5

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.
Reply
#6

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?
Reply
#7

"%%"
Reply
#8

Use it double such as "10%% off on business purchase".

This is how it works and it must be used.
Reply
#9

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
Reply
#10

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)