AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with function - tfc_isgrenade (https://forums.alliedmods.net/showthread.php?t=13120)

Lt Llama 05-05-2005 08:53

Need help with function - tfc_isgrenade
 
Im trying to learn small by making a very simple plugin for TFC.
I want the plugin to detect
_ if a player has nail grenades
_ send a print message that nail grenades cant be used
_ empty the players ammo bag from nail grenades

I probably do some very stupid things while coding, but im very new to it.

I looked at pizzahuts sniper plugin to see how to detect a weapon.

It works for switchable weapons but not for grenades. I have this now, it compiles but i dont get any message that nail grenades are carried

Code:
/* AMX Mod X *  Anti Nail Grenade Plugin for Team Fortress Classic * *  Created by Lt Llama *  based on pizzahut's Anti-Sniper AMX script. */ #include <amxmodx> #include <engine> #include <tfcx> #include <tfcconst> new announced[33] public plugin_init() {   register_plugin("Anti-Nail", "0.1", "Lt Llama") } public client_authorized(id){    announced[id] = 0 } public client_PreThink(id) {    if (is_user_alive(id)) {       new grenade       if (tfc_isgrenade(grenade) == TFC_WPN_NAILGRENADE ) {           announce(id)       } else {           announced[id] = 0       }     }     return PLUGIN_CONTINUE } public announce(id){   if (announced[id]==0) {      client_print(id, print_chat,"You carry nail grenades")      announced[id] = 1   } }

I tried get_user_weapon and get_user_ammo, but i cant get them to work.
I would be very greatful for any hints in the right direction.

Thx

Jinto 05-15-2005 21:23

How about..

1> Check if their class is soldier.
2> Check their secondary grenade count

Code:

new grenades = get_pdata_int( id, 15 );

if( grenades > 0 ) {
    // We have secondary grenades
    set_pdata_int( id, 15, 0 );
}



All times are GMT -4. The time now is 16:48.

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