Raised This Month: $ Target: $400
 0% 

get_user_weapons question on 3rd param


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 04-13-2006 , 00:52   get_user_weapons question on 3rd param
Reply With Quote #1

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
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode