define question - 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)
+--- Thread: define question (
/showthread.php?tid=630007)
define question -
wallee - 07.03.2017
This basically doesn't work ... the compiler just stops responding. Any idea on how can i make this work?
Код:
// On top.
#define MSG_SOMETHING "Hey %s what's up"
// Somewhere.
new string[64], name[24];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), MSG_SOMETHING, name);
SendClientMessage(playerid, COLOR_WHITE, string);
Re: define question -
w1z4rd - 07.03.2017
Try puting %0 instead of %s in define
If you want to add more then just continue to add more placeholders like %0 %1 ...
Re: define question -
wallee - 07.03.2017
i managed to compile it that way, but it doesn't show the name now just the text before and after %0
Re: define question -
ThatFag - 07.03.2017
but why do you need it when you can make it by Format i mean
Код:
new string[50];
format(string,sizeof(string), "Hey %s what's up ", name);
Re: define question -
Edwin2801 - 07.03.2017
Don't know, I'm fine
Код:
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Header size: 2484 bytes
Code size: 33756 bytes
Data size: 11848 bytes
Stack/heap size: 16384 bytes; estimated max. usage=185 cells (740 bytes)
Total requirements: 64472 bytes
Re: define question -
Sew_Sumi - 07.03.2017
Quote:
Originally Posted by Edwin2801
Don't know, I'm fine
|
Trust me, you're not... Can you please stop spam posting all over the forums...
Re: define question -
oSAINTo - 07.03.2017
The define is unnecessary, get rid of it and do this:
new string[128], name[64];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Hey %s what's up", name);
SendClientMessage(playerid, COLOR_WHITE, string);
Re: define question -
Dayrion - 07.03.2017
This is working for me too :
Код:
#define MSG_SOMETHING "Hey %s what's up"
main()
{
new str[60];
format(str, sizeof(str), MSG_SOMETHING, "TEST"); // Output: Hey TEST what's up
print(str);
}
This one too:
Код:
#define MSG_SOMETHING(%0) "Hey "%0" what's up"
main()
{
print(MSG_SOMETHING("Jina_Sichaels")); // Output: Hey Jina_Sichaels what's up
}