本文整理汇总了C++中P_CHAR::CountItems方法的典型用法代码示例。如果您正苦于以下问题:C++ P_CHAR::CountItems方法的具体用法?C++ P_CHAR::CountItems怎么用?C++ P_CHAR::CountItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_CHAR
的用法示例。
在下文中一共展示了P_CHAR::CountItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkReq
/*!
\brief Check if the player is skilled enough and have requested items
\return bool can or can't
\param pc the player
\param inMenu if write a sysmessage on error
\todo Add message if haven't enough item..
*/
bool cMakeItem::checkReq( P_CHAR pc, bool inMenu, cRawItem* def )
{
if( pc->IsGM() )
return true;
if( (skillToCheck!=INVALID) && (pc->skill[skillToCheck]<minskill) ) {
if( !inMenu )
pc->sysmsg(TRANSLATE("You're not enough skilled"));
return false;
}
for( int i=0; i<2; ++i ) {
cRawItem& raw = reqitems[i];
if( raw.id!=0 ) {
bool have = ( def!=NULL )? (def[i].number>=raw.number) : ( pc->CountItems( raw.id, raw.color)>= raw.number );
if( !have ) {
if( !inMenu )
pc->sysmsg(TRANSLATE("You've not enough resources"));
return false;
}
}
}
return true;
}
示例2: loadFromScript
void cMakeMenu::loadFromScript( P_CHAR pc )
{
VALIDATEPC(pc);
NXWCLIENT ps = pc->getClient();
if( ps==NULL ) return;
cScpIterator* iter = Scripts::Create->getNewIterator("SECTION MAKEMENU %i", section);
if (iter==NULL) return;
std::vector<std::string> names; //name
std::vector<std::string> models; //models
this->mat[0].number = ( mat[0].id!=0 )? pc->CountItems( mat[0].id, mat[0].color ) : 0;
this->mat[1].number = ( mat[1].id!=0 )? pc->CountItems( mat[1].id, mat[1].color ) : 0;
//da passare a checkReq PDPD
cMakeItem* imk = NULL;
pc->making=skill;
oldmenu->style=MENUTYPE_ICONLIST;
/* makemenu menu
SECTION MAKEMENU 1
{
Blacksmithing
1416 Armor
RESOURCE 10
SKILL 500
MAKEMENU 3
13BA Weapons
RESOURCE 3
SKILL 100
MAKEMENU 4
1BC3 Shields
RESOURCE 8
SKILL 250
MAKEMENU 2
09ed Misc
RESOURCE 6
SKILL 150
MAKEMENU 105
}
*/
/* makemenu item
SECTION MAKEMENU 2002
{
Golden Ring Mail
13F2 Gloves
RESOURCE 10
SKILL 338
ADDITEM $item_golden_ringmail_gloves
13EF Sleeves
RESOURCE 14
SKILL 385
ADDITEM $item_golden_ringmail_sleeves
13F1 Leggings
RESOURCE 16
SKILL 408
ADDITEM $item_golden_ringmail_leggings
13ED Tunic
RESOURCE 18
SKILL 432
ADDITEM $item_golden_ringmail_tunic
}
*/
enum MakeParamType {
MAKE_NEED_NAME = 0, //Blacksmithing
MAKE_NEED_INFO, //1416 Armor
MAKE_NEED_RESOURCE, //RESOURCE 10
MAKE_NEED_SKILL, //SKILL 500
MAKE_NEED_MENUORITEM, //MAKEMENU 3 or ADDITEM $item_golden_ringmail_tunic
};
MakeParamType type = MAKE_NEED_NAME;
bool error=false;
bool canSee = true;
int item = INVALID;
int loopexit=0;
do
{
std::string lha;
std::string rha;
iter->parseLine(lha, rha);
if( lha[0]=='{' )
continue;
if( lha[0]=='}' )
break;
switch( type ) {
case MAKE_NEED_NAME: //Blacksmithing
string2wstring( lha, oldmenu->title );
//.........这里部分代码省略.........