|
代码:
//宠物装备镶嵌卡片
function CreatureEh(user, account_id, charac_no) {
var CreatureEqu = CUserCharacInfo_getCurCharacInvenW(user); //获取背包
//获取卡片栏第一格
var cardZero = CInventory_GetInvenRef(CreatureEqu, INVENTORY_TYPE_ITEM, 201);
var itemId = Inven_Item_getKey(cardZero);//获取卡片ID
//获取宠物栏宠物装备第一个格子
var CreatureEquZero = CInventory_GetInvenRef(CreatureEqu, 3, 140);
var creatureId = Inven_Item_getKey(CreatureEquZero);//获取宠物装备ID
var charac_name = api_CUserCharacInfo_getCurCharacName(user);
if ( Inven_Item_isEmpty(CreatureEquZero) || Inven_Item_isEmpty(cardZero) ) {
//检查格子中的部位是否是空的
api_CUser_SendNotiPacketMessage(user, "附魔失败, 缺少适合条件的装备", 16);
api_CUser_AddItem(user, itemId, 1);//恢复附魔卡
} else {
var sql = "select creature_equ from creature_equ_eh where accout = '"+account_id+"' and creature_equ = '"+creatureId+"'";
var info = getInfo(mysql_taiwan_cain, sql, 0);
if(!info){
//添加数据
var value = {
charac_no: charac_no,
accout: account_id,
creature_equ: creatureId,
card_id: itemId
};
addData(mysql_taiwan_cain, "creature_equ_eh", value);
}else{
var data = {
card_id: itemId
};
var where = {
accout: account_id,
creature_equ: creatureId
};
updataData(mysql_taiwan_cain, "creature_equ_eh", data, where);
}
//附魔的卡片ID itemId
CreatureEquZero.add(13).writeU32(itemId);
CInventory_delete_item(CreatureEqu, 1, 201, 1, 20, 1);//删除卡片第一格
api_CUser_SendNotiPacketMessage(user, "恭喜玩家["+charac_name+"],宠物装备附魔卡片成功", 16);
}
CUser_send_itemspace(user, 7); //更新背包
CUser_SendUpdateItemList(user, 1, 0, 201);//通知客户端更新卡片栏第一格
}
其次在捕获游戏事件中,使用物品触发事件添加代码
if(game_event == 'Item-') {
if(3 == reason) {
//使用道具
if(item_id == 2020301509){
//宠物装备附魔
CreatureEh(user, account_id, charac_no);
}
}
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|