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

[SOLVED] Store and restore bpammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-09-2013 , 11:22   [SOLVED] Store and restore bpammo
Reply With Quote #1

Hi everyone

I have this:

PHP Code:
public StoreAllPlayersWeapons()
{
        for(new 
1;<= gMaxPlayers;i++)
    {
        if(
is_user_alive(i))
            
gPlayerWeapons[i] = pev(pev_weapons) &~ (<< 31)
    }
}

RestoreWeapons(id)
{
    new 
iValue gPlayerWeapons[id]
    
    for(new 
wpn 1;wpn <= 30;wpn++)
    {
        if((
& (iValue >> wpn)) && (wpn != 2) && (wpn != CSW_C4) && (wpn != CSW_KNIFE))
        {
            static 
szWeapon[32]
            
get_weaponname(wpnszWeapon31)
            
give_item(idszWeapon)
        }
    }

I need to know how to store bpammo and then restore the same amount for every weapon.

Thank you in advance
__________________

Last edited by alan_el_more; 10-10-2013 at 15:31.
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-09-2013 , 13:33   Re: Store and restore bpammo
Reply With Quote #2

PHP Code:
const WEAPON_SUIT 31;

const 
_ammo_338magnum 1;
const 
_ammo_c4 14;

const 
m_rgAmmo_CBasePlayer[32] = {376,377,...};

new 
gPlayerWeapons[33];
new 
gPlayersBpAmmo[33][_ammo_c4+1];

public 
StoreAllPlayersWeapons()
{
    new 
players[32], numidrgAmmoSlot;
    
get_players(playersnum"a");
    for(--
numnum>=0num--)
    {
        
id players[num];
        
gPlayerWeapons[id] = pev(idpev_weapons) & ~(1<<WEAPON_SUIT);
        for(
rgAmmoSlot=_ammo_338magnumrgAmmoSlot<=_ammo_c4rgAmmoSlot++)
        {
            
gPlayersBpAmmo[id][rgAmmoSlot] = get_pdata_int(idm_rgAmmo_CBasePlayer[rgAmmoSlot]);
        }
    }
}

RestoreWeapons(id)
{
    new 
szWeapon[32];
    new 
weapons gPlayerWeapons[id];
    for(new 
iId CSW_P228iId<=CSW_P90iId++)
    {
        if( 
weapons 1<<iId )
        {
            
get_weaponname(iIdszWeaponcharsmax(szWeapon));
            
give_item(idszWeapon);
        }
    }
    for(new 
rgAmmoSlot=_ammo_338magnumrgAmmoSlot<=_ammo_c4rgAmmoSlot++)
    {
        
set_pdata_int(idm_rgAmmo_CBasePlayer[rgAmmoSlot], gPlayersBpAmmo[id][rgAmmoSlot]);
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-10-2013 at 14:12.
ConnorMcLeod is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-10-2013 , 11:01   Re: Store and restore bpammo
Reply With Quote #3

Code:
L 10/10/2013 - 11:40:50: [AMXX] Run time error 4: index out of bounds
Code:
public StoreAllPlayersWeapons() {     new players[32], num, id, rgAmmoSlot;     get_players(players, num, "a");     for(--num; num>=0; num--)     {         id = players[num];         gPlayerWeapons[id] = pev(id, pev_weapons) & ~(1<<WEAPON_SUIT);         for(rgAmmoSlot=_ammo_338magnum; rgAmmoSlot<=_ammo_c4; rgAmmoSlot++)         {
            gPlayersBpAmmo[id][rgAmmoSlot] = get_pdata_int(id, m_rgAmmo_CBasePlayer[rgAmmoSlot]);
        }     }
__________________

Last edited by alan_el_more; 10-10-2013 at 11:04.
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-10-2013 , 14:12   Re: Store and restore bpammo
Reply With Quote #4

try again, code edited.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-10-2013 , 14:43   Re: Store and restore bpammo
Reply With Quote #5

It works!
Thank you
__________________
alan_el_more is offline
Reply


Thread Tools
Display Modes

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 00:59.


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