AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   unlimited ammo (https://forums.alliedmods.net/showthread.php?t=113247)

One 12-24-2009 18:38

unlimited ammo
 
hi,

i tried to give ammo to attacker but by first kill, happend nothing and user get ammo @ 2. kill.
can anyone fix this please?


PHP Code:

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


#define OFFSET_CLIPAMMO        51
#define OFFSET_LINUX_WEAPONS    4
#define fm_cs_set_weapon_ammo(%1,%2)    set_pdata_int(%1, OFFSET_CLIPAMMO, %2, OFFSET_LINUX_WEAPONS)
#define m_pActiveItem 373

const NOCLIP_WPN_BS    = ((1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))


new const 
g_MaxClipAmmo[] = 
{
    
0,
    
13//CSW_P228
    
0,
    
10//CSW_SCOUT
    
0,  //CSW_HEGRENADE
    
7,  //CSW_XM1014
    
0,  //CSW_C4
    
30,//CSW_MAC10
    
30//CSW_AUG
    
0,  //CSW_SMOKEGRENADE
    
15,//CSW_ELITE
    
20,//CSW_FIVESEVEN
    
25,//CSW_UMP45
    
30//CSW_SG550
    
35//CSW_GALIL
    
25//CSW_FAMAS
    
12,//CSW_USP
    
20,//CSW_GLOCK18
    
10//CSW_AWP
    
30,//CSW_MP5NAVY
    
100,//CSW_M249
    
8,  //CSW_M3
    
30//CSW_M4A1
    
30,//CSW_TMP
    
20//CSW_G3SG1
    
0,  //CSW_FLASHBANG
    
7,  //CSW_DEAGLE
    
30//CSW_SG552
    
30//CSW_AK47
    
0,  //CSW_KNIFE
    
50//CSW_P90
}
enum NadeType
{
    
NADE_HEGRENADE 0,
    
NADE_FLASHBANG,
    
NADE_SMOKEGREN,
}
const 
m_iClip 51;
new const 
g_nadewpnid[NadeType] =
{
    
4,
    
25,
    
9
}
new const 
g_nadename[NadeType][] =
{
    
"weapon_hegrenade",
    
"weapon_flashbang",
    
"weapon_smokegrenade"
}

new const 
g_nadeammomsg[NadeType] = 
{
    
12,
    
11,
    
13
}
new 
g_msg_ammo
public plugin_init() 
{
    
register_plugin"Deathmach manager" "1.0" "One" );
    
register_event("DeathMsg""DeathMsg""a");
    
g_msg_ammo         get_user_msgid("AmmoPickup")

}
public 
DeathMsg()
{
    new 
attacker read_data(1);
    new 
headshot read_data)
    
    if(
headshot)
    {
        if(
is_user_alive(attacker))
        {
            new 
iWeapon read_data(2)
            new 
old_hp get_user_health(attacker)
            
set_user_health(attackerold_hp 30)
            
give_nade(attackerNADE_HEGRENADE)
            
client_print(attacker,print_chat,"asdad")
            if( !( 
NOCLIP_WPN_BS & (1<<iWeapon) ) )
            {
                
fm_cs_set_weapon_ammoget_pdata_cbase(attackerm_pActiveItem) , g_MaxClipAmmoiWeapon ] )
            }
            
        }
    }
    else
    {
        if(
is_user_alive(attacker))
        {
            new 
iWeapon read_data(2)
            new 
old_hp get_user_health(attacker)
            
set_user_health(attackerold_hp 10)
            
cs_set_user_bpammo(attacker,CSW_M4A1,30)
            
client_print(attacker,print_chat,"asdad")
            if( !( 
NOCLIP_WPN_BS & (1<<iWeapon) ) )
            {
                
fm_cs_set_weapon_ammoget_pdata_cbase(attackerm_pActiveItem) , g_MaxClipAmmoiWeapon ] )
            }
        }
    }
}
give_nade(indexNadeType:nademode 0)
{
    switch(
mode)
    {
        case 
0:
        {
            new 
nadeammo cs_get_user_bpammo(index,g_nadewpnid[nade])
            if (
nadeammo == 0)
            {
                
give_item(index,g_nadename[nade])
            }
            else
            {
                
cs_set_user_bpammo(index,g_nadewpnid[nade],nadeammo+1)
                
                if (!
is_user_bot(index))
                {
                    
msg_ammo_pickup(index,nade)
                }
            }
            
            
        }
        case 
1:
        {
            
give_item(index,g_nadename[nade])
            
            
        }
        case 
2:
        {
            
cs_set_user_bpammo(index,g_nadewpnid[nade],cs_get_user_bpammo(index,g_nadewpnid[nade])+1)
            
            if (!
is_user_bot(index))
            {
                
msg_ammo_pickup(index,nade)
            }
            
            
        }
        case 
3:
        {
            return 
cs_get_user_bpammo(index,g_nadewpnid[nade])
        }
        default:
        {
            return 
0
        
}
    }
    
    return 
cs_get_user_bpammo(index,g_nadewpnid[nade])
}
msg_ammo_pickup(idNadeType:nade)
{
    
message_begin(MSG_ONEg_msg_ammo, {0,0,0}, id)
    
write_byte(g_nadeammomsg[nade])
    
write_byte(1)
    
message_end()



MouseSplash! 12-24-2009 18:45

Re: unlimited ammo
 
u can use set_task in bpammo..
and
the plugin is desactivate use remove_task

One 12-24-2009 18:47

Re: unlimited ammo
 
huh? why setting a task ?
why not so :
PHP Code:

if(headshot)
    {
        if(
is_user_alive(attacker))
        {
//give ammo
}


?

btw. idk why this not works or its buggy.






All times are GMT -4. The time now is 04:14.

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