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

Dissable shooting when in duck


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
niiii
Member
Join Date: Sep 2013
Old 05-13-2015 , 14:55   Dissable shooting when in duck
Reply With Quote #1

Hello, I have a problem with a plugin, I need to make that when somebody is in duck he cant shoot, Id like to do it like when you duck your gun dissappears but when you stand it appears again... is something like that possible?
niiii is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 05-13-2015 , 15:38   Re: Dissable shooting when in duck
Reply With Quote #2

I think it would be better to just block the weapon from firing instead of removing it
look up the longjump plugin, you have to duck + move forward + jump to longjump so you will find a way to hook ducking in there

after you're done, read this to block the weapon from shooting
https://forums.alliedmods.net/showthread.php?t=41265
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
niiii
Member
Join Date: Sep 2013
Old 05-14-2015 , 05:09   Re: Dissable shooting when in duck
Reply With Quote #3

I need that for the call of duty mod server, but only for 1 class. That class has special ability that when duck then the class is invisible, but I need you can't shoot.

case Poltergeist:
{
niewidzialnosc_kucanie[id] = 1;
ilosc_min_player[id] = 0;
ilosc_rakiet_player[id] = 0;
ilosc_dynamitow_player[id] = 0;
if(information_item_player[id][0] != 6){
set_user_rendering(id,kRenderFxNone,255,255,2 55,kRenderTransAlpha,255)
}
}



I need to add some lines to block shooting only for this class
niiii is offline
hzqst
Senior Member
Join Date: Jul 2008
Old 05-15-2015 , 01:01   Re: Dissable shooting when in duck
Reply With Quote #4

set player's m_flNextAttack = get_gametime() + 0.1 in PlayerPreThink when player is in duck
hzqst is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-15-2015 , 10:14   Re: Dissable shooting when in duck
Reply With Quote #5

Code:
#define m_flNextAttack  83 // CBasePlayer, Linux +5 public plugin_init() {     // ...     register_forward(FM_CmdStart, "fwd_CmdStart");     // ... } public fwd_CmdStart(id, uc_handle, seed) {         // Add class check here.         if ( ! is_user_alive(id) )         return FMRES_IGNORED;         if ( ! ( get_uc(uc_handle, UC_Buttons) & IN_DUCK ) )         return FMRES_IGNORED;         if ( get_user_weapon(id) == CSW_KNIFE ) // Perhaps?         return FMRES_IGNORED;         set_pdata_float(id, m_flNextAttack, 0.1, 5);         return FMRES_HANDLED; }
__________________
Black Rose is offline
niiii
Member
Join Date: Sep 2013
Old 05-16-2015 , 06:17   Re: Dissable shooting when in duck
Reply With Quote #6

Quote:
Originally Posted by Black Rose View Post
Code:
#define m_flNextAttack  83 // CBasePlayer, Linux +5 public plugin_init() {     // ...     register_forward(FM_CmdStart, "fwd_CmdStart");     // ... } public fwd_CmdStart(id, uc_handle, seed) {         // Add class check here.         if ( ! is_user_alive(id) )         return FMRES_IGNORED;         if ( ! ( get_uc(uc_handle, UC_Buttons) & IN_DUCK ) )         return FMRES_IGNORED;         if ( get_user_weapon(id) == CSW_KNIFE ) // Perhaps?         return FMRES_IGNORED;         set_pdata_float(id, m_flNextAttack, 0.1, 5);         return FMRES_HANDLED; }
Thank you very much, it works But I have another question, I'd like to print to client that he cant shot when in duck, but when I do it prints always when he ducks, not only if try to shot, any ideas?

Last edited by niiii; 05-16-2015 at 06:51.
niiii is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 05-16-2015 , 09:17   Re: Dissable shooting when in duck
Reply With Quote #7

Using (and superceding) Ham_Weapon_PrimaryAttack with similar code will probably be more efficient, and also allow you to more easily display the info message.
__________________
In Flames we trust!
Nextra is offline
niiii
Member
Join Date: Sep 2013
Old 05-16-2015 , 15:12   Re: Dissable shooting when in duck
Reply With Quote #8

may you edit the code for me please? it would be nice from you mate
niiii is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 05-17-2015 , 04:34   Re: Dissable shooting when in duck
Reply With Quote #9

Quote:
Originally Posted by Nextra View Post
Using (and superceding) Ham_Weapon_PrimaryAttack with similar code will probably be more efficient, and also allow you to more easily display the info message.
And you would need to delete client prediction, which means, UpdateClientData hook, same frames as CmdStart.

If the case were PrimaryAttack, setting PrimaryAttack offset up to 1-2 seconds would break the idea, since you'll lose seconds standing up, and that means, 0.1 seconds delay -> many forward calls anyway
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
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 19:02.


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