Raised This Month: $ Target: $400
 0% 

Properly catch buy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-20-2009 , 15:29   Properly catch buy
Reply With Quote #1

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.

Thanks in advance.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-20-2009 , 16:35   Re: Properly catch buy
Reply With Quote #2

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
__________________
minimiller is offline
Send a message via MSN to minimiller
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-20-2009 , 16:37   Re: Properly catch buy
Reply With Quote #3

Quote:
Originally Posted by Dores View Post
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.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-20-2009 , 16:41   Re: Properly catch buy
Reply With Quote #4

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.
Arkshine is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-20-2009 , 16:58   Re: Properly catch buy
Reply With Quote #5

Thanks, I'll test it. (+k)
(Need to wait 24 hours before giving you karma...)
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-20-2009 , 17:24   Re: Properly catch buy
Reply With Quote #6

Oops
I should read more
have 1 of my crabs
__________________
minimiller is offline
Send a message via MSN to minimiller
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 01-20-2009 , 21:13   Re: Properly catch buy
Reply With Quote #7

Whoa, what the fuck? I had no idea Pawn supported do while loops. O_O
Spunky is offline
Send a message via AIM to Spunky
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-20-2009 , 23:45   Re: Properly catch buy
Reply With Quote #8

Quote:
Originally Posted by Spunky View Post
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.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 01-21-2009 at 14:47.
Dores is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 01-22-2009 , 16:29   Re: Properly catch buy
Reply With Quote #9

Syntax and features are two completely different things. D:

Anyways, that's cool to know.
Spunky is offline
Send a message via AIM to Spunky
Reply


Thread Tools
Display Modes

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:40.


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