onplayertext & mute
#1

I'm working on making a mute system the system works as needed but tells them they're muted and still lets the client send a message while muted.




warning 225: unreachable code //Line 1423
Код:
public OnPlayerText(playerid, text[])
{
//===============MUTED=================================
    muted[playerid] = 1; return SendClientMessage(playerid, COLOR_ORANGE, "SERVER: You are muted");
    //===============Normal Chat===========================
    new string1[128], PName[MAX_PLAYER_NAME]; //Line 1423
	GetPlayerName(playerid, PName, sizeof(PName));
	format(string1,sizeof(string1),"{40E0D0}{%06x}%s(%d): {FFFFFF}%s",GetPlayerColor(playerid) >>> 8, PName, playerid, text);
	SendClientMessageToAll(-1, string1);
	return 0;
}
Reply
#2

Код:
if(muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "SERVER: You are muted");
Hope you got it
Reply
#3

Quote:
Originally Posted by DeathCore
Посмотреть сообщение
Код:
if(muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "SERVER: You are muted");
Hope you got it
Removed the warning but now the cmd is broke. I repped you btw.

Код:
new muted[MAX_PLAYERS];

public OnPlayerText(playerid, text[])
{
if(muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "SERVER: You are muted");
return 0;
}

CMD:mute(playerid, params[])
{
    if(eUser[playerid][e_USER_ADMIN_LEVEL] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You are not a administrator!");
    if(eUser[playerid][e_USER_ADMIN_LEVEL] >= 1)
    {
        new string[128], id, reason[128];
        if(muted[id])
        {
            muted[id] = 1;
            if(sscanf(params, "uS[128]", id, reason)) return SendClientMessage(playerid, COLOR_ERROR, "USAGE: /mute [playerid] [reason]");
            format(string, sizeof(string), "SERVER: %s has been muted by an admin (Reason: %s)", pName(id), reason);
            SendClientMessageToAll(COLOR_ORANGE, string);
        }
   	}
	return 1;
}
Reply
#4

Код:
public OnPlayerText(playerid, text[])
{
	if(muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "SERVER: You are muted");
	new string1[128], PName[MAX_PLAYER_NAME]; //Line 1423
	GetPlayerName(playerid, PName, sizeof(PName));
	format(string1,sizeof(string1),"{40E0D0}{%06x}%s(%d): {FFFFFF}%s",GetPlayerColor(playerid) >>> 8, PName, playerid, text);
	SendClientMessageToAll(-1, string1);
	return 0;
}
Reply
#5

Quote:
Originally Posted by Fratello
Посмотреть сообщение
Код:
public OnPlayerText(playerid, text[])
{
	if(muted[playerid] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "SERVER: You are muted");
	new string1[128], PName[MAX_PLAYER_NAME]; //Line 1423
	GetPlayerName(playerid, PName, sizeof(PName));
	format(string1,sizeof(string1),"{40E0D0}{%06x}%s(%d): {FFFFFF}%s",GetPlayerColor(playerid) >>> 8, PName, playerid, text);
	SendClientMessageToAll(-1, string1);
	return 0;
}
That doesn't solve my problem nor did I want it to tie into my main chat format.
Reply
#6

scm will not return 0 lol here's what you actually need to do
PHP код:
public OnPlayerText(playeridtext[])
{
    if(
muted[playerid] == 1)
    {
        
SendClientMessage(playeridCOLOR_ORANGE"SERVER: You are muted");
        return 
0;//see this
        
}
    new 
string1[128], PName[MAX_PLAYER_NAME]; //Line 1423
    
GetPlayerName(playeridPNamesizeof(PName));
    
format(string1,sizeof(string1),"{40E0D0}{%06x}%s(%d): {FFFFFF}%s",GetPlayerColor(playerid) >>> 8PNameplayeridtext);
    
SendClientMessageToAll(-1string1);
    return 
0;

see how i used return 0 afterwards to stop the message from being sent?
Reply
#7

Quote:
Originally Posted by MyUndiesSmell
Посмотреть сообщение
That doesn't solve my problem nor did I want it to tie into my main chat format.
Try this
PHP код:
CMD:mute(playeridparams[])
{
    if(
eUser[playerid][e_USER_ADMIN_LEVEL] >= 1
    {
        new 
string[128], idreason[128];
        if(
sscanf(params"uS[128]"idreason)) return SendClientMessage(playeridCOLOR_ERROR"USAGE: /mute [playerid] [reason]");
        if(
mute[id] == 0)
        {
            
muted[id] = 1;
            
format(stringsizeof(string), "SERVER: %s has been muted by an admin (Reason: %s)"pName(id), reason);
            
SendClientMessageToAll(-1string);
        }
        else return 
SendClientMessage(playerid,COLOR_ERROR,"The specified player is already muted.");
      }
    else return 
SendClientMessage(playerid, -1"You are not a administrator!");
     return 
1;

Reply
#8

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
scm will not return 0 lol here's what you actually need to do
PHP код:
public OnPlayerText(playeridtext[])
{
    if(
muted[playerid] == 1)
    {
        
SendClientMessage(playeridCOLOR_ORANGE"SERVER: You are muted");
        return 
0;//see this
        
}
    new 
string1[128], PName[MAX_PLAYER_NAME]; //Line 1423
    
GetPlayerName(playeridPNamesizeof(PName));
    
format(string1,sizeof(string1),"{40E0D0}{%06x}%s(%d): {FFFFFF}%s",GetPlayerColor(playerid) >>> 8PNameplayeridtext);
    
SendClientMessageToAll(-1string1);
    return 
0;

see how i used return 0 afterwards to stop the message from being sent?
This fixed it, thank you I repped you & everyone else that tried to help.
Reply
#9

Quote:
Originally Posted by MyUndiesSmell
Посмотреть сообщение
This fixed it, thank you I repped you & everyone else that tried to help.
hang on you made a mistake on your CMD, first of all if you did this:
PHP код:
  if(eUser[playerid][e_USER_ADMIN_LEVEL] == 0) return SendClientMessage(playeridCOLOR_ERROR"You are not a administrator!"); 
you dont need this:
PHP код:
if(eUser[playerid][e_USER_ADMIN_LEVEL] >= 1)

and then you need to use sscanf before you actually get to the cmd so use the one 1fret posted.
Reply
#10

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
hang on you made a mistake on your CMD, first of all if you did this:
PHP код:
  if(eUser[playerid][e_USER_ADMIN_LEVEL] == 0) return SendClientMessage(playeridCOLOR_ERROR"You are not a administrator!"); 
you dont need this:
PHP код:
if(eUser[playerid][e_USER_ADMIN_LEVEL] >= 1)

and then you need to use sscanf before you actually get to the cmd so use the one 1fret posted.
What's wrong with having two checks? If not admin return message if you're a admin of that level... continue with the command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)