Raised This Month: $ Target: $400
 0% 

[REQ] Fix add ammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-24-2011 , 05:53   Re: [REQ] Fix add ammo
Reply With Quote #1

If you want to add 1 bpammo, use this

Code:
stock addBpAmmo( index , weapon , num ) {      new newAmmo = (cs_get_user_bpammo( id , weapon )+num)      cs_set_user_bpammo( index , weapon , newAmmo ) }

addBpAmmo( id , CSW_AWP , 1 )

PS : To remove ammo, use negative values.

PS2: Untested.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-24-2011 , 06:00   Re: [REQ] Fix add ammo
Reply With Quote #2

Quote:
Originally Posted by Devil259 View Post
Code:
stock addBpAmmo( index , weapon , num ) {      cs_set_user_bpammo( index , weapon , cs_get_user_bpammo( id , weapon ) + num ) }
Simplified.


Following one could be usefull :
PHP Code:
enum
{
    
ammo_none,
    
ammo_338magnum 1,
    
ammo_762nato,
    
ammo_556natobox,
    
ammo_556nato,
    
ammo_buckshot,
    
ammo_45acp,
    
ammo_57mm,
    
ammo_50ae,
    
ammo_357sig,
    
ammo_9mm
}

new const 
g_szAmmoNames[][] = {
    
"",
    
"338magnum",
    
"762nato",
    
"556natobox",
    
"556nato",
    
"buckshot",
    
"45acp",
    
"57mm",
    
"50ae",
    
"357sig",
    
"9mm"
}

new const 
g_iMaxAmmo[] = {-1309020090321001003552120}
new const 
g_iDefaultAmmo[] = {-1103030308125071330}

addBpAmmo(idiIdamount = -1max = -1)
{
    new 
iAmmoType
    
switch(iId)
    {
        case 
CSW_AWPiAmmoType ammo_338magnum
        
case CSW_SCOUTCSW_AK47CSW_G3SG1iAmmoType ammo_762nato
        
case CSW_M249iAmmoType ammo_556natobox
        
case CSW_FAMASCSW_M4A1CSW_AUGCSW_SG550CSW_GALICSW_SG552iAmmoType ammo_556nato
        
case CSW_M3CSW_XM1014iAmmoType ammo_buckshot
        
case CSW_USPCSW_UMP45CSW_MAC10iAmmoType ammo_45acp
        
case CSW_FIVESEVENCSW_P90iAmmoType ammo_57mm
        
case CSW_DEAGLEiAmmoType ammo_50ae
        
case CSW_P228iAmmoType ammo_357sig
        
case CSW_GLOCK18CSW_MP5NAVYCSW_TMPCSW_ELITEiAmmoType ammo_9mm
        
default:return 0
    
}
    switch( 
max )
    {
        case -
1:max g_iMaxAmmo[iAmmoType]
        case 
0:max 999999999
    
}
    if( 
amount == -// give default
    
{
        
amount g_iDefaultAmmo[iAmmoType]
    }
    
ExecuteHamB(Ham_GiveAmmoidamountg_szAmmoNames[iAmmoType], max)

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-24-2011 at 06:13.
ConnorMcLeod is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-24-2011 , 08:07   Re: [REQ] Fix add ammo
Reply With Quote #3

Quote:
Originally Posted by Devil259 View Post
Code:
stock addBpAmmo( index , weapon , num ) {      cs_set_user_bpammo( index , weapon , cs_get_user_bpammo( id , weapon ) + num ) }
addBpAmmo( id , CSW_AWP , 1 )
__________________
You can do anything you set your mind to, man.

Devil259 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 11:50.


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