mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Added tfc_get/setweaponammo to set ammo in weapon's clip (not backpack ammo)
This commit is contained in:
parent
5b47da7cee
commit
74d3d23f13
@ -8,14 +8,12 @@
|
||||
|
||||
#ifndef __linux__
|
||||
#define LINUXOFFSET 0
|
||||
#define WEAP_LINUXOFFSET 0
|
||||
#define CLIP_LINUXOFFSET 0
|
||||
#else
|
||||
#define LINUXOFFSET 5
|
||||
#endif
|
||||
|
||||
#ifndef __linux__
|
||||
#define WEAP_LINUXOFFSET 0
|
||||
#else
|
||||
#define WEAP_LINUXOFFSET 3
|
||||
#define CLIP_LINUXOFFSET 4
|
||||
#endif
|
||||
|
||||
#define TFCMAX_CUSTOMWPNS 5
|
||||
@ -39,6 +37,8 @@
|
||||
#define PD_AMMO_NADE1 14 + WEAP_LINUXOFFSET
|
||||
#define PD_AMMO_NADE2 15 + WEAP_LINUXOFFSET
|
||||
|
||||
#define PD_WEAPON_AMMO 307 + CLIP_LINUXOFFSET
|
||||
|
||||
enum {
|
||||
TFC_AMMO_SHELLS = 0,
|
||||
TFC_AMMO_BULLETS,
|
||||
|
@ -320,6 +320,28 @@ static cell AMX_NATIVE_CALL TFC_SetWeaponBAmmo(AMX *amx, cell *params) {
|
||||
}
|
||||
// AssKicR end :)
|
||||
|
||||
static cell AMX_NATIVE_CALL TFC_GetWeaponAmmo(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
|
||||
CHECK_NONPLAYER(index);
|
||||
edict_t *weapon = INDEXENT(index);
|
||||
|
||||
return *((int *)weapon->pvPrivateData + PD_WEAPON_AMMO);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL TFC_SetWeaponAmmo(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
|
||||
CHECK_NONPLAYER(index);
|
||||
edict_t *weapon = INDEXENT(index);
|
||||
|
||||
*((int *)weapon->pvPrivateData + PD_WEAPON_AMMO) = params[2];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL TFC_GetWpnName(AMX *amx, cell *params) {
|
||||
int iIndex = params[1];
|
||||
if ( iIndex < 1 || iIndex > TFCMAX_WEAPONS ){
|
||||
@ -401,6 +423,8 @@ AMX_NATIVE_INFO base_Natives[] = {
|
||||
{"tfc_getbammo", TFC_GetBAmmo},
|
||||
{"tfc_getweaponbammo", TFC_GetWeaponBAmmo},
|
||||
{"tfc_setweaponbammo", TFC_SetWeaponBAmmo},
|
||||
{"tfc_getweaponammo", TFC_GetWeaponAmmo},
|
||||
{"tfc_setweaponammo", TFC_SetWeaponAmmo},
|
||||
|
||||
{"xmod_get_wpnname", TFC_GetWpnName},
|
||||
{"xmod_get_wpnlogname", TFC_GetWpnLogName},
|
||||
|
@ -119,3 +119,11 @@ native tfc_getweaponbammo(index, weapon);
|
||||
|
||||
/* Sets amount of ammo in weapon's clip (backpack) */
|
||||
native tfc_setweaponbammo(index, weapon, value);
|
||||
|
||||
/* Returns amount of ammo in weapon's clip */
|
||||
/* Index must be weapon's entity index */
|
||||
native tfc_getweaponammo(index);
|
||||
|
||||
/* Sets amount of ammo in weapon's clip */
|
||||
/* Index must be weapon's entity index */
|
||||
native tfc_setweaponammo(index, value);
|
||||
|
Loading…
Reference in New Issue
Block a user