Raised This Month: $ Target: $400
 0% 

check if user is given a weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
djmd378
Senior Member
Join Date: Sep 2004
Old 08-13-2007 , 02:14   check if user is given a weapon
Reply With Quote #1

Is there a way to check if a player was just given a weapon without looping?

For example, user was stripped but then the map (Yeah the map gives the weapon and no the weapon wasn't from the floor) suddenly gives the player a weapon. And then after the player was given the weapon, I want to be able to do something.
__________________
djmd378 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 08-13-2007 , 14:10   Re: check if user is given a weapon
Reply With Quote #2

Will work for any case: give/collect/buy/etc:
Code:
#include <amxmodx> #define MAX_CLIENTS 32 new g_weapons[MAX_CLIENTS + 1] public plugin_init() {         register_event("WeapPickup", "event_weap_pickup", "be", "1!0")         register_event("CurWeapon", "event_cur_weapon", "be", "2!0") } public event_weap_pickup(id) {         g_weapons[id] |= (1<<read_data(1)) } public event_cur_weapon(id) {         new wid = read_data(2)         if (g_weapons[id] & (1<<wid)) {                 g_weapons[id] &= ~(1<<wid)                 static wname[32]                 get_weaponname(wid, wname, sizeof wname - 1)                 server_print("Player [ClientIndex=%d] got ^"%s^" [WeaponIndex=%d]", id, wname, wid)         } }
VEN is offline
djmd378
Senior Member
Join Date: Sep 2004
Old 08-13-2007 , 17:05   Re: check if user is given a weapon
Reply With Quote #3

Oh wow! Exactly what I was looking for. I never knew AMX Mod X had "WeapPickup". I was thinking that they did but just didn't know it. Thanks!


Just one question though, does " |= " mean "or equal" ?
__________________

Last edited by djmd378; 08-13-2007 at 17:07.
djmd378 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-13-2007 , 17:28   Re: check if user is given a weapon
Reply With Quote #4

Code:
"|="    "Bitwise inclusive (normal) OR and assign"    "flags |= new_flags"
Alka is offline
djmd378
Senior Member
Join Date: Sep 2004
Old 08-13-2007 , 21:01   Re: check if user is given a weapon
Reply With Quote #5

Ah I see. Learning something new everyday.
__________________
djmd378 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 22:48.


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