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

[ H3LP ] Block weapon switch?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-23-2017 , 20:35   [ H3LP ] Block weapon switch?
Reply With Quote #1

Hello, I'm trying to block weapon switch, but I didn't get success.

Code:
set_pdata_int(id, 509, false);

and also with

Code:
// Ham_Item_CanHolster/Ham_Item_Holster public fw_Item_CanHolster_Pre(entity) {        return HAM_SUPERCEDE; }
__________________









Last edited by CrazY.; 08-23-2017 at 20:36.
CrazY. is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 08-23-2017 , 21:04   Re: [ H3LP ] Block weapon switch?
Reply With Quote #2

There is no way to do this directly.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-24-2017 , 08:45   Re: [ H3LP ] Block weapon switch?
Reply With Quote #3

Don't think if i understand correctly question but you can try some methods:
1. Block weapon slots
2. Use engclient_cmd() to set previous slot back right after player changes it
3. Strip useless weapons?
siriusmd99 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-24-2017 , 11:36   Re: [ H3LP ] Block weapon switch?
Reply With Quote #4

I don't think it's going to work this way, what I'm trying to do is a "injection" plugin that carries the player's life. The only problem is that the player can swap the weapon, I want to block until the injection animation is finalized.
__________________








CrazY. is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-24-2017 , 12:26   Re: [ H3LP ] Block weapon switch?
Reply With Quote #5

Quote:
Originally Posted by CrazY. View Post
I don't think it's going to work this way, what I'm trying to do is a "injection" plugin that carries the player's life. The only problem is that the player can swap the weapon, I want to block until the injection animation is finalized.
So i understand that engclientcmd will only set the previous weapon , but weapon will be still changed for a short time and injection animation will fail. I am right?

In this case you can hook Ham item deploy pre and return supercede.

When injection starts start a boolean g_blockedDeploy[id] = true

Then check

PHP Code:




public OnItemDeployPre(ent)
{
   static 
idid fm_cs_get_weapon_ent_owner(ent);
   if((
<= id <= g_iMaxplayers) && g_blockedDeploy[id])
   return 
HAM_SUPERCEDE;

   return 
HAM_IGNORED;

Not sure if it will work but it would be enough logic to hook pre and return supercede.

Last edited by siriusmd99; 08-24-2017 at 12:29.
siriusmd99 is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 08-24-2017 , 15:08   Re: [ H3LP ] Block weapon switch?
Reply With Quote #6

i suggest striping all player wepons on "injection" then give them back when "injection" ends.
__________________
JusTGo is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-24-2017 , 15:57   Re: [ H3LP ] Block weapon switch?
Reply With Quote #7

Hm, I'm going to do some tests.
__________________









Last edited by CrazY.; 08-24-2017 at 15:58.
CrazY. is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 08-24-2017 , 16:02   Re: [ H3LP ] Block weapon switch?
Reply With Quote #8

Even though it won't help you.
You are wrong in here. ::CanHolster returns TRUE/FALSE, so that you need to not only block the original execution, but also provide a valid result by using SetHamReturn....

Code:
// Ham_Item_CanHolster/Ham_Item_Holster
public fw_Item_CanHolster_Pre(entity)
{
       SetHamReturnInteger(_:false);
       return HAM_SUPERCEDE;
}
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
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 10:09.


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