mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
Added cs_get_weapon_ammo/cs_set_weapon_ammo
This commit is contained in:
parent
b21bbcbf90
commit
bbbe0cda78
@ -1185,6 +1185,57 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params) // cs_
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cs_get_weapon_ammo(AMX *amx, cell *params) // cs_get_weapon_ammo(index); = 1 param
|
||||
{
|
||||
// Get amount of ammo in weapon's clip
|
||||
// params[1] = weapon index
|
||||
|
||||
// Valid entity should be within range
|
||||
if (params[1] < 1 || params[1] > gpGlobals->maxEntities)
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t *pWeapon = INDEXENT(params[1]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pWeapon)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return *(int *)pWeapon->pvPrivateData + OFFSET_CLIPAMMO;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cs_set_weapon_ammo(AMX *amx, cell *params) // cs_set_weapon_ammo(index, newammo); = 2 params
|
||||
{
|
||||
// Set amount of ammo in weapon's clip
|
||||
// params[1] = weapon index
|
||||
// params[2] = newammo
|
||||
|
||||
// Valid entity should be within range
|
||||
if (params[1] < 1 || params[1] > gpGlobals->maxEntities)
|
||||
{
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make into edict pointer
|
||||
edict_t *pWeapon = INDEXENT(params[1]);
|
||||
|
||||
// Check entity validity
|
||||
if (FNullEnt(pWeapon)) {
|
||||
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*((int *)pWeapon->pvPrivateData + OFFSET_CLIPAMMO) = params[2];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO cstrike_Exports[] = {
|
||||
{"cs_set_user_money", cs_set_user_money},
|
||||
{"cs_get_user_money", cs_get_user_money},
|
||||
@ -1213,6 +1264,8 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
|
||||
{"cs_get_user_model", cs_get_user_model},
|
||||
{"cs_set_user_model", cs_set_user_model},
|
||||
{"cs_reset_user_model", cs_reset_user_model},
|
||||
{"cs_set_weapon_ammo", cs_set_weapon_ammo},
|
||||
{"cs_get_weapon_ammo", cs_get_weapon_ammo},
|
||||
//------------------- <-- max 19 characters!
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
#define __cswonbuild__ // comment when compiling for STEAM
|
||||
//#define __cswonbuild__ // comment when compiling for STEAM
|
||||
#define CS_WON_BUILD
|
||||
|
||||
/* AMX Mod X
|
||||
@ -113,9 +113,9 @@ pfnmodule_engine_g* g_engModuleFunc;
|
||||
#define OFFSET_CSDEATHS 448 + EXTRAOFFSET // differs -1 from STEAM
|
||||
// "weapon_*" entities
|
||||
#define OFFSET_WEAPONTYPE 43 + EXTRAOFFSET // same as STEAM
|
||||
//#define OFFSET_CLIPAMMO 51 + EXTRAOFFSET // not tested under WON!!!!!!!!!!!!!!!!!!
|
||||
#define OFFSET_SILENCER_FIREMODE 70 + EXTRAOFFSET // differs -4 from STEAM
|
||||
// "hostage_entity" entities
|
||||
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET // NOT YET CHECKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! find out before build
|
||||
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET // same as STEAM
|
||||
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET // same as STEAM
|
||||
#else // from here STEAM build looks for offsets
|
||||
@ -145,6 +145,7 @@ pfnmodule_engine_g* g_engModuleFunc;
|
||||
#define OFFSET_CSDEATHS 449 + EXTRAOFFSET
|
||||
// "weapon_*" entities
|
||||
#define OFFSET_WEAPONTYPE 43 + EXTRAOFFSET
|
||||
#define OFFSET_CLIPAMMO 51 + EXTRAOFFSET
|
||||
#define OFFSET_SILENCER_FIREMODE 74 + EXTRAOFFSET
|
||||
// "hostage_entity" entities
|
||||
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET
|
||||
|
Loading…
Reference in New Issue
Block a user