SA-MP Forums Archive
SendClientMessageToAll(format) problem - 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: SendClientMessageToAll(format) problem (/showthread.php?tid=498147)



SendClientMessageToAll(format) problem - Extraordinariness - 02.03.2014

I've resetted my gamemode and put in some color defines for my SCMToAll msg. Something like this
pawn Код:
public OnPlayerDisconnect(playerid, reason);
{
    new
        szString[64],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    switch(reason)
    {
        case 0: format(szString, sizeof szString, ""C_RED"%s"C_WHI" has been disconnected in the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, ""C_RED"%s"C_WHI" has been disconnected in the server. (Quit)", name);
        case 2: format(szString, sizeof szString, ""C_RED"%s"C_WHI" has been disconnected in the server. (Kicked/Banned)", name);
    }
    SendClientMessageToAll(-1, szString);
    return 1;
}
becomes...



C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(74) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(74) : warning 215: expression has no effect
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(74) : error 001: expected token: ";", but found "-identifier-"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(74) : error 017: undefined symbol "C_WHI"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(74) : fatal error 107: too many error messages on one line

Line 74:
pawn Код:
case 0: format(szString, sizeof szString, ""C_RED"%s"C_WHI" has been disconnected in the server. (Timed Out/Crashed)", name);



Respuesta: SendClientMessageToAll(format) problem - iNetX - 02.03.2014

How you have defined "C_WHI"?


Re: SendClientMessageToAll(format) problem - Twizted - 02.03.2014

pawn Код:
szString[64],
Change the , to ; and the problem should be resolved, therefore being:

pawn Код:
szString[64];



Re: SendClientMessageToAll(format) problem - Mike.FTW - 02.03.2014

Why do you put " ; " at the end of a Public ??
And not like that you embed colors. See https://sampwiki.blast.hk/wiki/Colour_Embedding


pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new
        szString[64],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    switch(reason)
    {
        case 0: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Quit)", name);
        case 2: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Kicked/Banned)", name);
    }
    SendClientMessageToAll(-1, szString);
    return 1;
}
And change
pawn Код:
#define C_WHI "{FFFFFF}"
to
pawn Код:
#define C_WHI 0xFFFFFFAA
You defined it bad.
Do the same with the other color.


Re: SendClientMessageToAll(format) problem - Extraordinariness - 02.03.2014

Quote:
Originally Posted by Twizted
Посмотреть сообщение
pawn Код:
szString[64],
Change the , to ; and the problem should be resolved, therefore being:

pawn Код:
szString[64];
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(70) : warning 217: loose indentation
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(70) : error 017: undefined symbol "name"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(70) : warning 215: expression has no effect
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(70) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(70) : error 029: invalid expression, assumed zero
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\TDScript9.pwn(70) : fatal error 107: too many error messages on one line

Line 70
pawn Код:
name[MAX_PLAYER_NAME];
Quote:

How have you defined "C_WHI"?

pawn Код:
#define C_WHI "{FFFFFF}"



Re: SendClientMessageToAll(format) problem - Konstantinos - 02.03.2014

C_WHI is defined correctly. Is C_RED defined as?
pawn Код:
#define C_RED "{FF0000}"
Quote:
Originally Posted by Twizted
Посмотреть сообщение
pawn Код:
szString[64],
Change the , to ; and the problem should be resolved, therefore being:

pawn Код:
szString[64];
He uses "," because at the next line there's 1 more variable.

Quote:
Originally Posted by Mike.FTW
Посмотреть сообщение
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new
        szString[64],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    switch(reason)
    {
        case 0: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Quit)", name);
        case 2: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Kicked/Banned)", name);
    }
    SendClientMessageToAll(-1, szString);
    return 1;
}
And change
pawn Код:
#define C_WHI "{FFFFFF}"
to
pawn Код:
#define C_WHI 0xFFFFFFAA
You defined it bad.
Do the same with the other color.
You have to use "" around the C_RED and C_WHI, otherwise they'll be taken as text. Also C_WHI must be defined as "{FFFFFF}" because it's a string, not an integer.


Re: SendClientMessageToAll(format) problem - Twizted - 02.03.2014

Oh, right! I did not even notice. Thanks for the heads up.

It must be a color define then, because the rest is ok.


Re: SendClientMessageToAll(format) problem - Extraordinariness - 02.03.2014

Quote:
Originally Posted by Mike.FTW
Посмотреть сообщение
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new
        szString[64],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    switch(reason)
    {
        case 0: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Quit)", name);
        case 2: format(szString, sizeof szString, "{C_RED}%s{C_WHI} has been disconnected in the server. (Kicked/Banned)", name);
    }
    SendClientMessageToAll(-1, szString);
    return 1;
}
And change
pawn Код:
#define C_WHI "{FFFFFF}"
to
pawn Код:
#define C_WHI 0xFFFFFFAA
You defined it bad.
Do the same with the other color.
https://sampforum.blast.hk/showthread.php?tid=250389


Re: SendClientMessageToAll(format) problem - Extraordinariness - 02.03.2014

Then if I can't really find solution, could you just give me one example? Cus it's very impossible in the wiki to backfire.


Re : SendClientMessageToAll(format) problem - TunisianoGamer - 02.03.2014

public OnPlayerDisconnect(playerid, reason)
{
new
szString[64],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
switch(reason)
{
case 0: format(szString, sizeof (szString), "{FF0000}%s{FFFFFF} has been disconnected in the server. (Timed Out/Crashed)", name);
case 1: format(szString, sizeof (szString), "{FF0000}%s{FFFFFF} has been disconnected in the server. (Quit)", name);
case 2: format(szString, sizeof (szString), "{FF0000}%s{FFFFFF} has been disconnected in the server. (Kicked/Banned)", name);
}
SendClientMessageToAll(-1, szString);
return 1;
}