OnPlayerText problem
#1

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

return 0;
Reply
#3

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 ?
Reply
#4

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

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

Nope, return immediately ends the function.
Reply
#7

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;
Reply
#8

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;
}
Reply
#9

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;

Reply
#10

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 !!!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)