AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Properly catch buy (https://forums.alliedmods.net/showthread.php?t=84108)

Dores 01-20-2009 15:29

Properly catch buy
 
What is the best way to catch/hook the event when a player successfully bought a weapon?
I don't need to catch the event if he don't have enough money, etc.
I know I could register many client commands of the buy commands, but I wonder if there's an easier way to get that info.

It should be simple, but I just can't see it. :o

Thanks in advance. :crab:

minimiller 01-20-2009 16:35

Re: Properly catch buy
 
PHP Code:

public plugin_init(id)
{
     
register_clcmd("deagle""func")
}

public 
func()
{
    
//Do your thang


Some1 else will probly pwn this, but its worked for me in the past

Dores 01-20-2009 16:37

Re: Properly catch buy
 
Quote:

Originally Posted by Dores (Post 747275)
I know I could register many client commands of the buy commands, but I wonder if there's an easier way to get that info.

Thanks. :crab:


Arkshine 01-20-2009 16:41

Re: Properly catch buy
 
Here, a snippet from VEN :

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

I'm not sure if it's a proper way or not.

Dores 01-20-2009 16:58

Re: Properly catch buy
 
Thanks, I'll test it. (+k) :crab:
(Need to wait 24 hours before giving you karma...)

minimiller 01-20-2009 17:24

Re: Properly catch buy
 
Oops
I should read more
have 1 of my crabs
:crab:

Spunky 01-20-2009 21:13

Re: Properly catch buy
 
Whoa, what the fuck? I had no idea Pawn supported do while loops. O_O

Dores 01-20-2009 23:45

Re: Properly catch buy
 
Quote:

Originally Posted by Spunky (Post 747384)
Whoa, what the fuck? I had no idea Pawn supported do while loops. O_O

The syntax is the same as C, Java, PHP, etc...
But please don't start a off-topic chat here.

EDIT: @arkshine: It works, thanks.

Spunky 01-22-2009 16:29

Re: Properly catch buy
 
Syntax and features are two completely different things. D:

Anyways, that's cool to know. :D


All times are GMT -4. The time now is 01:40.

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