Raised This Month: $12 Target: $400
 3% 

Solved Mute players dont work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 07-24-2021 , 04:24   Mute players dont work
Reply With Quote #1

Everything works but when I unmute a player so he can talk it dosn't, he still cant talk

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

#define PLUGIN "123"
#define VERSION "1.0"
#define AUTHOR "1234"

new bool:is_muted[33];
new 
g_maxplayers;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_forward(FM_Voice_SetClientListening"fwd_voice_setclientlistening")
    
register_clcmd("say /mic""cmdMenuMic"ADMIN_ALL);

        
g_maxplayers get_maxplayers();
}

public 
client_putinserver(id){
        
is_muted[id] = true;
}

public 
cmdMenuMic(id){
    
    if(!
is_user_connected(id)){
        return 
PLUGIN_HANDLED;
    }
    
    if(
get_user_flags(id) & ADMIN_BAN || get_user_team(id) == 2){
        
        static 
menuname[32], inum[7];

        
menu menu_create("\yGive mic""handled_give_mic");
    
        for (
1<= g_maxplayersi++){
        
            if (!
is_user_connected(i) || is_user_bot(i) || get_user_team(i) != || !is_user_alive(i)){
                continue;
            }
            
            
get_user_name(inamecharsmax(name));
            
num_to_str(inumcharsmax(num));
            
menu_additem(menunamenum);
        }
                            
        
menu_display(idmenu);
    }
    
    return 
PLUGIN_HANDLED;
}


public 
handled_give_mic(idmenuitem){
    
    if (
item == MENU_EXIT){
        
        
menu_destroy(menu);
        return;
    }
    
    static 
accessnum[7], target;
    
menu_item_getinfo(menuitemaccessnumcharsmax(num), __access);
    
    
target str_to_num(num);
    
    if (
is_user_connected(id)){
        
        if(
is_muted[id]){        
            
is_muted[id] = false;
            
client_print(0print_chat"No longer muted");
        }
        else{
            
is_muted[id] = true;
            
client_print(0print_chat"Muted again");
        }
    }
    
    else{
        
chatcolor(id"User isn't in the server");
        
menu_destroy(menu);
    }
}


public 
fwd_voice_setclientlistening(receiversenderlisten){
    
    if(
receiver == sender){
        return 
FMRES_IGNORED;
    }
    if(
get_user_flags(sender) & ADMIN_BAN){
        return 
FMRES_IGNORED;
    }
    
    if(
get_user_team(sender) == && !is_muted[sender] && is_user_alive(sender)){ 
        return 
FMRES_IGNORED;
    }
    if(
get_user_team(sender) == && is_user_alive(sender)){
        return 
FMRES_IGNORED;
    }

    
engfunc(EngFunc_SetClientListeningreceiversender0);
    return 
FMRES_SUPERCEDE;

If user is admin he can talk always.
If user is terrorist he can only talk when he's alive and he isnt muted.
If user is counter terrrorist he can talk only when he's alive.

So I want CTS or admins make X terrorist speak, but even if the terrorist is not muted he can't.
If a player is CT and then he change to TT he can speak even if he's muted.

Last edited by The overrated maniac; 07-24-2021 at 18:58. Reason: Solved
The overrated maniac is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-24-2021 , 08:14   Re: Mute players dont work
Reply With Quote #2

it seems like you're muting and unmuting the menu user instead of the target.


PHP Code:
public handled_give_mic(idmenuitem){
    
    if (
item == MENU_EXIT){
        
        
menu_destroy(menu);
        return;
    }
    
    new 
accessnum[7], target;
    
menu_item_getinfo(menuitemaccessnumcharsmax(num), __access);
    
menu_destroy(menu);
    
target str_to_num(num);
    
    if (
is_user_connected(target)){
        
        new 
szName[32];
        
get_user_name(targetszName31); // MAX NAME IS 31 ITS HARDCODED IN THE ENGINE
        
        
if(is_muted[target]){        
            
is_muted[target] = false;
            
client_print(idprint_chat"%s is no longer muted!"szName);
        }
        else{
            
is_muted[target] = true;
            
client_print(idprint_chat"%s is muted!"szName);
        }
    }
    
    else{
        
chatcolor(id"Player is not connected!");
    }

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 07-24-2021 at 08:14.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 07-24-2021 , 18:58   Re: Mute players dont work
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
it seems like you're muting and unmuting the menu user instead of the target.


PHP Code:
public handled_give_mic(idmenuitem){
    
    if (
item == MENU_EXIT){
        
        
menu_destroy(menu);
        return;
    }
    
    new 
accessnum[7], target;
    
menu_item_getinfo(menuitemaccessnumcharsmax(num), __access);
    
menu_destroy(menu);
    
target str_to_num(num);
    
    if (
is_user_connected(target)){
        
        new 
szName[32];
        
get_user_name(targetszName31); // MAX NAME IS 31 ITS HARDCODED IN THE ENGINE
        
        
if(is_muted[target]){        
            
is_muted[target] = false;
            
client_print(idprint_chat"%s is no longer muted!"szName);
        }
        else{
            
is_muted[target] = true;
            
client_print(idprint_chat"%s is muted!"szName);
        }
    }
    
    else{
        
chatcolor(id"Player is not connected!");
    }

Thanks, solved.
The overrated maniac is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode