SendClientMessage -
Urefeu - 07.08.2011
Hello.
I currently have a function like this:
Код:
public SendPlayerText(playerid, color, const str[], define)
{
new tmpbuf[256];
format(tmpbuf, sizeof(tmpbuf), str, define);
SendClientMessage(playerid, color, tmpbuf);
}
As you can see, it is supposed to make a SendClientMessage without a format.
There are two problems: I can just pass an argument define.
I think, but I'm not sure that I can not put arrays.
Do you have a solution for this?
Thank you.
Re: SendClientMessage -
RyDeR` - 07.08.2011
Just use this instead:
pawn Код:
#if !defined SendPlayerText
stock
__string[128]
;
#define SendPlayerText(%0,%1,%2,%3) \
(format(__string, sizeof(__string), (%2), %3), SendClientMessage((%0), (%1), __string))
#endif
Interpret it like this:
Код:
SendPlayerText(playerid, color, const string[], { Float, _ }: ...);
Re : SendClientMessage -
Urefeu - 07.08.2011
Thanks !
I have do it for SendClientMessageToAll and print :
Код:
#if !defined SendPlayerText
stock
__string[128]
;
#define SendPlayerText(%0,%1,%2,%3) \
(format(__string, sizeof(__string), (%2), %3), SendClientMessage((%0), (%1), __string))
#endif
#if !defined SendAllPlayerText
stock
__string[128]
;
#define SendAllPlayerText(%0,%1,%2) \
(format(__string, sizeof(__string), (%1), %2), SendClientMessageToAll((%1), __string))
#endif
#if !defined PrintText
stock
__string[128]
;
#define PrintText(%0,%1) \
(format(__string, sizeof(__string), (%0), %1), print(__string))
#endif
I placed the code on top of a page .inc I'll include all pages.
So I call the function: SendPlayerText(iPlayerID, VIOLET, "Admin %s : %s", szPlayerName, text[1]);.
And I get errors like this: error 017: undefined symbol "SendPlayerText".
What is the problem?
PS: Is the C you put?
Re : SendClientMessage -
Urefeu - 07.08.2011
I've it :
Код:
new FALSE = false;
#define SendPlayerText(%0,%1,%2,%3,%4) do{new _str[256]; format(_str,%2,%3,%4); SendClientMessage(%0,%1,_str);}while(FALSE)
//------------------------------------------------------------------------------
#define SendAllPlayerText(%0,%1,%2,%3) do{new _str[%1]; format(_str,%1,%2,%3); SendClientMessageToAll(%0,_str);}while(FALSE)
//------------------------------------------------------------------------------
#define PrintText(%0,%1,%2) do{new _str[%1]; format(_str,%0,%1,%2); print(_str);}while(FALSE)
Errors :
expected token: "-string end-", but found "-identifier-"
invalid array size (negative, zero or out of bounds)
empty statement
Code :
Код:
if((text[0] == ADMIN_TCHAT) && strlen(text) > 1)
{
new szPlayerName[124];
GetPlayerName(playerid, szPlayerName, 124);
if(IsPlayerAdmin(playerid))
{
for(new iPlayerID; iPlayerID < MAX_PLAYERS; iPlayerID++)
{
if(!IsPlayerConnected(iPlayerID)) continue;
if(!IsPlayerAdmin(iPlayerID)) continue;
SendPlayerText(iPlayerID, VIOLET, "Admin %s : %s", szPlayerName, text[1]);
}
}
return 0;
}
I have theses errors for the first SendPlayerText of each page...
Re : SendClientMessage -
Urefeu - 08.08.2011
Can you help me please ?
I can't continue my script because there are bugs and i can't compile...