飞狐魔兽代码
//修改积分 bool ChatHandler::HandleAddjifen(const char* args) { Player *chr = getSelectedPlayer(); if (chr == NULL) { SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); return false; } int32 addmoney = atoi((char*)args); chr->modifyjifen (addmoney); chr->GetSession()->SendNotification("修改积分成功"); return true; } // 积分查询 bool ChatHandler::HandleSeejifen(const char* args) { int32 usermoney = m_session->GetPlayer()->getjifen(); std::stringstream sstr; std::string a; sstr<<usermoney; sstr>>a; a="您当前积分为"+a; m_session->GetPlayer()->GetSession()->SendNotification(a.c_str()); return true; } 还需新增player的两个函数 //从数据库获取积分 uint32 Player::getjifen() { QueryResult *result; result = loginDatabase.PQuery("select jifen from jf where accid = %u",GetSession()->GetAccountId()); if (result) { uint32 a = result->Fetch()[0].GetUInt32();; delete result; return a; } delete result; return 0; } //从数据库修改积分 void Player::modifyjifen(int32 a) { int32 moneyuser = getjifen(); int32 newmoney = moneyuser + a; if(newmoney<0) loginDatabase.PExecute("update jf set jifen = 0 where accid = %u",GetSession ()->GetAccountId()); else loginDatabase.PExecute("update jf set jifen = %u where accid = %u",newmoney,GetSession ()->GetAccountId()); }