zoukankan      html  css  js  c++  java
  • T端查看和修改积分的功能

    飞狐魔兽代码

    //修改积分
    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());
    
    }
  • 相关阅读:
    002.NFS相关配置项
    001.NFS简介
    002.DNS-BIND简介
    001.DNS原理及配置格式
    002.DHCP配置
    001.DHCP简介
    001.Chrony时间服务器
    博客开篇记载!
    【python-opencv】图像梯度
    【python-opencv】形态转换
  • 原文地址:https://www.cnblogs.com/needly/p/3758740.html
Copyright © 2011-2022 走看看