So get_user_weapons has a 3rd param, at first I thought this was just so that we would know how many weapons the user has...
I'm curious as to why it adds this number to the initial array position?
Code:
static cell AMX_NATIVE_CALL get_user_weapons(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index < 1 || index > gpGlobals->maxClients){
LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d", index);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
cell *cpNum = get_amxaddr(amx,params[3]);
cell *cpIds = get_amxaddr(amx,params[2]);
*cpIds = 0;
int weapons = pPlayer->pEdict->v.weapons & ~(1<<31); // don't count last element
for(int i = 1; i < MAX_WEAPONS; ++i)
{
if (weapons & (1<<i))
{
*(cpIds+(*cpNum)) = i;
(*cpNum)++;
}
}
return weapons;
}
return 0;
}
Notice the
Code:
*(cpIds+(*cpNum)) = i;
Why is it +cpNum? Just spent like 40 minutes debugging b/c I thought I f'ed something up then I noticed this...
Was just curious why this decision was made? I can't see the point
Josh
__________________