Raised This Month: $ Target: $400
 0% 

Solved prevent weapon reload


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hakim Azizov
Member
Join Date: Mar 2023
Old 11-25-2023 , 15:53   prevent weapon reload
Reply With Quote #1

hi guys. i want a plugin it prevents to reload weapons. can anybody help me?

Last edited by Hakim Azizov; 11-28-2023 at 09:22.
Hakim Azizov is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 11-26-2023 , 06:07   Re: prevent weapon reload
Reply With Quote #2

prevent the manual reload or automatic?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Hakim Azizov
Member
Join Date: Mar 2023
Old 11-26-2023 , 12:53   Re: prevent weapon reload
Reply With Quote #3

Quote:
Originally Posted by georgik57 View Post
prevent the manual reload or automatic?
only manual bro. admins have unmlimted clip. but they click reload button, i want to stop it. (prevent to push reload button)

i did this code but not worked

Code:
#include <amxmodx>
#include <amxmisc>
#include <amx_settings_api>
#include <cs_ham_bots_api>
#include <dhudmessage>
#include <hamsandwich>
#include <fakemeta_util>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <geoip>
#include <fun>

public plugin_init()
{
            register_forward(FM_CmdStart, "fm_cmd_start")
}

public fm_cmd_start(id, uc_handle, seed)
{
	if (!is_user_alive(id)) 
		return PLUGIN_HANDLED
	
       // comes from admin's unlimited clip
	//if (g_has_unlimited_clip[id])
	//	if (get_uc(uc_handle, UC_Buttons) & IN_RELOAD)
		//	return PLUGIN_HANDLED

	if (get_user_flags(id) & ADMIN_BAN)
		if (get_uc(uc_handle, UC_Buttons) & IN_RELOAD)
			return PLUGIN_HANDLED
       
	return PLUGIN_CONTINUE	
}

Last edited by Hakim Azizov; 11-26-2023 at 12:56.
Hakim Azizov is offline
McTavish
Senior Member
Join Date: May 2021
Old 11-26-2023 , 13:28   Re: prevent weapon reload
Reply With Quote #4

Quote:
Originally Posted by Hakim Azizov View Post
only manual bro. admins have unmlimted clip. but they click reload button, i want to stop it. (prevent to push reload button)

i did this code but not worked

Code:
#include <amxmodx>
#include <amxmisc>
#include <amx_settings_api>
#include <cs_ham_bots_api>
#include <dhudmessage>
#include <hamsandwich>
#include <fakemeta_util>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <geoip>
#include <fun>

public plugin_init()
{
            register_forward(FM_CmdStart, "fm_cmd_start")
}

public fm_cmd_start(id, uc_handle, seed)
{
	if (!is_user_alive(id)) 
		return PLUGIN_HANDLED
	
       // comes from admin's unlimited clip
	//if (g_has_unlimited_clip[id])
	//	if (get_uc(uc_handle, UC_Buttons) & IN_RELOAD)
		//	return PLUGIN_HANDLED

	if (get_user_flags(id) & ADMIN_BAN)
		if (get_uc(uc_handle, UC_Buttons) & IN_RELOAD)
			return PLUGIN_HANDLED
       
	return PLUGIN_CONTINUE	
}
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;
}
__________________
No Steam = No Support.
McTavish is offline
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
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 11-26-2023 , 15:17   Re: prevent weapon reload
Reply With Quote #6

As this is a forum for learning to script, i've given you explanations of how the code works overall.
Please ask if you don't understand something.
PHP Code:
#include <amxmodx>
#include <fakemeta>

// flags that a user needs to have access to unlimited clip
new g_szAccess[] = "mnopqrstu";

public 
plugin_init()
{
    
register_plugin("Block manual reload""0.0.1""D i 5 7 i n c T")
    
    
// catch the event when the players are pressing a button
    
register_forward(FM_CmdStart"fwFmCmdStartPre")
}

public 
plugin_cfg()
    
g_szAccess[0] = read_flags(g_szAccess);

public 
fwFmCmdStartPre(const iID, const iIDUCHandle)//, const iSeed
{
    
// ignore players that are not alive or connected or don't have the needed flags
    
if (!is_user_alive(iID) || get_user_flags(iID) & g_szAccess[0] != g_szAccess[0])
        return;
    
    
// find what buttons the player is pressing
    
new iBsButtons get_uc(iIDUCHandleUC_Buttons);
    
    
// ignore if he is not pressing the reload button
    
if (!(iBsButtons IN_RELOAD))
        return;
    
    
// he is pressing the reload button. "unpress" it.
    
set_uc(iIDUCHandleUC_ButtonsiBsButtons & ~IN_RELOAD)

Attached Files
File Type: sma Get Plugin or Get Source (D7BlockReloadManual.sma - 25 views - 984 Bytes)
__________________

Last edited by georgik57; 11-26-2023 at 15:42. Reason: attached sma
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Hakim Azizov
Member
Join Date: Mar 2023
Old 11-27-2023 , 10:00   Re: prevent weapon reload
Reply With Quote #7

Quote:
Originally Posted by georgik57 View Post
As this is a forum for learning to script, i've given you explanations of how the code works overall.
Please ask if you don't understand something.
PHP Code:
#include <amxmodx>
#include <fakemeta>

// flags that a user needs to have access to unlimited clip
new g_szAccess[] = "mnopqrstu";

public 
plugin_init()
{
    
register_plugin("Block manual reload""0.0.1""D i 5 7 i n c T")
    
    
// catch the event when the players are pressing a button
    
register_forward(FM_CmdStart"fwFmCmdStartPre")
}

public 
plugin_cfg()
    
g_szAccess[0] = read_flags(g_szAccess);

public 
fwFmCmdStartPre(const iID, const iIDUCHandle)//, const iSeed
{
    
// ignore players that are not alive or connected or don't have the needed flags
    
if (!is_user_alive(iID) || get_user_flags(iID) & g_szAccess[0] != g_szAccess[0])
        return;
    
    
// find what buttons the player is pressing
    
new iBsButtons get_uc(iIDUCHandleUC_Buttons);
    
    
// ignore if he is not pressing the reload button
    
if (!(iBsButtons IN_RELOAD))
        return;
    
    
// he is pressing the reload button. "unpress" it.
    
set_uc(iIDUCHandleUC_ButtonsiBsButtons & ~IN_RELOAD)

thanks bro. you are real man )
Hakim Azizov is offline
Reply



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 04:59.


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