Raised This Month: $ Target: $400
 0% 

Problem with "buy" detecting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
matsi
Thinkosaur
Join Date: Sep 2006
Old 11-14-2009 , 12:43   Problem with "buy" detecting
Reply With Quote #1

I'm using this code to detect buying:
Code:
#include <amxmodx> #define MAX_CLIENTS 32 new g_weapons[MAX_CLIENTS + 1] public plugin_init() {         register_event("Money", "event_money", "be") } public client_command(id) {         static dummy[32], dummy2         g_weapons[id] = get_user_weapons(id, dummy, dummy2) } public event_money(id) {         new old_weapons = g_weapons[id]         client_command(id)         new new_weapon = g_weapons[id] & ~old_weapons         if (new_weapon) {                 new x = -1                 do ++x; while ((new_weapon /= 2) >= 1)                 static wname[32]                 get_weaponname(x, wname, sizeof wname - 1)                 server_print("Player [ClientIndex=%d] has bought ^"%s^" [WeaponIndex=%d]", id, wname, x)         } }

Now i have problem with flashbang detecting. So when i first buy flashbang it works as it should but when i buy second flashbang it doesn't work.
matsi is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-14-2009 , 13:34   Re: Problem with "buy" detecting
Reply With Quote #2

Try this:
Code:
#include <amxmodx> #include <cstrike> #define MAX_CLIENTS 32 new g_weapons[MAX_CLIENTS + 1] new g_flashbangs[MAX_CLIENTS + 1] public plugin_init() {         register_event("Money", "event_money", "be") } public client_command(id) {         static dummy[32], dummy2         g_weapons[id] = get_user_weapons(id, dummy, dummy2)         g_flashbangs[id] = cs_get_user_bpammo(id, CSW_FLASHBANG) } public event_money(id) {         new old_weapons = g_weapons[id]         new old_flashbangs = g_flashbangs[id]         client_command(id)         new new_weapon = g_weapons[id] & ~old_weapons         if (new_weapon) {                 new x = -1                 do ++x; while ((new_weapon /= 2) >= 1)                 static wname[32]                 get_weaponname(x, wname, sizeof wname - 1)                 server_print("Player [ClientIndex=%d] has bought ^"%s^" [WeaponIndex=%d]", id, wname, x)         }         else if (old_flashbangs == 1 && g_flashbangs[id] == 2) {                 server_print("Player [ClientIndex=%d] has bought ^"weapon_flashbang^" [WeaponIndex=%d]", id, CSW_FLASHBANG)         } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 11-15-2009 at 12:54.
Exolent[jNr] is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 11-14-2009 , 14:06   Re: Problem with "buy" detecting
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Try this:
Code:
#include <amxmodx> #include <cstrike> #define MAX_CLIENTS 32 new g_weapons[MAX_CLIENTS + 1] new g_flashbangs[MAX_CLIENTS + 1] public plugin_init() {         register_event("Money", "event_money", "be") } public client_command(id) {         static dummy[32], dummy2         g_weapons[id] = get_user_weapons(id, dummy, dummy2)         g_flashbangs[id] = cs_get_user_bpammo(id, CSW_FLASHBANG) } public event_money(id) {         new old_weapons = g_weapons[id]         client_command(id)         new new_weapon = g_weapons[id] & ~old_weapons         if (new_weapon) {                 new x = -1                 do ++x; while ((new_weapon /= 2) >= 1)                 static wname[32]                 get_weaponname(x, wname, sizeof wname - 1)                 server_print("Player [ClientIndex=%d] has bought ^"%s^" [WeaponIndex=%d]", id, wname, x)         }         else if (g_flashbangs[id] == 1 && cs_get_user_bpammo(id, CSW_FLASHBANG) == 2) {                 server_print("Player [ClientIndex=%d] has bought ^"weapon_flashbang^" [WeaponIndex=%d]", id, CSW_FLASHBANG)         } }
Only the first message was displayed.
matsi is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-15-2009 , 12:54   Re: Problem with "buy" detecting
Reply With Quote #4

Try it now.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 11-19-2009 , 04:37   Re: Problem with "buy" detecting
Reply With Quote #5

Quote:
Originally Posted by Exolent[jNr] View Post
Try it now.
Works now...

Thanks
matsi 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 00:42.


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