AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Add bullets to current mag? (https://forums.alliedmods.net/showthread.php?t=130714)

Jelle 06-26-2010 19:35

Add bullets to current mag?
 
Is there a way to add like 2 bullets in the current mag of the current gun in use? I mean maybe a native like cs_set_user_bpammo().

GXLZPGX 06-26-2010 19:44

Re: Add bullets to current mag?
 
Quote:

Originally Posted by Jelle (Post 1220878)
Is there a way to add like 2 bullets in the current mag of the current gun in use? I mean maybe a native like cs_set_user_bpammo().

This should work, I don't know if you're trying to use a say command or what not.

PHP Code:

new userammo cs_get_user_bpammoidCSW_WEAPONNAME )
cs_set_user_bpammoidCSW_WEAPONNAMEuserammo 

Of course change the "CSW_WEAPONNAME" to "CSW_AK47" or whatever weapon it is.

wrecked_ 06-26-2010 20:13

Re: Add bullets to current mag?
 
Code:
#define cs_add_user_bpammo(%1,%2,%3) (cs_set_user_bpammo(%1,%2,cs_get_user_bpammo(%1,%2)+%3) // Usage cs_add_user_bpammo( id, CSW_DEAGLE, 2 )

GXLZPGX 06-26-2010 21:15

Re: Add bullets to current mag?
 
Quote:

Originally Posted by wrecked_ (Post 1220900)
Code:
#define cs_add_user_bpammo(%1,%2,%3) (cs_set_user_bpammo(%1,%2,cs_get_user_bpammo(%1,%2)+%3) // Usage cs_add_user_bpammo( id, CSW_DEAGLE, 2 )

Lol'd because my version = long way :(

Kreation 06-26-2010 23:26

Re: Add bullets to current mag?
 
Wouldn't that add ammo for their bp? The current mag would be something like as they're shooting and the ammo is running out. I think that may be what he wants, not sure though.

wrecked_ 06-27-2010 00:43

Re: Add bullets to current mag?
 
Code:
cs_add_weapon_ammo( id, weapon, amt=1 ) {     if( is_user_alive( id ) )     {         new bad_weapons_bitsum = ( ( 1 << CSW_KNIFE ) | ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << 2 ) )                 if( !( ( 1 << weapon ) & bad_weapons_bitsum ) )         {             new wname[20]             get_weaponname( weapon, wname, 19 )             new iWep = find_ent_by_owner( iWep, wname, id, 0 )                         if( iWep )             {                 cs_set_weapon_ammo( iWep, cs_get_weapon_ammo( iWep ) + amt )                 return iWep;             }         }     }     return 0; } // Usage Example cs_add_weapon_ammo( id, CSW_DEAGLE, 2 ) cs_add_weapon_ammo( id, CSW_AWP, 1 )

madeitout 06-27-2010 23:37

Re: Add bullets to current mag?
 
PHP Code:

stock set_user_clip(idammo)
{
    new 
weaponname[32], weaponid = -1weapon get_user_weapon(id__);
    
get_weaponname(weaponweaponname31);
    while ((
weaponid engfunc(EngFunc_FindEntityByStringweaponid"classname"weaponname)) != 0)
        if (
pev(weaponidpev_owner) == id) {
            
set_pdata_int(weaponid51ammo4);
            return 
weaponid;
        }
    return 
0;



Jelle 06-28-2010 09:43

Re: Add bullets to current mag?
 
Thank you all.

What I want to do is to make a superhero, where you, each second gain 2 more bullets in current mag. This makes it so people just doesn't spray, which is a common thing in SH mod.

Also, I have no idea how to use stocks.

I believe wrecked_'s version is the best?

wrecked_ 06-28-2010 10:10

Re: Add bullets to current mag?
 
Both will work. Mine is a little more direct, as his searches for the gun in a loop.

A stock is a function. All you have to do is paste it at the bottom of your plugin and you can use it.

ConnorMcLeod 06-28-2010 11:45

Re: Add bullets to current mag?
 
Alternative to find_ent_by_owner : http://forums.alliedmods.net/showthread.php?t=85962


All times are GMT -4. The time now is 14:44.

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