AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Best way to set unlimited BPammo (https://forums.alliedmods.net/showthread.php?t=241511)

Flick3rR 06-04-2014 15:46

[HELP] Best way to set unlimited BPammo
 
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. :)

jimaway 06-04-2014 16:09

Re: [HELP] Best way to set unlimited BPammo
 
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))         }     } }

Flick3rR 06-04-2014 16:24

Re: [HELP] Best way to set unlimited BPammo
 
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.

hornet 06-04-2014 20:59

Re: [HELP] Best way to set unlimited BPammo
 
Quote:

Originally Posted by jimaway (Post 2146872)
Spoiler

Quote:

Originally Posted by Flick3rR (Post 2146879)
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 ] ); }

Flick3rR 06-05-2014 01:50

Re: [HELP] Best way to set unlimited BPammo
 
Thanks! Will test and post the results. Now we get that as the best option, right?

^SmileY 06-05-2014 11:40

Re: [HELP] Best way to set unlimited BPammo
 
Quote:

Originally Posted by hornet (Post 2146977)
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

jimaway 06-05-2014 12:25

Re: [HELP] Best way to set unlimited BPammo
 
Quote:

Originally Posted by ^SmileY (Post 2147165)
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.

^SmileY 06-05-2014 14:23

Re: [HELP] Best way to set unlimited BPammo
 
Quote:

Originally Posted by jimaway (Post 2147181)
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

hornet 06-05-2014 19:27

Re: [HELP] Best way to set unlimited BPammo
 
Quote:

Originally Posted by ^SmileY (Post 2147165)
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 ...

^SmileY 06-05-2014 19:57

Re: [HELP] Best way to set unlimited BPammo
 
Quote:

Originally Posted by hornet (Post 2147340)
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


All times are GMT -4. The time now is 09:38.

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