define question
#1

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);
Reply
#2

Try puting %0 instead of %s in define

If you want to add more then just continue to add more placeholders like %0 %1 ...
Reply
#3

i managed to compile it that way, but it doesn't show the name now just the text before and after %0
Reply
#4

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);
Reply
#5

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

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

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);
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)