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

Cannot get flashbang bpammo. "Invalid weapon ID: 25"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 01-20-2021 , 23:07   Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #1

I am trying to get the amount of flashbangs a player has, as seen in presented code.
However, I am getting an error [CSTRIKE] Invalid weapon ID: 25, I have also tried putting the flashbang's AID (ammo id?) of 11 and I get the same error.


PHP Code:
#include <amxmodx>
#include <cstrike>

public plugin_init() {

        
register_clcmd("say /countfb""CmdCountFlashbangs");
}

public 
CmdCountFlashbangs(id) {

        
client_print(idprint_chat"You have %d flashbangs."cs_get_user_bpammo(idCSW_FLASHBANG));


Last edited by redivcram; 01-21-2021 at 20:24.
redivcram is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 01-20-2021 , 23:11   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #2

I like how I easily find an obvious solution just after I call for help. lol


Just use:
PHP Code:
    new clipammo;
    
get_user_ammo(idCSW_FLASHBANGclipammo);
    
client_print(idprint_chat"You have %d / %d flapbangs."clipammo); 
</div>

ammo is the answer

Last edited by redivcram; 01-20-2021 at 23:11.
redivcram is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-21-2021 , 00:42   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #3

Quote:
Originally Posted by redivcram View Post
I like how I easily find an obvious solution just after I call for help. lol
That's how it works out all too often.
__________________
fysiks is online now
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 01-21-2021 , 11:41   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
That's how it works out all too often.

I can safely say people helped me a lot without saying anything.
redivcram is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-21-2021 , 13:36   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #5

That doesn't seem right. I use "cs_get_user_bpammo" for handling grenades and it works properly.

Code:
give_grenade(id, iGrenade, iCount = 1) {     if(user_has_weapon(id, iGrenade))     {         cs_set_user_bpammo(id, iGrenade, cs_get_user_bpammo(id, iGrenade) + iCount)     }     else     {         new szGrenade[20]         get_weaponname(iGrenade, szGrenade, charsmax(szGrenade))         give_item(id, szGrenade)         if(iCount > 1)         {             cs_set_user_bpammo(id, iGrenade, iCount)         }     } }

Just tested your code and it works as well. What AMXX version are you using?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 01-21-2021 , 19:43   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #6

Yes. I am using 1.9. I've abandoned 1.8.3 long ago. Perhaps I should submit a new issue on the repo? :V
redivcram is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-21-2021 , 19:48   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #7

Are you using the latest 1.9 build? I'm currently on 1.10 and there's no issue.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 01-21-2021 , 20:02   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #8

I don't think I'm using the latest build for 1.9. Is 1.10 stable enough for use yet?
redivcram is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 01-21-2021 , 20:25   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #9

Okay, I am at the latest 1.10 build for Windows. Apparently now both get_user_ammo and cs_get_user_bpammo throw the same error... Weapon ID: 25, ofc.
redivcram is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-21-2021 , 21:02   Re: Cannot get flashbang bpammo. "Invalid weapon ID: 25"
Reply With Quote #10

Can you test with all other plugins disabled?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 01:58.


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