Raised This Month: $ Target: $400
 0% 

Event fired when shield is used or not used?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mugwump
Senior Member
Join Date: May 2004
Old 10-22-2007 , 13:48   Event fired when shield is used or not used?
Reply With Quote #1

Heya, is there an event I can hook for when the CT shield is used? CurWeapon does not seem to fire when the shield is used or not used...

Thanks,
Mugwump
Mugwump is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 10-22-2007 , 13:59   Re: Event fired when shield is used or not used?
Reply With Quote #2

Try this...
http://www.amxmodx.org/funcwiki.php?...ield&go=search
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Mugwump
Senior Member
Join Date: May 2004
Old 10-22-2007 , 14:04   Re: Event fired when shield is used or not used?
Reply With Quote #3

I don't know if that helps. The definition says if the user _has_ a shield, but not whether its in use mode or not.

When a player uses their shield (puts it in block mode) their default runspeed slow down, I want to be able to detect that they just used their shield so I can override the runspeed change...

Thanks,
Mugwump
Mugwump is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-22-2007 , 14:39   Re: Event fired when shield is used or not used?
Reply With Quote #4

You have to use IN_ATTACK2 button to use a shield. ( I believe )

So something like :

Code:
if( ( pev( id, pev_button ) & IN_ATTACK2 ) && cs_get_user_shield( id ) )

But to detect properly IN_ATTACK2 you have to use the PlayerPreThink forward or CmdStart, I think.
__________________

Last edited by Arkshine; 10-22-2007 at 14:43.
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-22-2007 , 16:02   Re: Event fired when shield is used or not used?
Reply With Quote #5

You can use this, may be make full tests before...

Code:
#include <amxmodx> #include <fakemeta> #define OFFSET_SHIELD   510 #define HAS_SHIELD      (1<<24) #define USES_SHIELD     (1<<16) #define MAXPLAYERS  32 enum ShieldState {     Hasnt = 0,     Has,     Uses } new ShieldState:has_shield[MAXPLAYERS+1] public plugin_init() {     register_plugin("shield test", "0.1", "ConnorMcLeod")       register_forward(FM_PlayerPreThink, "fwdPlayerPreThink") } public fwdPlayerPreThink(id) {     if(!is_user_alive(id) || !is_user_connected(id))         return     static shield_offset     shield_offset = get_pdata_int(id, OFFSET_SHIELD)     if(shield_offset & HAS_SHIELD)     {         if(shield_offset & USES_SHIELD && has_shield[id] != Uses)         {             // player has just used his shield, you can fire a forward             has_shield[id] = Uses         }         else if(has_shield[id] != Has)         {             // player doesn't use his shield anymore, you can fire a forward             has_shield[id] = Has         }               }     else if(has_shield[id])     {         // player droped his shield ?, respawn ?         has_shield[id] = Hasnt     }     return } //for a native public has_user_shield(id) {     new ShieldState:result, shield_offset = get_pdata_int(id, OFFSET_SHIELD)     if(shield_offset & HAS_SHIELD)         if(shield_offset & USES_SHIELD)             result = Uses         else             result = Has     else         result = Hasnt      return result }

Either you use this in a plugin, either you create a native, either you need the event when the player uses it and in this case i guess you need to create a forward.Well, i don't know yet how to deal with forward creation, but you seem to be skilled ;)

I guess this offset could be added in cstrike module.

Last edited by ConnorMcLeod; 10-22-2007 at 17:37.
ConnorMcLeod is offline
Mugwump
Senior Member
Join Date: May 2004
Old 10-22-2007 , 20:38   Re: Event fired when shield is used or not used?
Reply With Quote #6

The PreThink logic appears to work great, I can use a similar technique for what I need to accomplish. Thank you!

-Mugwump
Mugwump is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 10-23-2007 , 08:41   Re: Event fired when shield is used or not used?
Reply With Quote #7

Quote:
Originally Posted by arkshine View Post
You have to use IN_ATTACK2 button to use a shield. ( I believe )

So something like :

Code:
if( ( pev( id, pev_button ) & IN_ATTACK2 ) && cs_get_user_shield( id ) )

But to detect properly IN_ATTACK2 you have to use the PlayerPreThink forward or CmdStart, I think.
CmdStart is the best method, since that is where the buttons are actually sent/received from.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz 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 01:12.


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