SA-MP Forums Archive
[Help]Making a text with %d - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help]Making a text with %d (/showthread.php?tid=103561)



[Help]Making a text with %d - Danikov - 20.10.2009

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?


Re: [Help]Making a text with %d - CAR - 20.10.2009

Change the %d to %s


Re: [Help]Making a text with %d - Danikov - 20.10.2009

Ok ill see if its okay


Re: [Help]Making a text with %d - Danikov - 20.10.2009

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


Re: [Help]Making a text with %d - Correlli - 20.10.2009

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.



Re: [Help]Making a text with %d - Danikov - 20.10.2009

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


Re: [Help]Making a text with %d - dice7 - 20.10.2009

https://sampwiki.blast.hk/wiki/GetPlayerName


Re: [Help]Making a text with %d - Correlli - 20.10.2009

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?


Re: [Help]Making a text with %d - Danikov - 20.10.2009

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?


Re: [Help]Making a text with %d - Correlli - 20.10.2009

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.