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

Get ammo of weapon on the ground


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sebxx4
Senior Member
Join Date: Feb 2013
Old 02-27-2023 , 07:51   Get ammo of weapon on the ground
Reply With Quote #1

How can I check the amount of ammo in a weapon lying on the ground without picking it up?
sebxx4 is offline
theartemmaps
Junior Member
Join Date: Sep 2022
Old 02-28-2023 , 15:39   Re: Get ammo of weapon on the ground
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=305952
theartemmaps is offline
sebxx4
Senior Member
Join Date: Feb 2013
Old 03-01-2023 , 07:24   Re: Get ammo of weapon on the ground
Reply With Quote #3

I have seen it.
But I dont want to pick up this weapon, I just want to know what amount of ammo it has when player steps on it. This plugin seems to just move weapon in player's POV to his position.

I tried this, but always returns 0 :/
Quote:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init()
{
register_plugin("test", "1.0", "sebxx")
RegisterHam(Ham_Touch, "weaponbox", "HamTouchPre", 0);
}

public HamTouchPre(weapon, id)
{
if ( pev_valid(weapon) != 2 || !is_user_alive(id) )
return HAM_IGNORED;

new ammo = get_pdata_int(weapon, 51, 4);
client_print(id, print_chat, "CLIP: %d", ammo);

return HAM_SUPERCEDE;
}

Last edited by sebxx4; 03-01-2023 at 07:48.
sebxx4 is offline
sebxx4
Senior Member
Join Date: Feb 2013
Old 03-02-2023 , 07:02   Re: Get ammo of weapon on the ground
Reply With Quote #4

Anybody?
sebxx4 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-03-2023 , 15:11   Re: Get ammo of weapon on the ground
Reply With Quote #5

How do you want to identify the weapon on the ground that you want the ammo for? When the player looks at it?
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-04-2023 , 11:05   Re: Get ammo of weapon on the ground
Reply With Quote #6

PHP Code:

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

const m_iClip 51;
const 
XO_WEAPON 4;

new const 
m_rgpPlayerItems_CWeaponBox6]  = { 34 35 , ... };
const 
XO_WEAPONBOX 4;

public 
plugin_init()
{
    
register_touch"weaponbox" "player" "PlayerTouchWeaponbox" );
}

public 
PlayerTouchWeaponboxiWeaponbox iPlayer )
{
    new 
iWeapon;
    
    if ( 
entity_get_intiWeaponbox EV_INT_flags ) & FL_ONGROUND )
    {
        for ( new 
iSlot iSlot <= iSlot++ )
        {
            
iWeapon get_pdata_cbaseiWeaponbox m_rgpPlayerItems_CWeaponBoxiSlot ] , XO_WEAPONBOX );
            
            if ( 
iWeapon )
            {
                
client_printiPlayer print_chat "Clip ammo: %d" get_pdata_intiWeapon m_iClip XO_WEAPON ) );
                break;
            }
        }
    }

__________________
Bugsy is offline
sebxx4
Senior Member
Join Date: Feb 2013
Old 03-05-2023 , 09:35   Re: Get ammo of weapon on the ground
Reply With Quote #7

This is what I was looking for Thank you.
sebxx4 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 12:48.


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