Connecting Tech Pros Worldwide Help | Site Map

Undeclared Identifier, Only found solutions, not reasons

Newbie
 
Join Date: Apr 2009
Posts: 1
#1: Apr 20 '09
Hey everyone, i've been browsing for a fix to my problem
1>c:\documents and settings\user\desktop\judis_repack\judis repack\judis repack\maplestoryserver\inventory.cpp(386) : error C2065: 'amount' : undeclared identifier
I've found some solutions but I'm not sure how they pertain to my problem. If possible, would there be any general methods of resolving such undeclared identifier problems? This is the string, I'm a complete beginner so i'm really bad a this. Thanks


void Inventory::takeItem(Player* player, int item, int howmany){
for(int i=0; i<player->inv->getItemNum(); i++)
if(player->inv->getItem(i)->id == item){
if(player->inv->getItem(i)->amount>=howmany){
Item* item = player->inv->getItem(i);
item->amount-=howmany;
howmany=0;
if (ISSTAR(item->id)) amount = item->amount;
if(item->amount == 0){
InventoryPacket::moveItem(player, item->inv, item->pos, 0);
player->inv->deleteItem(i);
}
else
InventoryPacket::moveItemS(player, item->inv, item->pos, item->amount);
break;
}
else{
Item* item = player->inv->getItem(i);
howmany-=item->amount;
item->amount=0;
InventoryPacket::moveItem(player, item->inv, item->pos, 0);
player->inv->deleteItem(i);
}
}
}
Savage's Avatar
Expert
 
Join Date: Feb 2007
Posts: 1,737
#2: Apr 20 '09

re: Undeclared Identifier, Only found solutions, not reasons


Quote:

Originally Posted by LuxCkrown View Post

Hey everyone, i've been browsing for a fix to my problem
1>c:\documents and settings\user\desktop\judis_repack\judis repack\judis repack\maplestoryserver\inventory.cpp(386) : error C2065: 'amount' : undeclared identifier
I've found some solutions but I'm not sure how they pertain to my problem. If possible, would there be any general methods of resolving such undeclared identifier problems? This is the string, I'm a complete beginner so i'm really bad a this. Thanks


Expand|Select|Wrap|Line Numbers
  1. void Inventory::takeItem(Player* player, int item, int howmany){
  2.     for(int i=0; i<player->inv->getItemNum(); i++)
  3.         if(player->inv->getItem(i)->id == item){
  4.             if(player->inv->getItem(i)->amount>=howmany){
  5.                 Item* item = player->inv->getItem(i);
  6.                 item->amount-=howmany;
  7.                 howmany=0;
  8.                 if (ISSTAR(item->id)) amount = item->amount;
  9.                 if(item->amount == 0){
  10.                     InventoryPacket::moveItem(player, item->inv, item->pos, 0);
  11.                     player->inv->deleteItem(i);
  12.                 }
  13.                 else
  14.                     InventoryPacket::moveItemS(player, item->inv, item->pos, item->amount);
  15.                 break;
  16.             }
  17.             else{
  18.                 Item* item = player->inv->getItem(i);
  19.                 howmany-=item->amount;
  20.                 item->amount=0;
  21.                 InventoryPacket::moveItem(player, item->inv, item->pos, 0);
  22.                 player->inv->deleteItem(i);
  23.             }
  24.         }
}

Is amount member of the Inventory class?

PS:Please use code tags (# button)
Reply