From 74d3d23f13720b74ad4b288c5542782af513be1e Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 21 Aug 2006 13:50:51 +0000 Subject: [PATCH] Added tfc_get/setweaponammo to set ammo in weapon's clip (not backpack ammo) --- dlls/tfc/tfcx/CMisc.h | 10 +++++----- dlls/tfc/tfcx/NBase.cpp | 24 ++++++++++++++++++++++++ plugins/include/tfcx.inc | 10 +++++++++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/dlls/tfc/tfcx/CMisc.h b/dlls/tfc/tfcx/CMisc.h index c68a73e1..5d88adec 100755 --- a/dlls/tfc/tfcx/CMisc.h +++ b/dlls/tfc/tfcx/CMisc.h @@ -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, diff --git a/dlls/tfc/tfcx/NBase.cpp b/dlls/tfc/tfcx/NBase.cpp index a516ba66..897d469d 100755 --- a/dlls/tfc/tfcx/NBase.cpp +++ b/dlls/tfc/tfcx/NBase.cpp @@ -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}, diff --git a/plugins/include/tfcx.inc b/plugins/include/tfcx.inc index 15836d63..b1fdb73a 100755 --- a/plugins/include/tfcx.inc +++ b/plugins/include/tfcx.inc @@ -118,4 +118,12 @@ native tfc_setbammo(index, ammo, value); native tfc_getweaponbammo(index, weapon); /* Sets amount of ammo in weapon's clip (backpack) */ -native tfc_setweaponbammo(index, weapon, value); \ No newline at end of file +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);