Thread: [Solved] prevent weapon reload
View Single Post
Hakim Azizov
Member
Join Date: Mar 2023
Old 11-26-2023 , 13:32   Re: prevent weapon reload
Reply With Quote #5

Quote:
Originally Posted by McTavish View Post
I'm bad at coding but try this maybe could help you.
write on chat: /reloadcfg
to give yourself unlimited ammo. After this, you should be able to reload without any restrictions.
Code:
#include <amxmodx>

const ADMIN_FLAGS = ADMIN_LEVEL_B;

public plugin_init() {
    register_plugin("NoReload", "1.0", "McTavish");
    
    register_clcmd("say /reload", "cmd_reload");
    register_clcmd("say !reload", "cmd_reload");
    register_clcmd("say @reload", "cmd_reload");
}

public cmd_reload(id) {
    if (is_user_connected(id) && !(get_user_flags(id) & ADMIN_FLAGS)) {
        client_print(id, print_chat, "You are not allowed to reload weapons!");
        return PLUGIN_HANDLED;
    }
    
    return PLUGIN_CONTINUE;
}

public plugin_cfg() {
    register_clcmd("say /reloadcfg", "cmd_reloadcfg");
    register_clcmd("say !reloadcfg", "cmd_reloadcfg");
    register_clcmd("say @reloadcfg", "cmd_reloadcfg");
}

public cmd_reloadcfg(id) {
    if (get_user_flags(id) & ADMIN_FLAGS) {
        set_user_flags(id, ADMIN_FLAGS);
        client_print(id, print_chat, "You now have unlimited ammo!");
        return PLUGIN_HANDLED;
    }

    return PLUGIN_CONTINUE;
}
this code you sent me will not work. because these codes only work with type to chat "reload" word. and when this function calls, it willn't prevent to reload because return PLUGIN_HANDLED can be called to own function
Hakim Azizov is offline