local req_item = ""; --所需道具(为""则不需要) local req_item_num = 0; --所需道具数量 local req_gold = 0; --所需金币(为0则不需要) local req_ingot = 0; --所需元宝(为0则不需要) local req_lv_min = 1; --所需等级(大于等于该等级可进入) local req_lv_max = 200; --限制等级(小于等于该等级可进入) local req_people = 0; --需要组队人数(指队伍人数必须大于等于该人数, 为1则表示不限制人数, 为0则只能单人进入) local dgn_key = "XXX"; --副本KeyName(或普通地图KeyName) local dbg_time = 1800; --副本存活时间(秒)(普通地图用不到) local dgn_count = 3; --每天进入次数 local dgn_x = 10; --进入地图X坐标 local dgn_y = 10; --进入地图Y坐标 function main(npc, player) local msg = "待编辑\n"; --说明文字部分 msg = msg .. "副本介绍1\n"; --说明文字部分 msg = msg .. "副本介绍2\n"; --说明文字部分 msg = msg .. "<@enter *01*进入副本>\n"; msg = msg .. "<@leave *01*纯属路过>\n"; return msg; end --以下代码基本可以不修改,只需要修改上面的定义及说明文字 function enter(npc, player) local members = {}; if not lualib:Player_HasTeam(player) then members = {player}; else members = lualib:Player_GetTeamList(player); if not lualib:Player_IsTeamLeader(player) then return "不是队长"; end end if req_people == 0 then if #members > 1 then return "单人才能进入"; end elseif req_people > 0 then if #members < req_people then return "需组队"..req_people.."人以上才能进入"; end elseif req_people < 0 then return "系统错误"; end for k, v in pairs(members) do if lualib:GetInt(v, "preday_"..dgn_key) ~= lualib:GetAllDays(0) then lualib:SetInt(v, "preday_"..dgn_key, lualib:GetAllDays(0)); lualib:SetInt(v, "today_count_"..dgn_key, 0); end local level = lualib:Level(v); if level < req_lv_min or level > req_lv_max then if player == v then return "你的等级不符"; else return "队友[".. lualib:Name(v) .."]的等级不符"; end end if lualib:GetInt(v, "today_count_"..dgn_key) >= dgn_count then if player == v then return "你今日进入次数已达上限"; else return "队友[".. lualib:Name(v) .."]今日进入次数已达上限"; end end if req_item ~= "" and req_item_num > 0 then if lualib:ItemCountEx(v, req_item, 2, false, true, false, false) < req_item_num then if player == v then return "你的道具不足"; else return "队友[".. lualib:Name(v) .."]的道具不足"; end end end if req_gold > 0 then if not lualib:Player_IsGoldEnough(v, req_gold, false) then if player == v then return "你的金币不足"; else return "队友[".. lualib:Name(v) .."]的金币不足"; end end end if req_ingot > 0 then if not lualib:Player_IsIngotEnough(v, req_ingot, false) then if player == v then return "你的元宝不足"; else return "队友[".. lualib:Name(v) .."]的元宝不足"; end end end end for k, v in pairs(members) do if req_item ~= "" and req_item_num > 0 then if not lualib:DelItem(v, req_item, req_item_num, 2, "扣除道具:进副本", v) then if player == v then return "扣除道具失败"; else return "扣除队友[".. lualib:Name(v) .."]的道具失败"; end end end if req_gold > 0 then if not lualib:SubGold(v, req_gold, "扣除金币:进副本", v) then if player == v then return "扣除金币失败"; else return "扣除队友[".. lualib:Name(v) .."]的金币失败"; end end end if req_ingot > 0 then if not lualib:SubIngot(v, req_ingot, "扣除元宝:进副本", v) then if player == v then return "扣除元宝失败"; else return "扣除队友[".. lualib:Name(v) .."]的元宝失败"; end end end end ------------------------------------------------------------------- ------------------------------------------------------------------- --此为副本模式, 挂接活动的一般是在 --活动玩法脚本中创建, 然后存入地图变量中, 在此取出 local dgn = lualib:Map_CreateDgn(dgn_key, false, dbg_time); if dgn == "" then lualib:Error("副本创建失败:"..dgn_key); return "副本创建失败"; end for k, v in pairs(members) do if not lualib:Player_SetDgnTicket(v, dgn) then if player == v then return "你不允许进入地图"; else return "队友[".. lualib:Name(v) .."]不允许进入地图"; end end if not lualib:Player_EnterDgn(v, dgn_key, dgn_x, dgn_y, 5) then if player == v then return "进入地图失败"; else return "队友[".. lualib:Name(v) .."]进入地图失败"; end else lualib:SetInt(v, "today_count_"..dgn_key, lualib:GetInt(v, "today_count_"..dgn_key) + 1); return ""; end end -------------------------------------------------------------------- --此为普通地图模式 for k, v in pairs(members) do if not lualib:Player_MapMoveXY(v, dgn_key, dgn_x, dgn_y, 5) then if player == v then return "进入地图失败"; else return "队友[".. lualib:Name(v) .."]进入地图失败"; end else lualib:SetInt(v, "today_count_"..dgn_key, lualib:GetInt(v, "today_count_"..dgn_key) + 1); return ""; end end end
分类:常用功能
标签:副本,地图,传送人,限制,次数,道具,金币