OnPlayerText mute.
#1

I've made my own simple mute system but I can't figure out why does the player can still send a message (along with the custom message, while muted)

Код:
public OnPlayerText(playerid, text[])
{
	if(connected[playerid] == true){
    SendClientMessage(playerid, -1 , "{c3c3c3}» You can't talk, you need to spawn first...");
    }
    else
    {
	// Chat showing the id of the player
	    new pText[144];
	    format(pText, sizeof (pText), "{c3c3c3}[%d] {FFFFFF}%s", playerid, text);
	    SendPlayerMessageToAll(playerid, pText);
	    if(Mute[playerid] == 1)
	    {
			SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You're muted therefore you can't type anything.");
			return 0;
		}
	}
    return 1;
}
Reply
#2

Put the mute code under the else bracket.
Reply
#3

ok that seems to work, but there's a weird issue

when I send 1 message for example like "t" it sends it twice?
Код:
[10:40:53] <[SN]Kartonitos> {c3c3c3}[0] {FFFFFF}asd

[10:40:53] <[SN]Kartonitos> asd
Reply
#4

Fixed, had to change return 1; to return 0;
Reply
#5

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
Fixed, had to change return 1; to return 0;
Well, you had already put return 0 for the mute. (Yes you was missing one return 0 too)
Your code is correct but the order is incorrect. You send the message and after you check if the player is mute.
PHP код:
public OnPlayerText(playeridtext[])
{
    if(
connected[playerid] == true)
    {
        
SendClientMessage(playerid, -"{c3c3c3}» You can't talk, you need to spawn first...");
        return 
0;
    }
    
    if(
Mute[playerid] == 1// If the player is mute, we don't format the message and return 0
    
{
        
SendClientMessage(playerid, -1"{c3c3c3}(INFO) You're muted therefore you can't type anything.");
        return 
0;
    }
    
    
// Chat showing the id of the player
    
new pText[144];
    
format(pTextsizeof (pText), "{c3c3c3}[%d] {FFFFFF}%s"playeridtext);
    
SendPlayerMessageToAll(playeridpText);
    return 
0;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)