@xolent
VEN's method with client command hook should be better than hooking client prethink.
PHP 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) {
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)
}
}
Should work for smokegrenade, not sure if the money check is required :
PHP Code:
#include <amxmodx>
#define MAX_CLIENTS 32
new g_bHasSmokeGren[MAX_CLIENTS + 1]
new g_bUserMoney[MAX_CLIENTS + 1]
public plugin_init() {
register_event("Money", "event_money", "be")
}
public client_command(id)
{
g_bHasSmokeGren[id] = user_has_weapon(id, CSW_SMOKEGRENADE)
}
public event_money(id)
{
new iNewMoney = read_data(1)
if( !g_bHasSmokeGren[id]
&& (g_bHasSmokeGren[id] = user_has_weapon(id, CSW_SMOKEGRENADE)) )
{
if( g_bUserMoney[id] - iNewMoney == 300 )
{
client_print(id, print_chat, "Enjoy the smoke.")
}
}
g_bUserMoney[id] = iNewMoney
}
__________________