AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to put in weapon only 1 bullet? (https://forums.alliedmods.net/showthread.php?t=127493)

PWA 05-21-2010 19:20

How to put in weapon only 1 bullet?
 
Hello everyone, i wanted to ask, how to put in the weapon only 1 bullet?
Help me ;)

KadiR 05-21-2010 19:22

Re: How to put in weapon only 1 bullet?
 
http://www.amxmodx.org/funcwiki.php?go=func&id=208

drekes 05-21-2010 21:40

Re: How to put in weapon only 1 bullet?
 
PHP Code:

public somefunc(id)
{
    if(
is_user_alive(id))
    {
         new 
wpn = (give_item(id"weapon_usp")
         
cs_set_weapon_ammo(wpn1)
         
cs_set_user_bpammo(idCSW_USP0)
    }



Exolent[jNr] 05-21-2010 23:27

Re: How to put in weapon only 1 bullet?
 
PHP Code:

public somefunc(id)
{
    if(
is_user_alive(id))
    {
        new 
wpn give_item(id"weapon_usp")
        if(
wpn 0)
        {
            
cs_set_weapon_ammo(wpn1)
        }
        
cs_set_user_bpammo(idCSW_USP0)
    }


But I would use something to make the rest easier like:

Code:
GiveWeapon( iPlayer, iWeaponID = 0, szWeaponName[ ] = "", iClip = -1, iAmmo = -1 ) {     if( !is_user_alive( iPlayer ) )     {         return 0;     }         new _szWeaponName[ 20 ]; // weapon_smokegrenade = 19         if( !iWeaponID )     {         if( !( iWeaponID = get_weaponid( szWeaponName ) ) )         {             return 0;         }                 copy( _szWeaponName, charsmax( _szWeaponName ), szWeaponName );     }     else if( !get_weaponname( iWeaponID, _szWeaponName, charsmax( _szWeaponName ) ) )     {         return 0;     }         new iWeaponEntity = give_item( iPlayer, _szWeaponName );         if( iWeaponEntity > 0     &&  iClip >= 0 )     {         cs_set_weapon_ammo( iWeaponEntity, iClip );     }         if( iAmmo >= 0 )     {         cs_set_weapon_ammo( iPlayer, iWeaponID, iAmmo );     }         return 1; }

Code:
GiveWeapon( iPlayer, CSW_USP, _, 1, 0 ); // 1 clip ammo GiveWeapon( iPlayer, _, "weapon_ak47" ); // default ammo

KadiR 05-22-2010 05:42

Re: How to put in weapon only 1 bullet?
 
Is that wrong when I make this, works perfectly for me:

PHP Code:

        new weapon_id find_ent_by_owner(-1"weapon_awp"id);
        if(
weapon_id)
        {
            
cs_set_weapon_ammo(weapon_id1);
            
//cs_set_user_bpammo ( id, CSW_AWP, 3 );
        



NiQu 05-22-2010 05:51

Re: How to put in weapon only 1 bullet?
 
You have errors in your code exolent.

Exolent[jNr] 05-22-2010 22:57

Re: How to put in weapon only 1 bullet?
 
Quote:

Originally Posted by NiQu (Post 1187687)
You have errors in your code exolent.

Show me?


All times are GMT -4. The time now is 03:33.

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