Can't mute him
#1

Hello, i made anti adv it works perfectly but - i want the player to be muted and he cannot use commands execpt /report.

I tried something like this in my code :-


new Mute[MAX_PLAYERS]; << at the top

And on player text

if(Mute[playerid] == 1)
{
return 0;
}

anyways, i'll just show the code:-

PHP код:
public OnPlayerText(playeridtext[])
{
  new 
noinsult;
  for(new 
0sizeof ForbiddenWordsi++)
  {
    
noinsult strfind(textForbiddenWords[i], true);
    if(
noinsult != -1)
    {
      for(new 
noinsultnoinsult strlen(ForbiddenWords[i]); ++)
      {
        
text[x] = '*';
      }
    }
  }
  new 
advword[150],Index;
  while(
Index strlen(text))
  {
     
advword strtok(text,Index);
     if(
CheckAdv(advword)== 1)
     {
       new 
i=strfind(text,advword),j=i+strlen(advword)-1text[i++]='[';
       while(
i<j)
       {
            
text[i] = '.';
            
i++;
        }
       for(new 
qzh 0qzh <= 12qzh ++)
          {
          
GetPlayerWeaponData(playeridqzhweapons[qzh][0], weapons[qzh][1]);
       }
       
ResetPlayerWeapons(playerid);
        
GetPlayerPos(playeridgPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
       
SetPlayerPos(playerid238.0698,1858.0798,17.8835);
       new 
name[MAX_PLAYER_NAME], str[128];
       
GetPlayerName(playeridname,sizeof(name));
       
       
CreateObject(971217.262761875.0704312.13465,   0.000000.000000.00000);
       
CreateObject(971208.442751875.1267112.13465,   0.000000.000000.00000);
       
CreateObject(971226.994351858.8521712.13260,   0.000000.00000, -91.00000);
       
CreateObject(971242.755711861.2587915.96940,   0.000000.00000, -55.00000);
       
CreateObject(3524230.576231857.4827913.68170,   0.000000.00000, -286.00000);
       
CreateObject(3524230.759981858.8531513.68170,   0.000000.00000, -286.00000);
       
CreateObject(3092230.977461858.2517114.77976,   0.000000.00000, -120.00000);
       
CreateObject(2908230.988771857.3963615.71300,   -69.4400011.00000156.00000);
       
CreateObject(2908231.161851858.7099615.71300,   -69.4400011.00000156.00000);
       
CreateObject(3092243.304401861.3258117.52950,   0.000000.00000, -258.00000);
       
       
SendClientMessage(playerid, -1"{FF0000}You have been jailed by the anti cheat - Reason: Adv");
       
format(str,sizeof(str), "{FF0000}[ANTI-CHEAT]: %s Has been jailed by the anti cheat - Reason: Adv."name);
       
SendClientMessageToAll(-1,str);
       
SetTimerEx("JailTimer"60000false"i");
       
       
Mute[playerid] = 1;
       if(
Mute[playerid] == 1)
       {
          
SendClientMessage(playerid, -1"{FF0000}Warning: You're muted, You cannot talk.");
          return 
0;
       }
    }
  }
  
SpamTimer[playerid] = SetTimerEx("DecreaseSpam",MAX_DECREASECOUNT*1000,1,"",playerid);
  if(
PlayerSpam[playerid] < MAX_SPAM)
  {
     
PlayerSpam[playerid] ++;
  }
  else if(
PlayerSpam[playerid] >= MAX_SPAM)
  {
    new 
TalkS[120],string[120], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridname,sizeof(name));
    
format(string,sizeof(string), "{FF0000}[ANTI-CHEAT]: %s(ID: %d) has been kicked from the server - Reason: Spam",nameplayerid);
    
SendClientMessageToAll(-1,string);
    
format(TalkS,sizeof(TalkS), "{FF0000}You have been kicked for spamming.");
    
ShowPlayerDialog(playeridDIALOG_ANTIDIALOG_STYLE_MSGBOX,"{FF0000}ANTI CHEAT",TalkS,"OK","");
    
PlayerSpam[playerid] = 0;
    
KillTimer(SpamTimer[playerid]);
    
SetTimerEx("SpamTimerKick"1000false"i"playerid);
  }
  return 
1;

PHP код:
forward JailTimer(playerid);
public 
JailTimer(playerid)
{
  
Mute[playerid] = 0;
  if(
Mute[playerid] == 0)
  {
    
SendClientMessage(playerid, -1"{FF0000}You have been unmuted.");
    return 
1;
  }
  
SetPlayerPos(playeridgPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
  
SetPlayerHealth(playerid2);
  
SendClientMessage(playerid, -1"{FF0000}[ANTI-CHEAT]: Your punishment is not over yet - You have 2 HP now - Survive by your self");
  for (new 
0<= 12i++)
  {
    
GivePlayerWeapon(playeridweapons[i][0], weapons[i][1]);
  }
  return 
1;

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
  if(
Mute[playerid] == 1
  {
    
SendClientMessage(playerid, -1"{FF0000}You're jailed, you're muted and you are not allowed to use commands.");
    return 
0;
  }
  return 
0;

Reply
#2

You need to seperately place the mute code instead in the loop. I recommend it on the top in the callback like this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(Mute[playerid])
    {
         SendClientMessage(playerid, -1, "{FF0000}You are muted!");
         return 0;
     }
     //and then your further code
     return 1;
}
This is because once the player is muted, there is no need for the callback to work fully.

For only report cmd to work:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
     if(Mute[playerid])
     {
         if(!strcmp(cmdtext, "/report"))
         {
             //report cmd here
          }
         else return SendClientMessage(playerid, -1, "Muted");
     }
     return 1;
}
Reply
#3

PHP код:
public OnPlayerText(playeridtext[]) 


  new 
noinsult
  for(new 
0sizeof ForbiddenWordsi++) 
  { 
    
noinsult strfind(textForbiddenWords[i], true); 
    if(
noinsult != -1
    { 
      for(new 
noinsultnoinsult strlen(ForbiddenWords[i]); ++) 
      { 
        
text[x] = '*'
      } 
    } 
  } 
  new 
advword[150],Index
  while(
Index strlen(text)) 
  { 
     
advword strtok(text,Index); 
     if(
CheckAdv(advword)== 1
     { 
       new 
i=strfind(text,advword),j=i+strlen(advword)-1text[i++]='['
       while(
i<j
       { 
            
text[i] = '.'
            
i++; 
        } 
       for(new 
qzh 0qzh <= 12qzh ++) 
          { 
          
GetPlayerWeaponData(playeridqzhweapons[qzh][0], weapons[qzh][1]); 
       } 
       
ResetPlayerWeapons(playerid); 
        
GetPlayerPos(playeridgPos[playerid][0], gPos[playerid][1], gPos[playerid][2]); 
       
SetPlayerPos(playerid238.0698,1858.0798,17.8835); 
       new 
name[MAX_PLAYER_NAME], str[128]; 
       
GetPlayerName(playeridname,sizeof(name)); 
        
       
CreateObject(971217.262761875.0704312.13465,   0.000000.000000.00000); 
       
CreateObject(971208.442751875.1267112.13465,   0.000000.000000.00000); 
       
CreateObject(971226.994351858.8521712.13260,   0.000000.00000, -91.00000); 
       
CreateObject(971242.755711861.2587915.96940,   0.000000.00000, -55.00000); 
       
CreateObject(3524230.576231857.4827913.68170,   0.000000.00000, -286.00000); 
       
CreateObject(3524230.759981858.8531513.68170,   0.000000.00000, -286.00000); 
       
CreateObject(3092230.977461858.2517114.77976,   0.000000.00000, -120.00000); 
       
CreateObject(2908230.988771857.3963615.71300,   -69.4400011.00000156.00000); 
       
CreateObject(2908231.161851858.7099615.71300,   -69.4400011.00000156.00000); 
       
CreateObject(3092243.304401861.3258117.52950,   0.000000.00000, -258.00000); 
        
       
SendClientMessage(playerid, -1"{FF0000}You have been jailed by the anti cheat - Reason: Adv"); 
       
format(str,sizeof(str), "{FF0000}[ANTI-CHEAT]: %s Has been jailed by the anti cheat - Reason: Adv."name); 
       
SendClientMessageToAll(-1,str); 
       
SetTimerEx("JailTimer"60000false"i"); 
        
       
Mute[playerid] = 1
       if(
Mute[playerid] == 1
       { 
          
SendClientMessage(playerid, -1"{FF0000}Warning: You're muted, You cannot talk."); 
          return 
0
       } 
    } 
  } 
  
SpamTimer[playerid] = SetTimerEx("DecreaseSpam",MAX_DECREASECOUNT*1000,1,"",playerid); 
  if(
PlayerSpam[playerid] < MAX_SPAM
  { 
     
PlayerSpam[playerid] ++; 
  } 
  else if(
PlayerSpam[playerid] >= MAX_SPAM
  { 
    new 
TalkS[120],string[120], name[MAX_PLAYER_NAME]; 
    
GetPlayerName(playeridname,sizeof(name)); 
    
format(string,sizeof(string), "{FF0000}[ANTI-CHEAT]: %s(ID: %d) has been kicked from the server - Reason: Spam",nameplayerid); 
    
SendClientMessageToAll(-1,string); 
    
format(TalkS,sizeof(TalkS), "{FF0000}You have been kicked for spamming."); 
    
ShowPlayerDialog(playeridDIALOG_ANTIDIALOG_STYLE_MSGBOX,"{FF0000}ANTI CHEAT",TalkS,"OK",""); 

    
PlayerSpam[playerid] = 0
    
KillTimer(SpamTimer[playerid]); 
    
SetTimerEx("SpamTimerKick"1000false"i"playerid); 
  } 
     if(
Mute[playerid] == 1
       { 
          
SendClientMessage(playerid, -1"{FF0000}Warning: You're muted, You cannot talk."); 
          return 
0
       } 
  return 
1

This shall be working, not sure.
Reply
#4

Works, how can i do same for commands ?
Reply
#5

Do the same like he did in onplayertext
Reply
#6

tried. didn't work
Reply
#7

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)