shendianchuansong_lock = shendianchuansong_lock or {} shendianchuansong_pending = shendianchuansong_pending or {} local SHENDIAN_CHUANSONG_LOCK_SEC = 5 local function ShendianChuansong_ClearLock(RoleID) shendianchuansong_lock[RoleID] = nil shendianchuansong_pending[RoleID] = nil end local function ShendianChuansong_TryLock(RoleID) local now = os.time() local lockedAt = shendianchuansong_lock[RoleID] if lockedAt ~= nil and (now - lockedAt) < SHENDIAN_CHUANSONG_LOCK_SEC then return false end shendianchuansong_lock[RoleID] = now shendianchuansong_pending[RoleID] = nil return true end function shendianchuansong_OnTalk(MapID, InstanceID, TargetID, TargetTypeID, RoleID, TalkIndex) if TalkIndex == -1 then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 206569) --��Ԫ�������ˣ�\n 1������Ϊ30�����Ͽɽ��롣\n 2���븱�����������ƣ�����ӽ������ж϶����Ա�ȼ����������͵ȼ�����Ҳ��ɳ���10����������ʾ�������Ա�ȼ���������޷����븱����\n 3�����븱������ƣ��ֵ25�㣬����ʱ��Ϊ45���ӡ��� msg.AddMsgEvent(MsgID, 24, TargetID) --npcid msg.AddMsgEvent(MsgID, 21, 4) --ȡ����ť msg.AddMsgEvent(MsgID, 1, 206570) --������Ԫ���� msg.AddMsgEvent(MsgID, 21, 5) --ȡ����ť msg.AddMsgEvent(MsgID, 1, 100002) --��ȡ���� msg.DispatchRoleMsgEvent(RoleID, MsgID) elseif TalkIndex == 4 then if not ShendianChuansong_TryLock(RoleID) then return end local TeamID = role.IsRoleHaveTeam(MapID, InstanceID, RoleID) local level = role.GetRoleLevel(MapID, InstanceID, RoleID) if level < 30 then ShendianChuansong_ClearLock(RoleID) local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 206571) --Ԫ�������ˣ�\n ֻ�г���30������Ҳ��ܽ���Ԫ���� msg.AddMsgEvent(MsgID, 24, TargetID) --npcid msg.AddMsgEvent(MsgID, 21, 5) --ȡ����ť msg.AddMsgEvent(MsgID, 1, 100001) --��ȷ���� msg.DispatchRoleMsgEvent(RoleID, MsgID) elseif role.GetRoleItemNum(RoleID, 4810062) < 1 then ShendianChuansong_ClearLock(RoleID) local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 206581) --Ԫ�������ˣ�\n ������ûȱ�����ռǣ��޷�������� msg.AddMsgEvent(MsgID, 24, TargetID) --npcid msg.AddMsgEvent(MsgID, 21, 5) --ȡ����ť msg.AddMsgEvent(MsgID, 1, 100001) --��ȡ���� msg.DispatchRoleMsgEvent(RoleID, MsgID) else local canEnter = true if TeamID ~= nil and TeamID ~= -1 and TeamID ~= 0 and TeamID ~= 4294967295 then local minlv = 0 local maxlv = 0 local Role = {} Role[1], Role[2], Role[3], Role[4], Role[5], Role[6] = role.GetRoleTeamMemID(TeamID) for i=1, 6 do if Role[i] and Role[i]~= 4294967295 then local Target_MapID, Target_InstanceID = role.GetRoleMapID(Role[i]) local rolelevel = role.GetRoleLevel(Target_MapID, Target_InstanceID, Role[i]) if minlv == 0 then minlv = rolelevel maxlv = rolelevel end if maxlv < rolelevel then maxlv = rolelevel elseif minlv > rolelevel then minlv = rolelevel end end end if maxlv - minlv > 15 then canEnter = false ShendianChuansong_ClearLock(RoleID) local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 206572) --Ԫ�������ˣ�\n �������е���ҵȼ������󣨴���15�������޷�����Ԫ���� msg.AddMsgEvent(MsgID, 24, TargetID) --npcid msg.AddMsgEvent(MsgID, 21, 5) --ȡ����ť msg.AddMsgEvent(MsgID, 1, 100001) --��ȡ���� msg.DispatchRoleMsgEvent(RoleID, MsgID) end end if canEnter then shendianchuansong_pending[RoleID] = true role.RoleGotoNewMap(MapID, InstanceID, RoleID, 1174895199, 91, 20, 217)--4567 791 10728 else ShendianChuansong_ClearLock(RoleID) end end end end aux.RegisterCreatureEvent(1085204, 7, "shendianchuansong_OnTalk") --j����Ԫ���������� function s53_OnPlayerEnter(MapID, InstanceID,RoleID) local shouldCharge = (shendianchuansong_pending[RoleID] == true) ShendianChuansong_ClearLock(RoleID) if shouldCharge and role.GetRoleItemNum(RoleID, 4810062) >= 1 then role.RemoveFromRole(MapID, InstanceID, RoleID, 4810062, 1, 420) end local bhave = role.IsRoleHaveBuff(MapID, InstanceID, RoleID, 99996) if bhave == true then unit.CancelBuff(MapID, InstanceID, RoleID, 9999601) end local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 102, 206570)--����Ԫ����� msg.DispatchMapMsgEvent(MsgID, MapID, InstanceID, -1) end --ע�� aux.RegisterMapEvent("s53_1", 2, "s53_OnPlayerEnter") --Ԫ�������� function shendianchukou_OnTalk(MapID, InstanceID, TargetID, TargetTypeID, RoleID, TalkIndex) --��ȡ��ҵȼ� if TalkIndex == -1 then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 206574) --����Ҫ�뿪Ԫ�����ô���� msg.AddMsgEvent(MsgID, 24, TargetID) --npcid msg.AddMsgEvent(MsgID, 21, 4) --ȡ����ť msg.AddMsgEvent(MsgID, 1, 100001) --��ȷ���� msg.AddMsgEvent(MsgID, 21, 5) --ȡ����ť msg.AddMsgEvent(MsgID, 1, 100002) --��ȡ���� msg.DispatchRoleMsgEvent(RoleID, MsgID) elseif TalkIndex == 4 then role.RoleGotoNewMap(MapID, InstanceID, RoleID, 3424073512, 733, 23510, 582)-- end end aux.RegisterCreatureEvent(1085206, 7, "shendianchukou_OnTalk") --[[1085203 ����ճ����񷢲��� 1085204 Ԫ�������� 1085205 Ԫ�������� 1085206 ]]