AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block weapon switch (https://forums.alliedmods.net/showthread.php?t=312109)

CrazY. 11-16-2018 15:27

Block weapon switch
 
Hello, I'm trying to block weapon from being "holstered". I tried with member bAutoWepSwitch and superced Ham_Item_Deploy/Ham_Item_Holster, but none of them work. Any idea?

HamletEagle 11-17-2018 04:08

Re: Block weapon switch
 
You can always do the old ugly trick with CurWeapon + engclient_cmd("weapon_").
I'm not sure if there is a better way.

CrazY. 11-17-2018 06:57

Re: Block weapon switch
 
What I did was work with player pev->weapons. They still can switch weapon if open console and write weapon_*, but this can be fixed if I return PLUGIN_HANDLED.

Natsheh 11-17-2018 10:11

Re: Block weapon switch
 
Check my jailbreak_main plugin i am using ham_item_can_deploy_pre to remove the weapon.
PHP Code:

public fw_wpn_deployed_pre(const iWpn)
{
    new 
id get_pdata_cbase(iWpnm_iWeaponOwnerWEAPON_LINUXDIFF)
    
    if(!
g_user_wpns_blocked[id]) return HAM_IGNORED;
    
    new 
sClassname[32], Wpn
    pev
(iWpnpev_classnamesClassnamecharsmax(sClassname))
    
    
Wpn cs_get_weapon_id(iWpn);
    
    if(
check_flag(g_user_wpns_blocked[id], Wpn))
    {
        
set_pev(idpev_weapons, (pev(id,pev_weapons) & ~(1<<Wpn)));
        
ExecuteHam(Ham_RemovePlayerItem,id,iWpn);
        
ExecuteHam(Ham_Item_KilliWpn);
        
SetHamReturnInteger(false);
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;



CrazY. 11-17-2018 13:08

Re: Block weapon switch
 
Actually I'm trying to avoid remove weapons from player, but thank you anyway.

Natsheh 11-17-2018 15:24

Re: Block weapon switch
 
Quote:

Originally Posted by CrazY. (Post 2624477)
Actually I'm trying to avoid remove weapons from player, but thank you anyway.

Then try calling the previous weapon instead of removing.

E1_531G 11-17-2018 16:09

Re: Block weapon switch
 
Did you try to call (ExecuteHam) Ham_Item_Deploy( your_weapon_ent ) in Ham_Item_Holster( your_weapon_ent ) POST forward ?


All times are GMT -4. The time now is 07:30.

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