Hi guys, this is driving me absolutely nuts! why on earth is this not working!!!!
int m_ntotalSAS = 0;
int iCounter2 = 0;
//reset the total number of sas
m_ntotalSAS = 0;
//work out how many SAS their are in total
for (int i = 1; i <= 32; i++ )
{
CHL2MP_Player *plr = (CHL2MP_Player*) UTIL_PlayerByIndex( i );
if ( plr )
{
if ( plr->GetTeamNumber() == 3){
m_ntotalSAS++;
}
}
}
//check to see if the entity that we hit is a player
CBaseEntity *pPlayer = dynamic_cast<CBaseEntity *>(pOther);
iCounter2 = 0;
int iSAScounter;
iSAScounter = 0;
int iArraypos;
iArraypos = 0;
if(pPlayer){
//our person is a player
if ( pPlayer->GetTeamNumber() == 3){
//search through our array to see if his handle is already in their, if not add it
//search
for (int i = 0; i <= 32; i++ )
{
if ( m_nSAS[ i ] == pPlayer->GetServerHandle()){
//we found our player in teh array dont bother diong anythuing
iCounter2++;
}
if (m_nSAS[ i ] == NULL){
//let us know the position of a blank slot plz
iArraypos = i;
}else{
iSAScounter++;
}
}
}
}
in the first FOR loop, the m_ntotalSAS++ gets called once, which should increment that integer by 1?
instead i get some horrible number that changes every single time to something completely random. whats going on??
the same thing is happening with iSAScounter++; and iCounter2++;
they are all returning horrible values?! and i havent got a clue why its doing that. whats going wrong?
Neowin says it's $39.99, but their site says $399.99 after discount. Is Neowin covering the difference? I'll take 7 if they are. Not 8, not 6, never 5, but 7.
Yeah and now they added space above the tab bar, so now I have to painstakingly aim at just slightly below the top of the screen to reach a tab with my mouse.
truly hate it
Question
Alex the man
Hi guys, this is driving me absolutely nuts! why on earth is this not working!!!!
int m_ntotalSAS = 0; int iCounter2 = 0; //reset the total number of sas m_ntotalSAS = 0; //work out how many SAS their are in total for (int i = 1; i <= 32; i++ ) { CHL2MP_Player *plr = (CHL2MP_Player*) UTIL_PlayerByIndex( i ); if ( plr ) { if ( plr->GetTeamNumber() == 3){ m_ntotalSAS++; } } } //check to see if the entity that we hit is a player CBaseEntity *pPlayer = dynamic_cast<CBaseEntity *>(pOther); iCounter2 = 0; int iSAScounter; iSAScounter = 0; int iArraypos; iArraypos = 0; if(pPlayer){ //our person is a player if ( pPlayer->GetTeamNumber() == 3){ //search through our array to see if his handle is already in their, if not add it //search for (int i = 0; i <= 32; i++ ) { if ( m_nSAS[ i ] == pPlayer->GetServerHandle()){ //we found our player in teh array dont bother diong anythuing iCounter2++; } if (m_nSAS[ i ] == NULL){ //let us know the position of a blank slot plz iArraypos = i; }else{ iSAScounter++; } } } }in the first FOR loop, the m_ntotalSAS++ gets called once, which should increment that integer by 1?
instead i get some horrible number that changes every single time to something completely random. whats going on??
the same thing is happening with iSAScounter++; and iCounter2++;
they are all returning horrible values?! and i havent got a clue why its doing that. whats going wrong?
-Alex
Link to comment
https://www.neowin.net/forum/topic/636135-c-counter-madness/Share on other sites
1 answer to this question
Recommended Posts