Raised This Month: $51 Target: $400
 12% 

update number of nades in inventory...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hoboman
Senior Member
Join Date: Jul 2007
Old 02-26-2008 , 19:59   update number of nades in inventory...
Reply With Quote #1

I got this script that uses cs_set_user_bpammo(id, nadeType, 0 ) to set the ammo count of a particular nade to 0
After this is done the nade will still appear to be in the players inventory, but it will be red ( can attach a screeny to make this more clear )
After a little while this red nade disappears ( i think only after switching to it back and forth a few times )

Can someone suggest to me a way as to how to update the player's weapons or something so as to get rid of the red/ammoless nades
__________________
hoboman is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-26-2008 , 20:49   Re: update number of nades in inventory...
Reply With Quote #2

Try something like :

Code:
engclient_cmd( id, "weapon_hegrenade" ); engclient_cmd( id, "lastinv" );

It selects the removed grenade and back to the last weapon.
__________________
Arkshine is offline
hoboman
Senior Member
Join Date: Jul 2007
Old 02-26-2008 , 22:44   Re: update number of nades in inventory...
Reply With Quote #3

Quote:
Originally Posted by arkshine View Post
Try something like :

Code:
engclient_cmd( id, "weapon_hegrenade" ); engclient_cmd( id, "lastinv" );


It selects the removed grenade and back to the last weapon.
i tried using that and it actually gave me a new hegren instead of the redish hegren icon...i am pretty sure "weapon_hegrenade" doesn't even change the player's weapon to a nade anyways

I also tried just two "engclient_cmd( id, "lastinv" )" back to back. I won't go into details, but it definitely didn't work right.

btw, how is engclient_cmd( id, "lastinv" ) different from just client_cmd( id, "lastinv" )? Is it kinda like telling the server that the server did lastinv without actually making the player do lastinv?


eidt: oops ur right, "weapon_hegrenade" changes weapon to nade...
__________________

Last edited by hoboman; 02-26-2008 at 23:04.
hoboman is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-26-2008 , 22:53   Re: update number of nades in inventory...
Reply With Quote #4

Quote:
Originally Posted by hoboman View Post
i tried using that and it actually gave me a new hegren instead of the redish hegren icon...i am pretty sure "weapon_hegrenade" doesn't even change the player's weapon to a nade anyways
if you don't have one, it tries to buy you one.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-26-2008 , 23:07   Re: update number of nades in inventory...
Reply With Quote #5

You didn't understand, hoboman.

Take a look into my plugin forbidden weapon : http://forums.alliedmods.net/showthread.php?t=63942

Search the DelayedDropping() function. All below 'remove_grenade()' is a snippet from VEN.

When a grenade is removed ( same method as you ), to update :

- If you had this grenade in your hands so then you have to switch on another weapon ( in my code the next weapon by priority ).
- If you hadn't this grenade in your hands so then you have to select this grenade and back to the last used weapon.

It works perfectly.
__________________

Last edited by Arkshine; 02-26-2008 at 23:12.
Arkshine is offline
hoboman
Senior Member
Join Date: Jul 2007
Old 02-26-2008 , 23:54   Re: update number of nades in inventory...
Reply With Quote #6

here is the piece of code that I am working with...

where id is the id of the player
nadeType is the CSW_... name of a nade
and nadeNameSw is the weapon_... name of a nade

Code:
           
 if( get_user_weapon(id)== nadeType )
            {
                cs_set_user_bpammo( id, nadeType, cs_get_user_bpammo(id, nadeType)-1 )
                client_cmd( id, "lastinv" )
            }
            else
            {
                client_cmd( id, nadeNameSw )
                cs_set_user_bpammo( id, nadeType, cs_get_user_bpammo(id, nadeType)-1 )
                client_cmd(id, "weapon_knife" )
            }

if I change any of the above client_cmd to engclient_cmd, the red nades get replaced by new mystery nades. Otherwise the red nade pic still does appear sometimes and sometimes it doesn't.
__________________
hoboman is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-27-2008 , 00:12   Re: update number of nades in inventory...
Reply With Quote #7

Instead of : client_cmd( id, "lastinv" ) , it should be engclient_cmd( id, "weapon_whatyouwant" )

Instead of : client_cmd(id, "weapon_knife" ) , it should be : engclient_cmd(id, "lastinv" ) and client_cmd( id, nadeNameSw ) should be called after cs_set_user_bpammo().

Code:
    cs_set_user_bpammo( id, nadeType, cs_get_user_bpammo( id, nadeType ) - 1 );             if( get_user_weapon( id ) == nadeType )     {         engclient_cmd( id, "weapon_Whatyouwant" );     }     else     {         engclient_cmd( id, nadeNameSw );         engclient_cmd( id, "lastinv" );     }
__________________

Last edited by Arkshine; 02-27-2008 at 00:35.
Arkshine is offline
Reply



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 23:02.


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