OnPlayerText Spamming Problem
#1

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;

Reply
#2

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

Reply
#3

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);

Reply
#4

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)