OnPlayerText -
Infamous - 29.11.2011
Hi there, this code works fine until someone is actually muted, it will then ignore all the code and return messages as normal as if there was no code under OnPlayerText at all. I want muted players to get the message "You are currently muted and cannot type in the chatbox." and nothing else.
pawn Код:
public OnPlayerText(playerid, text[])
{
if(Muted[playerid] == 1)
return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox.");
else if(Muted[playerid] == 0)
{
new string[128], playername[MAX_PLAYER_NAME];
new PlayerColor = GetPlayerColor(playerid);
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "%s[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(PlayerColor, string);
}
return 0;
}
Any one got an idea?
Re: OnPlayerText -
Kostas' - 29.11.2011
I am not sure if this works. But I suggest you to add the muted at the Admin's enum.
It's easier to use it.
pawn Код:
public OnPlayerText(playerid, text[])
{
if(Muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox.");
else {
new
string[128],
playername[MAX_PLAYER_NAME],
PlayerColor = GetPlayerColor(playerid);
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "%s[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(PlayerColor, string);
}
return 0;
}
Re: OnPlayerText -
wumpyc - 29.11.2011
maybe
return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox."),false;
Re: OnPlayerText -
Kingunit - 29.11.2011
pawn Код:
public OnPlayerText(playerid, text[])
{
if(Muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox.");
new string[128], playername[MAX_PLAYER_NAME];
new PlayerColor = GetPlayerColor(playerid);
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "%s[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(PlayerColor, string);
return 0;
}
Is enough.
Re: OnPlayerText -
ElkaBlazer - 29.11.2011
Why would you need another if/else ?
lol....
if(Muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox.");
EDIT
Quote:
Originally Posted by Kingunit
pawn Код:
public OnPlayerText(playerid, text[]) { if(Muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox.");
new string[128], playername[MAX_PLAYER_NAME]; new PlayerColor = GetPlayerColor(playerid); GetPlayerName(playerid, playername, sizeof(playername)); format(string, sizeof(string), "%s[%d]: {FFFFFF}%s", playername, playerid, text); SendClientMessageToAll(PlayerColor, string);
return 0; }
Is enough.
|
IS RIGHT
Re: OnPlayerText -
Kostas' - 29.11.2011
Quote:
Originally Posted by ElkaBlazer
Why would you need another if/else ?
lol....
|
Both of ways works. Kingunit's code is more shortly
Re: OnPlayerText -
Infamous - 29.11.2011
Thanks for all the replies guys but my problem still exists using the code below.
pawn Код:
public OnPlayerText(playerid, text[])
{
if(Muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox.");
new string[128], playername[MAX_PLAYER_NAME];
new PlayerColor = GetPlayerColor(playerid);
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "%s[%d]: {FFFFFF}%s", playername, playerid, text);
SendClientMessageToAll(PlayerColor, string);
return 0;
}
I just need to stop the default text from displaying when a player is muted, it works fine until 'Muted' is set to '1'. After that it allows the chat messages to carry on displaying.
Re: OnPlayerText -
Vince - 29.11.2011
Replace this:
pawn Код:
if(Muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox.");
With this (notice the 0 at the end):
pawn Код:
if(Muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You are currently muted and cannot type in the chatbox."), 0;
You people need to learn what return values are for. SendClientMessage returns 1 at all times (or so I assume), and when anything other than 0 is returned in OnPlayerText it will send the text through.
Re: OnPlayerText -
Infamous - 29.11.2011
Thanks Vince, never really had a problem with returns until now so lesson learnt lol.