AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ H3LP ] Use bpammo instead of clip? (https://forums.alliedmods.net/showthread.php?t=298598)

CrazY. 06-17-2017 10:56

[ H3LP ] Use bpammo instead of clip?
 
Hello, I want to do a thing for one weapon only. I need to hide weapon clip of hud and when player shoot, decrease one bullet of bpammo.

Bugsy 06-17-2017 13:23

Re: [ H3LP ] Use bpammo instead of clip?
 
I'm not sure it's possible to hide just the clip ammo. You could possibly make it display 0 or some constant value.

I was thinking HideWeapon message, but this hides other things in addition to ammo.
Code:

  1  (1<<0)  -  crosshair, ammo, weapons list
  2  (1<<1)  -  flashlight, +
  4  (1<<2)  -  ALL
  8  (1<<3)  -  radar, health, armor, +
 16  (1<<4)  -  timer, +
 32  (1<<5)  -  money, +
 64  (1<<6)  -  crosshair
128  (1<<7)  -  +

This will show clip as always 0 (or whatever you want it to show as) and subtract from bpammo as shots are fired. It needs a little work but it's something to start with:
PHP Code:


#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

#define m_pActiveItem 373

const WeaponType CSW_GLOCK18//Weapon that you want this plugin to apply to
const DisplayClip 0//Clip ammo that will display regardless of actual contents

enum _:CurWeaponArgs
{
    
IsActive 1,
    
WeaponID,
    
ClipAmmo
}

public 
plugin_init() 
{
    
register_messageget_user_msgid"CurWeapon" ) , "CurWeapon" );
}

public 
CurWeaponmsg_id msg_dest msg_entity )
{
    new 
iClip iBP iWeaponEnt;
    
    if ( ( 
get_msg_arg_intIsActive ) == ) && ( get_msg_arg_intWeaponID ) == WeaponType ) )
    {
        
get_user_ammomsg_entity WeaponType iClip iBP );
        
iWeaponEnt get_pdata_cbasemsg_entity m_pActiveItem );
        
        if ( 
iBP >= )
        {
            
cs_set_user_bpammomsg_entity WeaponType , --iBP );
            
cs_set_weapon_ammoiWeaponEnt 40 );
        }
        else
        {
            
cs_set_weapon_ammoiWeaponEnt );
        }
        
        
set_msg_arg_intClipAmmo DisplayClip );
    }



CrazY. 06-17-2017 14:54

Re: [ H3LP ] Use bpammo instead of clip?
 
I will test that bugsy, thank you!

CrazY. 07-02-2017 20:20

Re: [ H3LP ] Use bpammo instead of clip?
 
Bugsy, the code is subtracting 1 from the Bpammo of the player even if it is not firing. I print the value of IBP, is showing the Bpammo that the player should have, but in the hud shows the current value subtracted by one. So when the player's Bpammo is at 0, I can shoot one more time.

Apart from that problem, the code is OK!

I did some tests and found that if you change the display value to -1, it will only show you the Bpammo.

Edit: If I get user button and check if is IN_ATTACK the code work, but still player can shoot more one time if bpammo are 0

NiHiLaNTh 07-03-2017 04:59

Re: [ H3LP ] Use bpammo instead of clip?
 
I am pretty sure it is possible - just send 'CurWeapon' message with argument -1 as weapon clip.

Craxor 07-03-2017 05:59

Re: [ H3LP ] Use bpammo instead of clip?
 
Here's what i've done, is not using bpammo insteand of ammo, but when you no more having bullets is settings directly the bullets as bpamoo and empty the bpammo, test to see by yourself how is working.

You can easily add a hudmessage and remove the clip using the bugsy method (HideWeaponMessage) by yourself and manage how you want.

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <engine>

public plugin_init()
{
    new 
szWeaponName[20];
    for( new 
131i++ )
    {
        
get_weaponnameiszWeaponNamecharsmax(szWeaponName) );

        if( 
szWeaponName[0] != EOS )
        {
            
RegisterHamHam_Weapon_PrimaryAttackszWeaponName"ham_WpPrimaryAttack_PostFunc"true );
        }
    }
}

public 
ham_WpPrimaryAttack_PostFunc( const Entity )
{
    new 
OwnerOfWeaponIndex pevEntitypev_owner );
    new 
Bullets,Ammo;

    new 
WeaponId get_user_weaponOwnerOfWeaponIndexBulletsAmmo );

    if( 
Bullets <= )
    {
        
give_user_weaponOwnerOfWeaponIndexWeaponIdAmmo--, );
    }
}


give_user_weaponindex iWeaponTypeID iClip=iBPAmmo=szWeapon[]="" maxchars=)
{
    if ( !( 
CSW_P228 <= iWeaponTypeID <= CSW_P90 ) || ( iClip ) || ( iBPAmmo ) || !is_user_aliveindex ) )
        return -
1;
    
    new 
szWeaponName20 ] , iWeaponEntity bool:bIsGrenade;
    
    const 
GrenadeBits = ( ( << CSW_HEGRENADE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) | ( << CSW_C4 ) );
    
    if ( ( 
bIsGrenade bool:!!( GrenadeBits & ( << iWeaponTypeID ) ) ) )
        
iClip clampiClip iClip iBPAmmo );
    
    
get_weaponnameiWeaponTypeID szWeaponName charsmaxszWeaponName ) );
    
    if ( ( 
iWeaponEntity user_has_weaponindex iWeaponTypeID ) ? find_ent_by_owner( -szWeaponName index ) : give_itemindex szWeaponName ) ) > )
    {
        if ( 
iWeaponTypeID != CSW_KNIFE )
        {
            if ( 
iClip && !bIsGrenade )
                
cs_set_weapon_ammoiWeaponEntity iClip );
        
            if ( 
iWeaponTypeID == CSW_C4 
                
cs_set_user_plantindex );
            else
                
cs_set_user_bpammoindex iWeaponTypeID bIsGrenade iClip iBPAmmo ); 
        }
        
        if ( 
maxchars )
            
copyszWeapon maxchars szWeaponName[7] );
    }
    
    return 
iWeaponEntity;



CrazY. 07-03-2017 10:46

Re: [ H3LP ] Use bpammo instead of clip?
 
Ok, thanks.

CrazY. 07-13-2017 00:09

Re: [ H3LP ] Use bpammo instead of clip?
 
Bugsy, I tried to do the same with the Bpammo so it looks like the HUD of the knife, but I realized that there is no argument in the Curweapon as Clipammo. Can you help me?

https://wiki.alliedmods.net/Half-lif...ents#CurWeapon

Edit: I will try with ammox.
https://wiki.alliedmods.net/Half-lif...e_events#AmmoX

Depresie 07-13-2017 00:29

Re: [ H3LP ] Use bpammo instead of clip?
 
What weapon are you trying to create exactly ?
Maybe we can find a work around instead of rewriting a lot of stuff..

CrazY. 07-13-2017 08:49

Re: [ H3LP ] Use bpammo instead of clip?
 
Well, it's actually I added a power system to the Predators in my mod, so I don't need the clip/Bpammo from the plasma caster.

And the speargun just needs the Bpammo, it's already working.


All times are GMT -4. The time now is 22:55.

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