下面是一个涉及到积分系统交易的GM命令的函数参考。函数默认是MANGOS服务端的。不过你可以通过修改来支持T端的
GetAccountJf() 这个函数是自己增加的,主要是一个活的自己角色或则账号的积分数量的函数,。这里就不交代了
//普通玩家积分交易系统
bool ChatHandler::HandleTradeCommand(const char * args) {
if (!*args)
return false;
Player *target = getSelectedPlayer();
if(!target)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
return true;
}
uint32 guidtrade = 0;
if(target == m_session->GetPlayer())
{
SendSysMessage(LANG_COMMAND_TRADESELF);
return true;
guidtrade = m_session->GetPlayer()->GetSession()->GetAccountId(); //获得自己的ID号
}
uint32 guid = 0; //定义设置的用户ID
if(target)
{
guid = target->GetSession()->GetAccountId(); //获得该玩家的注册ID号
}
uint32 amount = (uint32)atoi(args);
uint32 amountself = player->GetAccountJf(guidtrade);
uint32 amountother = m_session->GetPlayer()->GetAccountJf(m_session->GetPlayer()->GetSession()->GetAccountId());
if (amount < 0 || amount > amountself)
{
SendSysMessage(LANG_BAD_VALUE);
return true;
}
uint32 amountpointadd = amountother + amount;
loginDatabase.PExecute("UPDATE `account` SET `jf` = '%u' WHERE `id` = '%u'",amountpointless,guidtrade); //交易发送方最后点数
loginDatabase.CommitTransaction();
loginDatabase.PExecute("UPDATE `account` SET `jf` = '%u' WHERE `id` = '%u'",amountpointadd,guid); //被交易方最后点数
loginDatabase.CommitTransaction();
PSendSysMessage(LANG_COMMAND_MODIFY_INTEGRAL, target->GetName(), amount);
return true;
}//普通玩家积分交易系统
|