AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Why this doesn't work ? (https://forums.alliedmods.net/showthread.php?t=326511)

Abhinash 08-03-2020 15:42

Why this doesn't work ?
 
Hi everyone.
I am using this function to give weapon --
Code:

give_user_weapon( index , iWeaponTypeID , iClip=0 , iBPAmmo=0 )
{
        if ( !( CSW_P228 <= iWeaponTypeID <= CSW_P90 ) || ( iClip < 0 ) || ( iBPAmmo < 0 ) || !is_user_alive( index ) )
                return -1;
       
        new szWeaponName[ 20 ] , iWeaponEntity , bool:bIsGrenade;
       
        const GrenadeBits = ( ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_C4 ) );
       
        if ( ( bIsGrenade = bool:!!( GrenadeBits & ( 1 << iWeaponTypeID ) ) ) )
                iClip = clamp( iClip ? iClip : iBPAmmo , 1 );
       
        get_weaponname( iWeaponTypeID , szWeaponName , charsmax( szWeaponName ) );
       
        if ( ( iWeaponEntity = user_has_weapon( index , iWeaponTypeID ) ? find_ent_by_owner( -1 , szWeaponName , index ) : give_item( index , szWeaponName ) ) > 0 )
        {
                if ( iWeaponTypeID != CSW_KNIFE )
                {
                        if ( iClip && !bIsGrenade )
                                cs_set_weapon_ammo( iWeaponEntity , iClip );
                        if ( !iClip && !iBPAmmo )
                                b_uAmmo[index] = true;
                        else
                                b_uAmmo[index] = false;

                       
                        if ( iWeaponTypeID == CSW_C4 )
                                cs_set_user_plant( index , 1 , 1 );
                        else
                                cs_set_user_bpammo( index , iWeaponTypeID , bIsGrenade ? iClip : iBPAmmo );
                }
        }
       
        return iWeaponEntity;
}

Here, b_uAmmo is a global variable.
And, I want it to work like when I use function with 3rd and 4th parameters, then I want to work it as usual which is working fine.
And I want when I am using this function without 3rd and 4th parameters, then it set the variable to true and then in CurWeapon, I can set unlimited Ammo according to the Variable. i did according to the plan, but its not working.
Please help me.

Here is the CurWeapon part --
Code:

public message_cur_weapon(id)
{
        // Not alive or zombie
        if (!g_isalive[id] || g_zombie[id])
                return;
       
        if (!g_zombie[id] || g_sniper[id])
                return;
       
        if (b_uAmmo[id])
                set_pdata_int(get_pdata_cbase(id, 373), 51, 100, 4)
}


supertrio17 08-03-2020 17:20

Re: Why this doesn't work ?
 
Post your whole code.

Abhinash 08-04-2020 01:57

Re: Why this doesn't work ?
 
Quote:

Originally Posted by supertrio17 (Post 2712894)
Post your whole code.

These are the only places, where it is used. And g_uammo[33] is global variable. And about full code, it's just default Zp 4.3 .
Can anyone help ?


All times are GMT -4. The time now is 13:46.

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