SendClientMessageToAll doesnt work
#1

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

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

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

Thanks Jack, but i still get the warnings.
Reply
#5

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

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

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

Alright, thanks!
Reply
#9

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?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)