OnPlayerText >> MUTE COMMAND <<
#1

I'm creating a mute command, it works great, but the only problem, is that i can't get it to "work" fully(OnPlayerText problem)
I keep getting this error, and this warning:
Код:
test.pwn(1010) : error 029: invalid expression, assumed zero
test.pwn(1016) : warning 225: unreachable code
Here's the OnPlayerText script ->
pawn Код:
//I have other scripts here..
    if(PlayerInfo[playerid][pMuted] == 0)
    format(string, sizeof(string), "[%d]%s: %s", playerid, name, text);
    SendClientMessageToAll(-1, string);
    else //Line 1010
    {
    if(PlayerInfo[playerid][pMuted] == 1)
    SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");
    return 0;
    }
    return 1; //Line 1016
}
I tried removing the "if(PlayerInfo[playerid][pMuted] == 0)", but they i still couldn't use the "return 0;"
Reply
#2

pawn Код:
public OnPlayerText( playerid, text[ ] )
{
    // code..
   
    if(!PlayerInfo[playerid][pMuted])
    {
        format(string, sizeof(string), "[%d]%s: %s", playerid, name, text);
        SendClientMessageToAll(-1, string);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");
        return 0;
    }
    return 0; // Return 0 at the end as well to prevent the default chat from being sent
}
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
public OnPlayerText( playerid, text[ ] )
{
    // code..
   
    if(!PlayerInfo[playerid][pMuted])
    {
        format(string, sizeof(string), "[%d]%s: %s", playerid, name, text);
        SendClientMessageToAll(-1, string);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");
        return 0;
    }
    return 0; // Return 0 at the end as well to prevent the default chat from being sent
}
Thanks works now, but now another problem comes, when i selected the team the chat shows white..Well, yeah, -1 = white.
But could there be a way to make it "SetTeamColor" or something?
xd
I have these two team-color defines ->
pawn Код:
#define USA_Army_COLOUR 0x0000BBAA
#define Russian_Spetsnaz_COLOUR 0xCC3333AA
Teams are called "USA_Army" and "Russian_Spetsnaz"..


EDIT:
Haha, fixed it!
pawn Код:
if(!PlayerInfo[playerid][pMuted])
    {
        format(string, sizeof(string), "[%d]%s: {FFFFFF}%s", playerid, name, text);
        if(GetPlayerTeam(playerid) == USA_Army)
    {
        SendClientMessageToAll(USA_Army_COLOUR, string);
    }
        else if(GetPlayerTeam(playerid) == Russian_Spetsnaz)
    {
        SendClientMessageToAll(Russian_Spetsnaz_COLOUR,string);
    }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");
        return 0;
    }
    return 0; // Return 0 at the end as well to prevent the default chat from being sent
}
Thanks Konstantinos, added a +rep to you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)