SA-MP Forums Archive
OnPlayerText Spamming 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: OnPlayerText Spamming Problem (/showthread.php?tid=627631)



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(playeridtext[])

   new 
gangstring[128];
   
format(gangstringsizeof(gangstring), "[%d] %s",playerid,  text);
   
SendPlayerMessageToAll(playeridgangstring);
   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(playeridtext[]) 
{  
   new 
gangstring[128]; 
   
format(gangstringsizeof(gangstring), "[%d] %s",playerid,  text); 
   
SendPlayerMessageToAll(playeridgangstring); 
   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(playeridtext[]) 
{  
   new 
gangstring[128]; 
   
format(gangstringsizeof(gangstring), "[%d] %s",playerid,  text); 
   
SendPlayerMessageToAll(playeridgangstring); 
   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