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



OnPlayerText problem - Zex Tan - 11.05.2013

I've add a Command called Mute ( Everyone knows it :P ), and it didn't go smoothly. The image below shows it all,



It shows 2 text, weird.

pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        message[128];
    if(PlayerInfo[playerid][Mute] == 1) return SendClientMessage(playerid, COL_RED, "[ERROR]: You are muted, you can't talk");
    {
        format(message, sizeof(message), "%s says: %s", GetName(playerid), text);
        ProxDetector(30.0, playerid, message, -1);
    }
    return 1;
}
Help please...


Re: OnPlayerText problem - ReVo_ - 11.05.2013

return 0;


Re: OnPlayerText problem - Zex Tan - 11.05.2013

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
return 0;
Uhhh.. It works

But when I muted myself, I can still type in the text in the main chat :/

How then ?


Re: OnPlayerText problem - ReVo_ - 11.05.2013

if(PlayerInfo[playerid][Mute] == 1) return SendClientMessage(playerid, COL_RED, "[ERROR]: You are muted, you can't talk"), 0;


Re: OnPlayerText problem - zDevon - 11.05.2013

You are missing the else statement. Right now you are basically sending the messages (error and their chat) if they ARE muted, while you should only be doing one of the two.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        message[128];
    if(PlayerInfo[playerid][Mute] == 1) return SendClientMessage(playerid, COL_RED, "[ERROR]: You are muted, you can't talk");
    else
    {
        format(message, sizeof(message), "%s says: %s", GetName(playerid), text);
        ProxDetector(30.0, playerid, message, -1);
    }
    return 1;
}



Re: OnPlayerText problem - Vince - 11.05.2013

Nope, return immediately ends the function.


Re: OnPlayerText problem - Zex Tan - 11.05.2013

Quote:
Originally Posted by zDevon
Посмотреть сообщение
You are missing the else statement. Right now you are basically sending the messages (error and their chat) if they ARE muted, while you should only be doing one of the two.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        message[128];
    if(PlayerInfo[playerid][Mute] == 1) return SendClientMessage(playerid, COL_RED, "[ERROR]: You are muted, you can't talk");
    else
    {
        format(message, sizeof(message), "%s says: %s", GetName(playerid), text);
        ProxDetector(30.0, playerid, message, -1);
    }
    return 1;
}
Still not working, even return 0 or 1;


Re: OnPlayerText problem - doreto - 11.05.2013

try now
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        message[128];
    if(PlayerInfo[playerid][Mute] == 1)
    {
        SendClientMessage(playerid, COL_RED, "[ERROR]: You are muted, you can't talk");
        return 0;
    }
    else
    {
        format(message, sizeof(message), "%s says: %s", GetName(playerid), text);
        ProxDetector(30.0, playerid, message, -1);
    }
    return 1;
}



Re: OnPlayerText problem - Chenko - 11.05.2013

Try this:

PHP код:
public OnPlayerText(playeridtext[])
{
    new
        
message[128];
    if(
PlayerInfo[playerid][Mute] == 1
    {
        
SendClientMessage(playeridCOL_RED"[ERROR]: You are muted, you can't talk");
        return 
0;
    }
    else
    {
        
format(messagesizeof(message), "%s says: %s"GetName(playerid), text);
        
ProxDetector(30.0playeridmessage, -1);
    }
    
    return 
0;




Re: OnPlayerText problem - Zex Tan - 11.05.2013

Quote:
Originally Posted by doreto
Посмотреть сообщение
try now
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        message[128];
    if(PlayerInfo[playerid][Mute] == 1)
    {
        SendClientMessage(playerid, COL_RED, "[ERROR]: You are muted, you can't talk");
        return 0;
    }
    else
    {
        format(message, sizeof(message), "%s says: %s", GetName(playerid), text);
        ProxDetector(30.0, playerid, message, -1);
    }
    return 1;
}
OMG thank you !!!

well, your code at
pawn Код:
if(PlayerInfo[playerid][Mute] == 1) return SendClientMessage(playerid, COL_RED, "[ERROR]: You are muted, you can't talk") return 0;
give me errors. But nevermind, I've fixed it by changing return 0 to && 0.

Anyways, Thanks !!!