SA-MP Forums Archive
OnPlayerText mute. - 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 mute. (/showthread.php?tid=649381)



OnPlayerText mute. - ivndosos - 08.02.2018

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



Re: OnPlayerText mute. - aoky - 08.02.2018

Put the mute code under the else bracket.


Re: OnPlayerText mute. - ivndosos - 08.02.2018

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



Re: OnPlayerText mute. - ivndosos - 08.02.2018

Fixed, had to change return 1; to return 0;


Re: OnPlayerText mute. - Dayrion - 08.02.2018

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;