吾爱尚玩资源基地
标题:
M端单机版一个竞技点,荣誉点,积分交易系统
[打印本页]
作者:
admin
时间:
2016-4-23 16:50
标题:
M端单机版一个竞技点,荣誉点,积分交易系统
这个是一个比较老的Mangos服务端的脚本代码。应用在Scriptdev2脚本中。次代码比较老了,不错作为参考使用还是可以的。
可以借鉴该思路,然后做出自己的脚本
#include "../sc_defines.h"
#include "../../../../game/Item.h"
#include "../../../../game/Player.h"
#include "../../../../game/SpellAuras.h"
#include "../../../../game/GossipDef.h"
#include "../../../../game/Chat.h"
bool GossipHello_ItemUse_honor_arena(Player *player, Item* _Item, SpellCastTargets const& targets)
{
player->CLEAR_GOSSIP_MENU();
if (!player->isDead())
{
player->SEND_GOSSIP_MENU(999999,_Item->GetGUID());
return true;
}
else
{
return true;
}
}
void SendDefaultMenu_ItemUse_honor_arena(Player *player, Item *_Item, uint32 action ,SpellCastTargets const& targets)
{
GetconfigHoner<<" 积分换荣誉点-多少积分换一荣誉点: "<<player->GetMyintConfig("IntegralDealHonor");
GetconfigArena<<" 积分换竞技点-多少积分换一竞技点: "<<player->GetMyintConfig("IntegralDealArena");
GetconfigMaxLevel<<" 最少多少等级-才能开始交易: "<<player->GetMyintConfig("MaxLevelDealHonorArena");
switch(action) {
//【高级陆地坐骑】
case GOSSIP_ACTION_INFO_DEF + 1 :
player->ADD_GOSSIP_ITEM( 0, GetconfigHoner.str().c_str(), 2, GOSSIP_ACTION_INFO_DEF + 1);
player->ADD_GOSSIP_ITEM( 0, GetconfigArena.str().c_str(), 2, GOSSIP_ACTION_INFO_DEF + 2);
player->ADD_GOSSIP_ITEM( 0, GetconfigMaxLevel.str().c_str(), 2, GOSSIP_ACTION_INFO_DEF + 5);
player->ADD_GOSSIP_ITEM( 7, "需要积分为0,为关闭状态 ", 3, GOSSIP_ACTION_INFO_DEF + 99);
player->SEND_GOSSIP_MENU(999999,_Item->GetGUID());
break;
}
}
bool GossipSelect_ItemUse_honor_arena(Player *player, Item *_Item, uint32 sender, uint32 action ,SpellCastTargets const& targets)
{
int icount = 0;
//uint32 price_city;
switch(sender) {
// 主选单
case 1 :
SendDefaultMenu_ItemUse_honor_arena(player, _Item, action,targets);
break;
case 2 ://积分交易开始
// 等级交易,金币交易系统的公式开始
uint32 jf = player->GetAccountJf(player->GetSession()->GetAccountId());//获得用户当前积分
uint32 jfpointhoner = player->GetMyintConfig("IntegralDealHonor"); //获得配置文件多少积分换一个荣誉点
uint32 jfpointarena = player->GetMyintConfig("IntegralDealArena");//获得配置文件多少积分换一个竞技点
uint32 HonerNow = player->GetHonorPoints(); //获得当前用户的荣誉点
uint32 ArenaNow = player->GetArenaPoints(); //获得当前用户的荣誉点
if (jfpointhoner > 0)
honerjfless = jf - 1; //交易荣誉点后用户的积分
if (jfpointarena > 0)
arenajfless = jf - 1; //交易竞技点后用户的积分
else
return false;
uint64 guid; //获得当前用户的帐号ID
guid = player->GetSession()->GetAccountId();
// 等级荣誉点,竞技点交易系统的公式结束
switch(action) {
case GOSSIP_ACTION_INFO_DEF + 1 : //积分换荣誉点
if (jf > 0 && jfpointhoner >= 1 && plevel >= player->GetMyintConfig("MaxLevelDealHonorArena"))
{
player->SetAccountJf(honerjfless,guid);
player->SetHonorPoints(HonerNow+jfpointhoner); //交易积分后,用户获得的荣誉点+1
player->CLOSE_GOSSIP_MENU();
}
else
{
player->GetSession()->SendAreaTriggerMessage("对不起积分不够,或则交易系统关闭中");
GossipHello_ItemUse_honor_arena(player,_Item,targets);
}
break;
case GOSSIP_ACTION_INFO_DEF + 2 : //积分换竞技点
if (jf > 0 && jfpointarena >= 1 && plevel >= player->GetMyintConfig("MaxLevelDealHonorArena"))
{
player->SetAccountJf(arenajfless,guid);
player->SetArenaPoints(ArenaNow+jfpointarena);
player->CLOSE_GOSSIP_MENU();
}
else
{
player->GetSession()->SendAreaTriggerMessage("对不起积分不够,或则交易系统关闭中");
GossipHello_ItemUse_honor_arena(player,_Item,targets);
}
break;
case GOSSIP_ACTION_INFO_DEF + 99 :
{
GossipHello_ItemUse_honor_arena(player,_Item,targets);//返回菜单
break;
}
}
break;
}
return true;
}
void AddSC_honor_arena()
{
Script *newscript;
newscript = new Script;
newscript->Name="honor_arena";
newscript->pItemUse = GossipHello_ItemUse_honor_arena;
newscript->pGossipSelect_Item = GossipSelect_ItemUse_honor_arena;
m_scripts[nrscripts++] = newscript;
}
欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/)
Powered by Discuz! X3.4