SendClientMessageToAll doesnt work -
CalvinC - 27.12.2014
Just started a fresh script, starting with OnPlayerText
pawn Код:
public OnPlayerText(playerid, text[])
{
new string[128];
format(string, sizeof(string), "%s(%s): %s", GetPlayerName(playerid), GetPlayerID(playerid), text);
SendClientMessageToAll(COLOR_WHITE, string);
return 1;
}
It gives me these:
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
error 035: argument type mismatch (argument 1)
From the format line.
Re: SendClientMessageToAll doesnt work -
jackx3rx - 27.12.2014
pawn Код:
format(string, sizeof(string), "%s(%s): %s", GetPlayerName(playerid), GetPlayerID(playerid), text);
The players ID is an integer, not a string, try this:
pawn Код:
new playername[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid,playername,sizeof(playername));
format(string, sizeof(string), "%s(%i): %s", playername, playerid, text);
SendClientMessageToAll(COLOR_WHITE,string);
- Theres no need for GetPlayerID, since 'playerid' is exactly the same.
- GetPlayerName doesn't work like you did, but I fixed it for you.
Re: SendClientMessageToAll doesnt work -
Glossy42O - 27.12.2014
Eh, not good at scripting but i'll try
new string[128];
format(string, sizeof(string), "%s(%d): %d", name, GetPlayerID(playerid), text);
SendClientMessageToAll(COLOR_WHITE, str);
I'm new so.. ehh
If not working try that..
new name[MAX_PLAYER_NAME], str[128];
format(string, sizeof(string), "%s(%s): %s", GetPlayerName(playerid), GetPlayerID(playerid), text);
SendClientMessageToAll(COLOR_WHITE, string);
or...
new string[128];
format(string, sizeof(string), "%s(%i): %d", GetPlayerName(playerid), GetPlayerID(playerid), text);
SendClientMessageToAll(COLOR_WHITE, string);
Re: SendClientMessageToAll doesnt work -
CalvinC - 27.12.2014
Thanks Jack, but i still get the warnings.
Re: SendClientMessageToAll doesnt work -
jackx3rx - 27.12.2014
pawn Код:
public OnPlayerText(playerid, text[])
{
new string[128], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string, sizeof(string), "%s(%u): %s", playername, playerid, text);
SendClientMessageToAll(-1, string);
return 1;
}
Try this, I replaced the %i with %u which is playerid, it SHOULD work. My bad before.
Re: SendClientMessageToAll doesnt work -
CalvinC - 27.12.2014
Sorry i didn't see what you wrote about "GetPlayerID(playerid)". That was the problem. :P
But how do i make the old text message not show, and make it show the new one instead?
Now it shows both.
Re: SendClientMessageToAll doesnt work -
jackx3rx - 27.12.2014
pawn Код:
public OnPlayerText(playerid, text[])
{
new string[128], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string, sizeof(string), "%s(%u): %s", playername, playerid, text);
SendClientMessageToAll(-1, string);
return 0;
}
Make it return 0 rather than 1.
Re: SendClientMessageToAll doesnt work -
CalvinC - 27.12.2014
Alright, thanks!
Re: SendClientMessageToAll doesnt work -
JaydenJason - 27.12.2014
Quote:
Originally Posted by jackx3rx
pawn Код:
public OnPlayerText(playerid, text[]) { new string[128], playername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername)); format(string, sizeof(string), "%s(%u): %s", playername, playerid, text); SendClientMessageToAll(-1, string); return 0; }
Make it return 0 rather than 1.
|
Why return 0; return 0 is used for failed commands right?
Re: SendClientMessageToAll doesnt work -
Facerafter - 27.12.2014
Quote:
Originally Posted by JaydenJason
Why return 0; return 0 is used for failed commands right?
|
They want to replace the original text, therefore the original text has to be cancelled from sending and a new has to be created & sent. The return 0; at OnPlayerText cancels the original message.