Raised This Month: $ Target: $400
 0% 

[HELP] Best way to set unlimited BPammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-04-2014 , 15:46   [HELP] Best way to set unlimited BPammo
Reply With Quote #1

So, the only way that comes on my mind is like:
PHP Code:
cs_set_user_bpammo(idCSW_99999999
but this looks nooby and also may be pointed as a hardcoding. Could this be wrong at all and cause some troubles, and if so, is there a better way to set unlimited BP ammo on weapon - only one weapon. All the example plugins I found were setting unlimited clip, but I want backpack ammo. Thanks.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 06-04-2014 , 16:09   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #2

Code:
#include <amxmodx> #include <cstrike> public plugin_init() {     register_event("CurWeapon", "event_CurWeapon", "be", "1=1") } public event_CurWeapon(id) {     if(!is_user_alive(id))         return PLUGIN_CONTINUE;     static wpnid, clip;     wpnid = read_data(2);     clip = read_data(3);     give_ammo(id , wpnid , clip);     return PLUGIN_CONTINUE; } stock maxclip(wpnid) {     static ca;     ca = 0;     switch (wpnid)     {         case CSW_P228 : ca = 13;         case CSW_SCOUT : ca = 10;         case CSW_HEGRENADE : ca = 0;         case CSW_XM1014 : ca = 7;         case CSW_C4 : ca = 0;         case CSW_MAC10 : ca = 30;         case CSW_AUG : ca = 30;         case CSW_SMOKEGRENADE : ca = 0;         case CSW_ELITE : ca = 15;         case CSW_FIVESEVEN : ca = 20;         case CSW_UMP45 : ca = 25;         case CSW_SG550 : ca = 30;         case CSW_GALI : ca = 35;         case CSW_FAMAS : ca = 25;         case CSW_USP : ca = 12;         case CSW_GLOCK18 : ca = 20;         case CSW_AWP : ca = 10;         case CSW_MP5NAVY : ca = 30;         case CSW_M249 : ca = 100;         case CSW_M3 : ca = 8;         case CSW_M4A1 : ca = 30;         case CSW_TMP : ca = 30;         case CSW_G3SG1 : ca = 20;         case CSW_FLASHBANG : ca = 0;         case CSW_DEAGLE : ca = 7;         case CSW_SG552 : ca = 30;         case CSW_AK47 : ca = 30;         case CSW_P90 : ca = 50;     }     return ca; } public give_ammo(id , wpnid , clip) {     if(!is_user_alive(id))         return;     if( wpnid==CSW_C4       ||         wpnid==CSW_KNIFE    ||         wpnid==CSW_HEGRENADE    ||         wpnid==CSW_SMOKEGRENADE ||         wpnid==CSW_FLASHBANG    )             return;     if(!clip)     {         if (cs_get_user_bpammo(id, wpnid) < maxclip(wpnid)) {             cs_set_user_bpammo(id, wpnid, maxclip(wpnid))         }     } }

Last edited by jimaway; 06-04-2014 at 16:13.
jimaway is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-04-2014 , 16:24   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #3

Wow, really thanks! That seems to work great. Now, one last question. Does this cost less CPU at all, than setting huge number bpammo. Which way would be better for the server's function at all. Don't know how to explain this in english properly, so I hope you got my idea. Thanks.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-04-2014 , 20:59   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #4

Quote:
Originally Posted by jimaway View Post
Spoiler
Quote:
Originally Posted by Flick3rR View Post
Wow, really thanks! That seems to work great. Now, one last question. Does this cost less CPU at all, than setting huge number bpammo. Which way would be better for the server's function at all. Don't know how to explain this in english properly, so I hope you got my idea. Thanks.
That would cost far more CPU then setting backpack ammo to a large number. Changing backpack ammo every time someone fires a shot? Bad idea.

This will have a couple loose calls here and there which can be patched up, but it is still called very few times:
Code:
#include <amxmodx> #include <cstrike> #define VERSION     "0.0.1" new const g_iMaxBpAmmo[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120, 30, 120, 200, 32, 90, 120, 90, 1, 35, 90, 90, -1, 100 } public plugin_init() {     register_plugin( "Infinite Backpack Ammo", VERSION, "hornet" );         register_event( "AmmoX", "Event_AmmoX", "be" ); } public Event_AmmoX( id ) {     new iWeapon = get_user_weapon( id );         if( iWeapon && iWeapon != CSW_KNIFE )         cs_set_user_bpammo( id, iWeapon, g_iMaxBpAmmo[ iWeapon ] ); }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-05-2014 , 01:50   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #5

Thanks! Will test and post the results. Now we get that as the best option, right?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-05-2014 , 11:40   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #6

Quote:
Originally Posted by hornet View Post
That would cost far more CPU then setting backpack ammo to a large number. Changing backpack ammo every time someone fires a shot? Bad idea.
Nope, is every weapon change, but the code of jimaway is terrible anyway.
You can look at CSDM to for infinite bpammo
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 06-05-2014 , 12:25   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #7

Quote:
Originally Posted by ^SmileY View Post
Nope, is every weapon change
where did you get this information?
Quote:
CurWeapon

This message updates the numerical magazine ammo count and the corresponding ammo type icon on the HUD.
jimaway is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-05-2014 , 14:23   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #8

Quote:
Originally Posted by jimaway View Post
where did you get this information?
Yes it is, because when you change the weapon the hud of ammo is updated.
If you no change the weapon the hud will not change. Depends what parameters you are specified in the register_event
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 06-05-2014 at 14:24.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Old 06-05-2014, 15:12
Apb hq
This message has been deleted by YamiKaitou. Reason: thread hijack
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-05-2014 , 19:27   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #9

Quote:
Originally Posted by ^SmileY View Post
Nope, is every weapon change, but the code of jimaway is terrible anyway.
You can look at CSDM to for infinite bpammo
CurWeapon event is sent every time a player's clip ammo changes. Go and do your research before engaging in something that you are clearly uneducated in ...
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-05-2014 , 19:57   Re: [HELP] Best way to set unlimited BPammo
Reply With Quote #10

Quote:
Originally Posted by hornet View Post
CurWeapon event is sent every time a player's clip ammo changes. Go and do your research before engaging in something that you are clearly uneducated in ...
Strange, it is used in csdm using active / inactive flag

https://github.com/Arkshine/CSDM/blo.../csdm_misc.sma
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 09:38.


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