OnPlayerText Spamming Problem -
RyderX - 30.01.2017
Hello guys, so i was wanted to show playerID in his/her name when he type anything,, like
Ryder[0]: HI i am ryder!
and scripted it and compiled without any error or warnings but it gives me that:
it spam the name 2 times, once with the id and once without the id.
here's the code:
PHP код:
public OnPlayerText(playerid, text[])
{
new gangstring[128];
format(gangstring, sizeof(gangstring), "[%d] %s",playerid, text);
SendPlayerMessageToAll(playerid, gangstring);
return 1;
}
Re: OnPlayerText Spamming Problem -
jlalt - 30.01.2017
You've to return 0 to prevent sending player original message to others, so it will be:
PHP код:
public OnPlayerText(playerid, text[])
{
new gangstring[128];
format(gangstring, sizeof(gangstring), "[%d] %s",playerid, text);
SendPlayerMessageToAll(playerid, gangstring);
return 0;
}
Re: OnPlayerText Spamming Problem -
Ultraz - 30.01.2017
Use return 0 instead of return 1 to prevent repeating or use this code
Quote:
GetPlayerName(playerid, tPlayerName, MAX_PLAYER_NAME);
format(msg, sizeof(msg), "%s: (%d) {FFFFFF}%s", tPlayerName, playerid, text);
|
Re: OnPlayerText Spamming Problem -
AndreiWow - 30.01.2017
Why do you use SendPlayerMessageToAll and also playerid?
It is SendClientMessageToAll(color, string);
You don't need a playerid if you send it to everyone..
Re: OnPlayerText Spamming Problem -
RyderX - 30.01.2017
Quote:
Originally Posted by AndreiWow
Why do you use SendPlayerMessageToAll and also playerid?
It is SendClientMessageToAll(color, string);
You don't need a playerid if you send it to everyone..
|
Quote:
Originally Posted by jlalt
You've to return 0 to prevent sending player original message to others, so it will be:
PHP код:
public OnPlayerText(playerid, text[])
{
new gangstring[128];
format(gangstring, sizeof(gangstring), "[%d] %s",playerid, text);
SendPlayerMessageToAll(playerid, gangstring);
return 0;
}
|
Quote:
Originally Posted by Ultraz
Use return 0 instead of return 1 to prevent repeating or use this code
|
Thanks all
@AndreiWow
SendPlayerMessageToAll is different than SendClientMessageToAll
Re: OnPlayerText Spamming Problem -
Beckett - 30.01.2017
Quote:
Originally Posted by AndreiWow
Why do you use SendPlayerMessageToAll and also playerid?
It is SendClientMessageToAll(color, string);
You don't need a playerid if you send it to everyone..
|
It's so that he doesn't have to format the player's name nor the color. SendPlayerMessageToAll does it automatically.
Re: OnPlayerText Spamming Problem -
AndreiWow - 30.01.2017
Quote:
Originally Posted by DaniceMcHarley
It's so that he doesn't have to format the player's name nor the color. SendPlayerMessageToAll does it automatically.
|
Oh, really didn't know about that, thanks