AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Mute players dont work (https://forums.alliedmods.net/showthread.php?t=333594)

The overrated maniac 07-24-2021 04:24

Mute players dont work
 
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.

Natsheh 07-24-2021 08:14

Re: Mute players dont work
 
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!");
    }



The overrated maniac 07-24-2021 18:58

Re: Mute players dont work
 
Quote:

Originally Posted by Natsheh (Post 2753533)
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.


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

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