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
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 #1

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 #2

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
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