Raised This Month: $51 Target: $400
 12% 

[ H3LP ] Use bpammo instead of clip?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-17-2017 , 10:56   [ H3LP ] Use bpammo instead of clip?
Reply With Quote #1

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.
__________________








CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-17-2017 , 13:23   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #2

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 );
    }

__________________

Last edited by Bugsy; 06-17-2017 at 14:05.
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-17-2017 , 14:54   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #3

I will test that bugsy, thank you!
__________________








CrazY. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-02-2017 , 20:20   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #4

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
__________________









Last edited by CrazY.; 07-03-2017 at 00:23.
CrazY. is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 07-03-2017 , 04:59   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #5

I am pretty sure it is possible - just send 'CurWeapon' message with argument -1 as weapon clip.
__________________


Last edited by NiHiLaNTh; 07-03-2017 at 05:01.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 07-03-2017 , 05:59   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #6

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;

__________________
Project: Among Us

Last edited by Craxor; 07-03-2017 at 15:27.
Craxor is offline
Send a message via ICQ to Craxor
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-03-2017 , 10:46   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #7

Ok, thanks.
__________________








CrazY. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-13-2017 , 00:09   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #8

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
__________________









Last edited by CrazY.; 07-13-2017 at 00:13.
CrazY. is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-13-2017 , 00:29   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #9

What weapon are you trying to create exactly ?
Maybe we can find a work around instead of rewriting a lot of stuff..
__________________

Last edited by Depresie; 07-13-2017 at 00:30.
Depresie is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-13-2017 , 08:49   Re: [ H3LP ] Use bpammo instead of clip?
Reply With Quote #10

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.
__________________








CrazY. is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:27.


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