mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
Request am28110 - Added tfc_get_user_goalitem native to determine if player is carrying a goal item (such as a flag or keycard)
This commit is contained in:
parent
0cb316c764
commit
58abc3a655
@ -8,37 +8,39 @@
|
||||
|
||||
#ifndef __linux__
|
||||
#define LINUXOFFSET 0
|
||||
#define WEAP_LINUXOFFSET 0
|
||||
#define CLIP_LINUXOFFSET 0
|
||||
#else
|
||||
#define LINUXOFFSET 5
|
||||
#define WEAP_LINUXOFFSET 3
|
||||
#define LINUXOFFSET 3
|
||||
#define CLIP_LINUXOFFSET 4
|
||||
#endif
|
||||
|
||||
#define TFCMAX_CUSTOMWPNS 5
|
||||
#define TFCMAX_WEAPONS MAX_WEAPONS + TFCMAX_CUSTOMWPNS
|
||||
|
||||
#define PD_HAS_GOALITEM 26 + LINUXOFFSET
|
||||
#define PD_GOALITEM_TEAM 36 + LINUXOFFSET
|
||||
#define PD_SENTRY_OWNER 83 + LINUXOFFSET
|
||||
#define PD_TIMER_OWNER 932 + LINUXOFFSET
|
||||
|
||||
#define MAX_TRACE 13
|
||||
//#define NADE_OFFSET 24
|
||||
|
||||
|
||||
#define ACT_NADE_NONE 0
|
||||
#define ACT_NADE_SHOT 1<<0
|
||||
#define ACT_NADE_PUT 1<<1
|
||||
|
||||
#define PD_AMMO_SHELLS 53 + WEAP_LINUXOFFSET
|
||||
#define PD_AMMO_BULLETS 55 + WEAP_LINUXOFFSET
|
||||
#define PD_AMMO_CELLS 57 + WEAP_LINUXOFFSET
|
||||
#define PD_AMMO_ROCKETS 59 + WEAP_LINUXOFFSET
|
||||
#define PD_AMMO_NADE1 14 + WEAP_LINUXOFFSET
|
||||
#define PD_AMMO_NADE2 15 + WEAP_LINUXOFFSET
|
||||
#define PD_AMMO_SHELLS 53 + LINUXOFFSET
|
||||
#define PD_AMMO_BULLETS 55 + LINUXOFFSET
|
||||
#define PD_AMMO_CELLS 57 + LINUXOFFSET
|
||||
#define PD_AMMO_ROCKETS 59 + LINUXOFFSET
|
||||
#define PD_AMMO_NADE1 14 + LINUXOFFSET
|
||||
#define PD_AMMO_NADE2 15 + LINUXOFFSET
|
||||
|
||||
#define PD_WEAPON_AMMO 307 + CLIP_LINUXOFFSET
|
||||
|
||||
// For tfc_get_user_goalitem
|
||||
#define CARRYING_GOALITEM (1<<0)
|
||||
|
||||
enum {
|
||||
TFC_AMMO_SHELLS = 0,
|
||||
TFC_AMMO_BULLETS,
|
||||
|
@ -342,6 +342,20 @@ static cell AMX_NATIVE_CALL TFC_SetWeaponAmmo(AMX *amx, cell *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL TFC_GetUserGoalItem(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
|
||||
CHECK_PLAYER(index);
|
||||
|
||||
edict_t *pPlayer = MF_GetPlayerEdict(index);
|
||||
cell *team = MF_GetAmxAddr(amx, params[2]);
|
||||
|
||||
*team = *((int *)pPlayer->pvPrivateData + PD_GOALITEM_TEAM);
|
||||
|
||||
return *((int *)pPlayer->pvPrivateData + PD_HAS_GOALITEM) & CARRYING_GOALITEM;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL TFC_GetWpnName(AMX *amx, cell *params) {
|
||||
int iIndex = params[1];
|
||||
if ( iIndex < 1 || iIndex > TFCMAX_WEAPONS ){
|
||||
@ -426,6 +440,8 @@ AMX_NATIVE_INFO base_Natives[] = {
|
||||
{"tfc_getweaponammo", TFC_GetWeaponAmmo},
|
||||
{"tfc_setweaponammo", TFC_SetWeaponAmmo},
|
||||
|
||||
{"tfc_get_user_goalitem", TFC_GetUserGoalItem},
|
||||
|
||||
{"xmod_get_wpnname", TFC_GetWpnName},
|
||||
{"xmod_get_wpnlogname", TFC_GetWpnLogName},
|
||||
{"xmod_is_melee_wpn", TFC_IsMelee},
|
||||
|
@ -69,3 +69,8 @@ enum {
|
||||
TFC_PC_CIVILIAN,
|
||||
};
|
||||
|
||||
// Goal items
|
||||
#define TFC_GOALITEM_BLUE (1 << 17)
|
||||
#define TFC_GOALITEM_RED (1 << 18)
|
||||
#define TFC_GOALITEM_YELLOW (1 << 24)
|
||||
#define TFC_GOALITEM_GREEN (1 << 25)
|
||||
|
@ -127,3 +127,9 @@ native tfc_getweaponammo(index);
|
||||
/* Sets amount of ammo in weapon's clip */
|
||||
/* Index must be weapon's entity index */
|
||||
native tfc_setweaponammo(index, value);
|
||||
|
||||
/* Returns 1 if user is carrying a goal item such as a flag or a keycard, else 0.
|
||||
* Team is by reference parameter that will be set to owning team(s) of the goal item.
|
||||
* Use the TFC_GOALITEM_* constants to determine the owning team.
|
||||
*/
|
||||
native tfc_get_user_goalitem(index, &team);
|
||||
|
Loading…
Reference in New Issue
Block a user