Raised This Month: $ Target: $400
 0% 

Grenade ammo *SOLVED*


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-21-2006 , 05:07   Grenade ammo *SOLVED*
Reply With Quote #1

When the user touches a nade it gives him TWO nades instead of one. Reason being is because CS gives him the spawned nade and what not and then my plugin gives him a nade when it specifically checks if his bpammo is > 0 (already has grenade). I tried these 2 methods:

Method 1:
Code:
register_touch("armoury_entity" , "player" , "touch_player"); /* [...] */ public touch_player(pToucher , pTouched) {     if(!is_valid_ent(pToucher) || !is_valid_ent(pTouched) || !is_user_connected(pTouched)) {         return PLUGIN_CONTINUE;     }     new pToucherMdl[64];     entity_get_string(pToucher , EV_SZ_model , pToucherMdl , 63);     new model = check_nade_model(pToucherMdl);     if(model > -1) {         if(is_user_alive(pTouched)) {             new ammo;             ammo = cs_get_user_bpammo(pTouched , model);             new max_ammo;             switch(model) {                 case CSW_FLASHBANG: max_ammo = get_nade_num(CSW_FLASHBANG);                 case CSW_HEGRENADE: max_ammo = get_nade_num(CSW_HEGRENADE);                 case CSW_SMOKEGRENADE:  max_ammo = get_nade_num(CSW_SMOKEGRENADE);             }             if(ammo > 0 && ammo < max_ammo) { /* Checking the ammo */                 remove_entity(pToucher);                 new param[2];                 param[0] = pTouched;                 param[1] = model;                 set_task(0.1 , "give_nade" , random_num(999,9999) , param , 2);             }         }     } }
Gives nades 1 at a time ( only when you don't have the type of nade out that you just touched ).

Method 2:
Code:
register_touch("armoury_entity" , "player" , "touch_player"); /* [...] */ public touch_player(pToucher , pTouched) {     if(!is_valid_ent(pToucher) || !is_valid_ent(pTouched) || !is_user_connected(pTouched)) {         return PLUGIN_CONTINUE;     }     new pToucherMdl[64];     entity_get_string(pToucher , EV_SZ_model , pToucherMdl , 63);     new model = check_nade_model(pToucherMdl);     if(model > -1) {         if(is_user_alive(pTouched)) {             new ammo , ammo1 , clip , weap = get_user_weapon(pTouched , ammo1 , clip);             if(weap != CSW_FLASHBANG && weap != CSW_HEGRENADE && weap != CSW_SMOKEGRENADE) {                 ammo = cs_get_user_bpammo(pTouched , model);             } else {                 ammo = cs_get_weapon_ammo(pTouched);             }             new max_ammo;             switch(model) {                 case CSW_FLASHBANG: max_ammo = get_nade_num(CSW_FLASHBANG);                 case CSW_HEGRENADE: max_ammo = get_nade_num(CSW_HEGRENADE);                 case CSW_SMOKEGRENADE:  max_ammo = get_nade_num(CSW_SMOKEGRENADE);             }             if(ammo > 0 && ammo < max_ammo) {                 remove_entity(pToucher);                 new param[2];                 param[0] = pTouched;                 param[1] = model;                 set_task(0.1 , "give_nade" , random_num(999,9999) , param , 2);             }         }     } }

A few functions that are used in there:
Code:
public give_nade(param[]) {     new id = param[0];     new nade = param[1];     new ammo = cs_get_user_bpammo(id , nade);     cs_set_user_bpammo(id , nade , ammo + 1);     emit_sound(id, CHAN_WEAPON , "items/9mmclip1.wav" , 1.0 , ATTN_NORM , 0 , PITCH_NORM); } public check_nade_model(model[]) {     if( containi( model, "w_flashbang.mdl"    ) != -1 ) return CSW_FLASHBANG;     if( containi( model, "w_hegrenade.mdl"    ) != -1 ) return CSW_HEGRENADE;     if( containi( model, "w_smokegrenade.mdl" ) != -1 ) return CSW_SMOKEGRENADE;     return -1; } public get_nade_num(nade) {     switch(nade) {         case CSW_FLASHBANG: return get_cvar_num(CVAR_FB);         case CSW_HEGRENADE: return get_cvar_num(CVAR_HE);         case CSW_SMOKEGRENADE:  return get_cvar_num(CVAR_SG);     }     return -1; }
Gives 2 nades instead of 1 for the first one.

Also, it permanently removes the spawned nades from the map.

Help would be greatly appreciated
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
 


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 20:17.


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