Hello,
Today I tried out to retrieve player's weapon ammo inside FM_PlaybackEvent but every time I ran into this error:
PHP Code:
[CSTRIKE] Non-player entity 1 out of range
Code:
PHP Code:
public fw_PlaybackEvent(flags, iPlayer, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
if(!is_user_connected(iPlayer) || !pev_valid(iPlayer))
return;
server_print("Entities: %d/%d", entity_count(), global_get(glb_maxEntities))
static iClip;
iClip = cs_get_weapon_ammo(iPlayer);
}
http://www.amxmodx.org/api/cstrike/cs_get_weapon_ammo
PHP Code:
index
Weapon entity index
In API docs it's specified that the index should be a weapon entity, but after looking in the core code I saw that is not right; Index param should be player's index:
PHP Code:
// native cs_get_weapon_ammo(index);
static cell AMX_NATIVE_CALL cs_get_weapon_ammo(AMX *amx, cell *params)
{
GET_OFFSET("CBasePlayerWeapon", m_iClip);
int index = params[1];
CHECK_NONPLAYER(index);
edict_t *pWeapon = TypeConversion.id_to_edict(index);
return get_pdata<int>(pWeapon, m_iClip);
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(TypeConversion.id_to_edict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
It said that "Non-player entity 1 out of range" which is not right at all because player is connected to server and it can't exceed MaxEntities according to my debugging:
PHP Code:
server_print("Entities: %d/%d", entity_count(), global_get(glb_maxEntities))
Output: Entities: 126/1365
__________________