[Help]Making a text with %d
#1

Why when i make something with SendClientMessage/ToAll and i add in the text place %d and what i get is the text and lots of numbers why?
Reply
#2

Change the %d to %s
Reply
#3

Ok ill see if its okay
Reply
#4

LOL,When i putted %s instead of %d i was auto exited from SA-MP xD
So its not it
Reply
#5

Do you even know what %d is for?
It's an placeholder which will insert an integer (whole) number.

Example (integer):
pawn Код:
new string[16], myVariable = 5;
format(string, sizeof(string), "myInteger: %d", myVariable);
SendClientMessage(playerid, 0xFFFFFFAA, string);
This will display "myInteger: 5".

Example (float):
pawn Код:
new string[16], Float:myVariable = 5.0;
format(string, sizeof(string), "myFloat: %f", myVariable);
SendClientMessage(playerid, 0xFFFFFFAA, string);
This will display "myFloat: 5.0".

Example (string):
pawn Код:
new string[24], myVariable[8];
format(myVariable, sizeof(myVariable), "myText");
format(string, sizeof(string), "myString: %s", myVariable);
SendClientMessage(playerid, 0xFFFFFFAA, string);
This will display "myString: MyText".

You can learn more here.
Reply
#6

I Thought it used to make like a text and %d used to show the name of the player o_O

So can you help me?i want to make a text with a name,example:Player1234 stole the cash,player1234 was an example but i mean that in the text the player name will be recognised....
im currently working on a gamemode with pickups so i want to do a text and the player name will be recognised in it...

Sorry for long explanation
Reply
#7

https://sampwiki.blast.hk/wiki/GetPlayerName
Reply
#8

pawn Код:
new string[64], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s stole the cash.", playername);
SendClientMessageToAll(0xFFFFFFAA, string);
Is this what you want?
Reply
#9

Errrrm once i logged in to the server i saw that i logged in(in yellow ^^)but when i take something like a pickup and it has a text i added the %s in the end of the text and my SA Crashes but its still running o.O
Help please?
Reply
#10

Quote:
Originally Posted by Danikov
Errrrm once i logged in to the server i saw that i logged in(in yellow ^^)but when i take something like a pickup and it has a text i added the %s in the end of the text and my SA Crashes but its still running o.O
Help please?
Show your code, i guess you're not doing it correctly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)