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());
    
    }
  • 相关阅读:
    co模块总结
    Promise总结
    webpack错误Chunk.entry was removed. Use hasRuntime()
    jquery validate用法总结
    node命令行开发
    animation总结
    formData使用总结
    vue-resource发送multipart/form-data数据
    keil中使用Astyle格式化你的代码的方法-keil4 keil5通用
    tcpip入门的网络教程汇总
  • 原文地址:https://www.cnblogs.com/needly/p/3758740.html
Copyright © 2011-2022 走看看