Senior Member
07-24-2013
, 12:57
Re: [CSGO] SDKCalls
#8
Quote:
Originally Posted by
HAWK0044
2mcpan313:
It's just max ammo in general, not into weapon magazine, and use cvars for getting weapon max clips is really poor.
Why use cvars is really poor.
PHP Code:
// PrintToChat(client, "ammo=%i/%i (max:%i)", GetWeaponPrimaryAmmo(client), GetWeaponSecondaryAmmo(client), GetWeaponAmmoMax(client));
stock GetWeaponPrimaryAmmo ( client , weapon = 0 )
{
if (! weapon &&
( weapon = GetEntPropEnt ( client , Prop_Send , "m_hActiveWeapon" )) == - 1 )
{
return - 1 ;
}
return GetEntProp ( weapon , Prop_Data , "m_iClip1" );
}
stock GetWeaponSecondaryAmmo ( client , weapon = 0 )
{
if (! weapon &&
( weapon = GetEntPropEnt ( client , Prop_Send , "m_hActiveWeapon" )) == - 1 )
{
return - 1 ;
}
static ammo_offset ;
if ( ammo_offset < 1 )
{
ammo_offset = FindSendPropOffs ( "CCSPlayer" , "m_iAmmo" );
}
new ammo_type = GetEntProp ( weapon , Prop_Data , "m_iPrimaryAmmoType" );
return GetEntData ( client , ammo_offset + ( ammo_type * 4 ));
}
stock GetWeaponAmmoMax ( client , weapon = 0 )
{
if (! weapon &&
( weapon = GetEntPropEnt ( client , Prop_Send , "m_hActiveWeapon" )) == - 1 )
{
return - 1 ;
}
new index = WeaponToIndex ( weapon );
if ( index == - 1 )
{
return - 1 ;
}
__findAmmoMaxCvar ();
return __getAmmoMax ( index );
}
enum WeaponAmmo
{
ammo_338mag_max ,
ammo_357sig_max ,
ammo_45acp_max ,
ammo_50AE_max ,
ammo_556mm_box_max ,
ammo_556mm_max ,
ammo_57mm_max ,
ammo_762mm_max ,
ammo_9mm_max ,
ammo_buckshot_max
}
static const String : g_szWeaponAmmo [][]=
{
"ammo_338mag_max" ,
"ammo_357sig_max" ,
"ammo_45acp_max" ,
"ammo_50AE_max" ,
"ammo_556mm_box_max" ,
"ammo_556mm_max" ,
"ammo_57mm_max" ,
"ammo_762mm_max" ,
"ammo_9mm_max" ,
"ammo_buckshot_max"
};
static Handle : g_hWeaponAmmo [ WeaponAmmo ];
static const WeaponAmmo : g_nAmmoIndex []=
{
ammo_50AE_max ,
ammo_9mm_max ,
ammo_57mm_max ,
ammo_9mm_max ,
ammo_357sig_max ,
ammo_357sig_max ,
ammo_9mm_max ,
ammo_762mm_max ,
ammo_762mm_max ,
ammo_556mm_max ,
ammo_556mm_max ,
ammo_556mm_max ,
ammo_556mm_max ,
ammo_buckshot_max ,
ammo_buckshot_max ,
ammo_buckshot_max ,
ammo_buckshot_max ,
ammo_9mm_max ,
ammo_45acp_max ,
ammo_9mm_max ,
ammo_9mm_max ,
ammo_57mm_max ,
ammo_45acp_max ,
ammo_338mag_max ,
ammo_762mm_max ,
ammo_762mm_max ,
ammo_762mm_max ,
ammo_556mm_box_max ,
ammo_556mm_box_max
};
static const String : g_szWeaponName [][]=
{
"weapon_deagle" ,
"weapon_elite" ,
"weapon_fiveseven" ,
"weapon_glock" ,
"weapon_hkp2000" ,
"weapon_p250" ,
"weapon_tec9" ,
"weapon_ak47" ,
"weapon_aug" ,
"weapon_famas" ,
"weapon_galilar" ,
"weapon_m4a1" ,
"weapon_sg556" ,
"weapon_mag7" ,
"weapon_nova" ,
"weapon_sawedoff" ,
"weapon_xm1014" ,
"weapon_bizon" ,
"weapon_mac10" ,
"weapon_mp7" ,
"weapon_mp9" ,
"weapon_p90" ,
"weapon_ump45" ,
"weapon_awp" ,
"weapon_g3sg1" ,
"weapon_scar20" ,
"weapon_ssg08" ,
"weapon_m249" ,
"weapon_negev"
};
static WeaponToIndex ( weapon )
{
decl String : classname [ 64 ];
GetEdictClassname ( weapon , classname , sizeof ( classname ));
for (new index ; index < sizeof ( g_szWeaponName ); index ++)
{
if (! strcmp ( g_szWeaponName [ index ], classname ))
{
return index ;
}
}
return - 1 ;
}
static __findAmmoMaxCvar ()
{
if ( g_hWeaponAmmo [ 0 ] == INVALID_HANDLE )
{
for (new index ; index < _ : WeaponAmmo ; index ++)
{
g_hWeaponAmmo [ index ] = FindConVar ( g_szWeaponAmmo [ index ]);
}
}
}
static __getAmmoMax ( index )
{
return GetConVarInt ( g_hWeaponAmmo [ g_nAmmoIndex [ index ]]);
}
And GiveAmmo offset:
PHP Code:
"Games"
{
"csgo"
{
"Offsets"
{
// http://www.sourcemodplugins.org/vtableoffsets/csgo
// CBaseCombatCharacter::GiveAmmo(int, int, bool)
"GiveAmmo"
{
"windows" "270"
"linux" "271"
"mac" "271"
}
}
}
}
__________________
sorry, for my poor english.