魔力宝贝

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

[GP] Match_team.lua--匹配组队

[复制链接]
发表于 5 天前 | 显示全部楼层 |阅读模式
local mudidi={}--{目的地地图类型,目的地地图类型编号,x坐标,y坐标,传送费}
mudidi[1]={0,11003,9,37,0,9,37}--哈洞
mudidi[2]={0,1538,15,14,50,15,14}--灵堂
mudidi[3]={0,15005,8,2,300,10,12}--海底|8,2-10,13
mudidi[4]={0,38015,28,24,800,41,39}--雪山|28,24-41,39
mudidi[5]={0,38016,11,41,900,21,46}--炎洞|11,41-21,46
mudidi[6]={0,33000,610,296,1000,624,311}--坎村|610,296-624,311
mudidi[7]={0,38017,9,5,900,21,19}--水洞|9,5-21,19
mudidi[8]={0,38086,1,21,1000,18,32}--龙城|1,21-18,32
mudidi[9]={0,38019,46,19,1200,55,37}--火山|46,19-55,37
mudidi[10]={0,38020,4,15,1500,32,36}--兰一|25,15-40,34
mudidi[11]={0,62902,10,10,1500,36,43}--山道
mudidi[12]={0,38011,23,31,2500,28,36}--迷宫之城|22,30-33,41

Global_Reg.RegDischargeParty("Match_NO_team");--解散or离开队伍
Global_Reg.RegWarpEvent ("Match_Safe_team");--游戏传送点
Global_Reg.RegLogoutEvent("Match_Safe_teamb");--游戏登出
Global_Reg.RegJoinParty("NO_Team_formation")--禁止组队


local team_save_tab = {}--组队记录表
--{传教记录,群攻记录,佣兵记录,队长index,队友一index,队友二index,队友三index,队友四index}
local team_player_time = {}--时间记录表(单人匹配下没有组队记录表,只有时间记录表)
team_lock_tab = team_lock_tab or {}--禁止组队记录&组队目的地记录表
local team_lock_tab2 = team_lock_tab2 or {}
--{目的地编号,队长index}
local team_limit = {}--登出游戏要回收内存
team_limit[1]={}--第一个练级点
team_limit[2]={}
team_limit[3]={}
team_limit[4]={}
team_limit[5]={}
team_limit[6]={}
team_limit[7]={}
team_limit[8]={}
team_limit[9]={}
team_limit[10]={}
team_limit[11]={}
team_limit[12]={}
----------------------------------------
--职业名
local team_JobName = {}
team_JobName[-1] = "游民"
team_JobName[0] = "游民"
team_JobName[10] = "剑士"
team_JobName[20] = "战斧斗士"
team_JobName[30] = "骑士"
team_JobName[40] = "弓箭手"
team_JobName[50] = "士兵"
team_JobName[60] = "传教士"
team_JobName[70] = "魔术师"
team_JobName[80] = "咒术师"
team_JobName[90] = "封印师"
team_JobName[100] = "饲养员"
team_JobName[110] = "驯兽师"
team_JobName[120] = "盗贼"
team_JobName[130] = "巫师"
team_JobName[140] = "格斗士"
team_JobName[150] = "忍者"
team_JobName[160] = "舞者"
team_JobName[170] = "竞技士兵"
team_JobName[180] = "竞技舞者"
team_JobName[190] = "吟游诗人"
team_JobName[200] = "造剑师"
team_JobName[210] = "造斧师"
team_JobName[220] = "造枪师"
team_JobName[230] = "造弓师"
team_JobName[240] = "造杖师"
team_JobName[250] = "造回力师"
team_JobName[260] = "造小刀师"
team_JobName[270] = "造头盔师"
team_JobName[280] = "造帽子师"
team_JobName[290] = "造铠师"
team_JobName[300] = "造衣服师"
team_JobName[310] = "造袍师"
team_JobName[320] = "造靴师"
team_JobName[330] = "造鞋子师"
team_JobName[340] = "造盾师"
team_JobName[350] = "厨师"
team_JobName[360] = "药剂师"
team_JobName[370] = "武器修理工"
team_JobName[380] = "防具修理工"
team_JobName[390] = "鉴定士"
team_JobName[400] = "刻印工"
team_JobName[410] = "侦探"
team_JobName[420] = "仙人"
team_JobName[430] = "护士"
team_JobName[440] = "医师"
team_JobName[450] = "伐木工"
team_JobName[460] = "猎人"
team_JobName[470] = "矿工"
team_JobName[480] = "炸弹师"
team_JobName[500] = "武器大师"
team_JobName[510] = "防具大师"
team_JobName[520] = "巧匠"
team_JobName[530] = "探险家"
team_JobName[540] = "佣兵"
team_JobName[690] = "管理员"
---------------***********************************************************---------------


---------------***********************************************************---------------

function NO_Team_formation(player,capIndex)--玩家index,被加队者index
        local dz = Char.GetData(player,%对象_组队模式%)
        if team_lock_tab[player] or team_lock_tab2[player] then
                NLG.SystemMessage(player,"[系统]:您或者对方正处于『匹配组队状态』,无法进行组队操作")
                return -1
        elseif team_lock_tab[capIndex] or team_lock_tab2[capIndex] then
                NLG.SystemMessage(player,"[系统]:您或者对方正处于『匹配组队状态』,无法进行组队操作")
                return -1
        end
        return 0
end

function Match_Safe_teamb(player)--玩家掉线或者登出
        for i=1,12 do
                if team_limit[i][player] then
                        team_limit[i][player]=nil
                end
        end
        if team_lock_tab2[player] then
                team_lock_tab2[player]=nil
        end
        Match_team_off(player,0)
        return 0
end

function Match_NO_team(player)
        Match_team_off(player,3)
        return 0
end

function Match_Safe_team(player, mapID, MapFloor, x, y)
        if mapID==0 then
                if (MapFloor<1000 or MapFloor>1870) or (MapFloor>=1400 and MapFloor<1500) then--在法兰城外触发,拦截
                        Match_team_off(player,1)
                        return 0
                end
        end
        return 0
end

function Win_Team_Event(Fd,Pack)
        --print("\n\n 匹配组队封包是"..Pack)
        local player = Protocol.GetCharByFd(Fd);
        local ScapePack = WinMl_LocalSplit(Pack," ");
        local dz = Char.GetData(player,%对象_组队模式%)
        local maplx = Char.GetData(player,%对象_地图类型%)
        local mapid = Char.GetData(player,%对象_地图%)
        if maplx==0 then
                if (mapid<1000 or mapid>1870) or (mapid>=1400 and mapid<1500) then
                        Protocol.Send(Fd,"Teamviewer 3")
                        NLG.SystemMessage(player,"[系统]:『匹配组队』只能在法兰城内使用");
                        return 1;
                end
        else
                Protocol.Send(Fd,"Teamviewer 3")
                NLG.SystemMessage(player,"[系统]:『匹配组队』只能在法兰城内使用");
                return 1;
        end
        if(#ScapePack < 3)then
                return 1;
        end
       
        if dz==2 then
                Protocol.Send(Fd,"Teamviewer 3")
                NLG.SystemMessage(player,"[系统]:组队队员无法使用『匹配组队』");
                return 1;
        end
       
        local Page_1 = tonumber(ScapePack[2]);
        local Page_2 = tonumber(ScapePack[3]);
       
        if(Page_1 == 0 and Page_2 == 0)then --初始化打开界面
                if team_player_time[player]~=nil or team_save_tab[player]~=nil then
                        Protocol.Send(Fd,"Teamviewer 3")
                        NLG.SystemMessage(player,"[系统]:您已经在『匹配组队』中,请耐心等待,若长时间未匹配到队友,将会自动出发");
                        return 1;
                else
                        if team_lock_tab2[player] then
                                team_lock_tab2[player]=nil
                        end
                        local SendMapDate = "Teamviewer 0 1 1 1 1 1 1 1 1 1 1 1 1"
                        Protocol.Send(Fd,SendMapDate);
                        return 1;
                end
        end
       
        if Pack=="Teamviewer x " then--关闭了匹配组队
               
                Match_team_off(player,2)
                return 1;
        end
        if(Page_1 == -1)then --取消了匹配
                Match_team_off(player,2)
                return 1;
        end
        if(Page_1 == 1)then --选择了练级点
                --print("选择的练级点是:"..Page_2);
                if Page_2==1 then--哈洞
                        team_Get_ready_go(player,Page_2,Fd,5,0)
                elseif Page_2==2 then--灵堂
                        team_Get_ready_go(player,Page_2,Fd,10,50)
                elseif Page_2==3 then--海底
                        team_Get_ready_go(player,Page_2,Fd,20,300)
                elseif Page_2==4 then--雪山
                        team_Get_ready_go(player,Page_2,Fd,30,800)
                elseif Page_2==5 then--炎洞
                        team_Get_ready_go(player,Page_2,Fd,45,900)
                elseif Page_2==6 then--选择坎村
                        team_Get_ready_go(player,Page_2,Fd,40,1000)
                elseif Page_2==7 then--水洞
                        team_Get_ready_go(player,Page_2,Fd,55,900)
                elseif Page_2==8 then--龙城
                        team_Get_ready_go(player,Page_2,Fd,65,1000)
                elseif Page_2==9 then--火山
                        team_Get_ready_go(player,Page_2,Fd,75,1200)
                elseif Page_2==10 then--兰一
                        team_Get_ready_go(player,Page_2,Fd,85,1500)
                elseif Page_2==11 then--山道
                        team_Get_ready_go(player,Page_2,Fd,100,1500)
                elseif Page_2==12 then--迷宫之城
                        team_Get_ready_go(player,Page_2,Fd,100,2500)
                end
                return 1;
        end
       
        if(Page_1 == 2)then --选择了练级点--并且等待模式
                --print("进入等待模式选择的练级点是:"..Page_2);
               
                if team_limit[Page_2][player]==0 then
                        if team_player_time[player]==nil or team_save_tab[player]==nil then
                                local team =Char.GetData(player,%对象_组队模式%)
                                if team==0 then--单人匹配
                                        if Page_2==2 or Page_2==6 or Page_2==12 then
                                                if team_lock_tab2[player] then
                                                        team_lock_tab2[player]=nil
                                                end
                                                team_templayer_warp2(player,Page_2)--直接出发
                                                return 1
                                        end
                                        local tim=os.time()
                                        team_player_time[player]={tim,tim}--{初始时间,玩家当前时间}
                                        team_lock_tab[player]={Page_2,player}
                                        Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",player,5023)
                                        team_state_msg(player)
                                        Char.SendMsg(player,4,4,"$4[智能匹配]您开始寻找队友,请耐心等待3分钟,正在为您自动分配$0");
                                        --local Originname = Char.GetData(player,%对象_原名%)
                                        --NLG.SystemMessage(-1,"玩家"..Originname.."的初始出发时间为"..tim)
                                        if team_lock_tab2[player] then
                                                team_lock_tab2[player]=nil
                                        end
                                        return 1;
                                elseif team==1 then--组队匹配,自身为队长
                                        if Page_2==2 or Page_2==6 or Page_2==12 then
                                                for i=0,4 do
                                                        local teamindex=Char.GetTeamIndex(player,i) or -1
                                                        if teamindex>=0 then
                                                                if team_lock_tab2[teamindex] then
                                                                        team_lock_tab2[teamindex]=nil
                                                                end
                                                        end
                                                end
                                                team_templayer_warp2(player,Page_2)--直接出发
                                                return 1
                                        end
                                        local count = 1
                                        for i= 1, 4 do
                                                local GroupIndex = Char.GetTeamIndex(player,i) or -1
                                                if GroupIndex>=0 and team_lock_tab[GroupIndex]==nil then
                                                        count = count + 1
                                                end
                                        end
                                        if count==5 then
                                                local mapnow=Page_2
                                                local gold=mudidi[mapnow][5]
                                                for i=0,4 do
                                                        local teamindex=Char.GetTeamIndex(player,i) or -1
                                                        if teamindex>=0 then
                                        --local jobnum = Char.GetData(teamindex,%对象_职类ID%)
                                                                local jobnum = Char.GetData(teamindex,%对象_职类ID%)
                                                                local Fd=Protocol.GetFdByChar(teamindex)
                                                                Protocol.Send(Fd,"Teamviewer 3")
                                                                if jobnum~=540 then--佣兵不扣钱
                                                                        NLG.AddGold(teamindex,-gold)
                                                                        if teamindex~=player then
                                                                                if team_save_tab[teamindex] then
                                                                                        team_save_tab[teamindex]=nil
                                                                                end
                                                                        end
                                                                        if team_player_time[teamindex] then
                                                                                team_player_time[teamindex]=nil
                                                                        end
                                                                end
                                                                if teamindex==player then
                                                                        NLG.SystemMessage(player,"[匹配组队]:勇者们应邀加入了您的队伍!")
                                                                elseif jobnum~=540 then--佣兵不管
                                                                        local capIndexb = Char.GetTeamIndex(teamindex,0) or -1
                                                                        if capIndexb~=player then--如果队员的队长不是匹配队列队长
                                                                                if capIndexb~=-1 then--如果为-1就是单人状态,无队长,无需解散队伍
                                                                                        NLG.DischargeParty(teamindex)--解散队伍
                                                                                end
                                                                                Char.JoinParty(teamindex,player)--加入匹配队列队长的队伍
                                                                                NLG.SystemMessage(teamindex,"[匹配组队]:您加入了队伍!")
                                                                        end
                                                                end
                                                                if team_lock_tab2[teamindex] then
                                                                        team_lock_tab2[teamindex]=nil
                                                                end
                                                                for i=1,10000 do
                                                                        local warpnum1=math.random(mudidi[mapnow][3],mudidi[mapnow][6])
                                                                        local warpnum2=math.random(mudidi[mapnow][4],mudidi[mapnow][7])
                                                                        if(Map.WalkAble(mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2) == 1)then
                                                                                NLG.Warp(teamindex,mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2)
                                                                                break
                                                                        end
                                                                end
                                                        end
                                                end
                                        else
                                                local tim=os.time()
                                                team_player_time[player]={tim,tim}--{初始时间,玩家当前时间}
                                                team_save_tab[player]={0,0,0}
                                                for g = 0,4 do--整队计入锁定表和队列表
                                                        local GroupIndex = Char.GetTeamIndex(player,g) or -1
                                                        if GroupIndex>=0 and team_lock_tab[GroupIndex]==nil then
                                                                team_lock_tab[GroupIndex]={Page_2,player}--{目的地编号,队长index}
                                                                local job = Char.GetData(GroupIndex,%对象_职类ID%)
                                                                if job==60 then
                                                                        team_save_tab[player][1]=team_save_tab[player][1]+1
                                                                end
                                                                if job == 40 or job ==70 or job==140 then
                                                                        team_save_tab[player][2]=team_save_tab[player][2]+1
                                                                end
                                                                if job==540 then
                                                                        local ItemIndex = Char.GetItemIndex(GroupIndex,2)
                                                                        local fjob = Item.GetData(ItemIndex,37)
                                                                        if fjob==60 then
                                                                                team_save_tab[player][1]=team_save_tab[player][1]+1
                                                                        end
                                                                        if fjob == 40 or fjob ==70 or fjob==140 then
                                                                                team_save_tab[player][2]=team_save_tab[player][2]+1
                                                                        end
                                                                        team_save_tab[player][3]=team_save_tab[player][3]+1
                                                                end
                                                                table.insert(team_save_tab[player],GroupIndex)
                                                                if team_lock_tab2[GroupIndex] then
                                                                        team_lock_tab2[GroupIndex]=nil
                                                                end
                                                        elseif GroupIndex>=0 and team_lock_tab[GroupIndex] then
                                                                local name = Char.GetData(GroupIndex,%对象_原名%)
                                                                NLG.SystemMessage(player,"[系统]:队员"..name.."正在『匹配组队』队列内,无法参与您的组队");
                                                        end
                                                end
                                                Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",player,10101)--10秒执行一次loop
                                                team_state_msg(player)
                                                Char.SendMsg(player,4,4,"$4[智能匹配]您的团队开始寻找队友,请耐心等待3分钟,正在为您自动分配$0");
                                        end
                                        --local Originname = Char.GetData(player,%对象_原名%)
                                        --NLG.SystemMessage(-1,"玩家"..Originname.."的初始出发时间为"..tim)
                                       
                                        return 1;
                                else--为队员
                                        NLG.SystemMessage(player,"[系统]:队员无法使用『匹配组队』功能");
                                end
                        end
                                Protocol.Send(Fd,"Teamviewer 3 ");--关闭组队窗口
                                NLG.SystemMessage(player,"[系统]:您已经在『匹配组队』中,请耐心等待,若长时间未匹配到队友,将会自动出发");
                        return 1;
                elseif team_limit[Page_2][player]==1 then
                        Protocol.Send(Fd,"Teamviewer 3 ");--关闭组队窗口
                        NLG.SystemMessage(player,"[匹配系统]:您的队伍内有人等级未满足出发条件,无法进入匹配模式");
                        return 1
                elseif team_limit[Page_2][player]==2 then
                        Protocol.Send(Fd,"Teamviewer 3 ");--关闭组队窗口
                        NLG.SystemMessage(player,"[匹配系统]:您的队伍内有人金币不足,无法进入匹配模式");
                        return 1
                end
        end
        return 1;
end

function team_Get_ready_go(player,Page_2,Fd,lv,money)--lv和money填目标目的地的限制等级和传送费用
        local lvsave=0
        local moneysave=0
        local teamnum=0
        local dz = Char.GetData(player,%对象_组队模式%)
       
        if dz==0 then--单人
                team_lock_tab2[player] = 1
                local lvb = Char.GetData(player,%对象_等级%)
                local moneyb = Char.GetData(player,%对象_金币%)
                if lvb>=lv then
                        lvsave=lvsave+1
                end
                if moneyb>=money then
                        moneysave=moneysave+1
                end
                teamnum=teamnum+1
        else
                for i = 0,4 do
                        local GroupIndex = Char.GetTeamIndex(player, i) or -1
                        if(GroupIndex >= 0)then
                                team_lock_tab2[GroupIndex] = 1
                                local lvb = Char.GetData(GroupIndex,%对象_等级%)
                                local moneyb = Char.GetData(GroupIndex,%对象_金币%)
                                local job = Char.GetData(GroupIndex,%对象_职类ID%)
                                if lvb>=lv or job==540 then
                                        lvsave=lvsave+1
                                end
                                if moneyb>=money or job==540 then
                                        moneysave=moneysave+1
                                end
                                teamnum=teamnum+1
                        end
                end
        end
        local lvok = "$4是"
        local moneyok = "$4是"
        team_limit[Page_2][player]=0
        if lvsave<teamnum then--有人没满足等级条件
                lvok = "$6否"
                team_limit[Page_2][player]=1
        end
        if moneysave<teamnum then--有人没满足金钱条件
                moneyok = "$6否"
                team_limit[Page_2][player]=2
        end
        local SendMapDate = "Teamviewer 1 "..lvok.."|"..moneyok.."|$4是"
        Protocol.Send(Fd,SendMapDate);
end

function team_state_msg(player)--player==队列队长index
        local Team="Teamviewer 2 "
        if team_player_time[player] and team_save_tab[player]==nil then--单人
                local name = Char.GetData(player,%对象_原名%) or -1
                local img = Char.GetData(player,%对象_原形%) or -1
                local lv = Char.GetData(player,%对象_等级%) or -1
                local zya= Char.GetData(player,%对象_职类ID%) or -1
                local zyb=team_JobName[zya]
                local atk=Char.GetData(player,289) or -1--攻击力
                local Cri = Char.GetData(player,332) or -1--必杀
                local tint = Char.GetData(player,292) or -1--精神
                local mg = Char.GetData(player,396) or -1--魔攻
                local Dodge = Char.GetData(player,335)
                local jk = Char.GetData(player,%对象_受伤%)
                Team= Team..name.."|"..img.."|"..lv.."|"..zyb.."|"..atk.."|"..Cri.."|"..tint.."|"..mg.."|"..Dodge.."|"..jk
                local fd = Protocol.GetFdByChar(player)
                Protocol.Send(fd,Team)
        else
                for i = 4,#team_save_tab[player] do
                        local GroupIndex = team_save_tab[player][i];
                        if(GroupIndex >= 0)then
                                local name = Char.GetData(GroupIndex,%对象_原名%)
                                local img = Char.GetData(GroupIndex,%对象_原形%)
                                local lv = Char.GetData(GroupIndex,%对象_等级%)
                                local zya= Char.GetData(GroupIndex,%对象_职类ID%)
                                local zyb=team_JobName[zya]
                                if zya==540 then
                                        local ItemIndex = Char.GetItemIndex(GroupIndex,2)
                                        local fjob = Item.GetData(ItemIndex,37)
                                        zyb=team_JobName[fjob]
                                end
                                local atk=Char.GetData(GroupIndex,289)--攻击力
                                local Cri = Char.GetData(GroupIndex,332)--必杀
                                local tint = Char.GetData(GroupIndex,292)--精神
                                local mg = Char.GetData(GroupIndex,396)--魔攻
                                local Dodge = Char.GetData(GroupIndex,335)--闪躲
                                local jk = Char.GetData(GroupIndex,%对象_受伤%) or 0
                                if GroupIndex==player then
                                        Team= Team..name.."|"..img.."|"..lv.."|"..zyb.."|"..atk.."|"..Cri.."|"..tint.."|"..mg.."|"..Dodge.."|"..jk
                                else
                                        Team= Team..":"..name.."|"..img.."|"..lv.."|"..zyb.."|"..atk.."|"..Cri.."|"..tint.."|"..mg.."|"..Dodge.."|"..jk
                                end
                        end
                end
                for k = 4,#team_save_tab[player] do
                        local teamindex = team_save_tab[player][k]
                        local zya= Char.GetData(teamindex,%对象_职类ID%)
                        if teamindex>=0 and zya~=540 then
                                local FD = Protocol.GetFdByChar(teamindex)
                                Protocol.Send(FD,Team)
                                --print("\n\n 图形界面返回值:"..rt)
                        end
                end
        end
end

function Auto_team_onceplayer_Loop(player)
        --print("\n\n 单人loop开始了~!")
        local tim = os.time()
        team_player_time[player][2]=tim
        if (team_player_time[player][2]-team_player_time[player][1])<90 then--匹配时间未到1分半钟(90秒)
                if tablength(team_save_tab)>=1 then
                        local job = Char.GetData(player,%对象_职类ID%)
                        for k,v in pairs(team_save_tab) do
                                if team_lock_tab[player][1]==team_lock_tab[k][1] then--目的地一致
                                        if job==60 and team_save_tab[k][1]<1 then--队伍内传教小于1人,并且自身为传教
                                                if #team_save_tab[k]<8 then--队伍有空位,计入排队列表
                                                        team_save_tab[k][1]= team_save_tab[k][1] + 1
                                                        Auto_team_onceplayer_ex(player,k)--K为队长的index
                                                        return 0;
                                                end
                                        elseif team_save_tab[k][2] >= 2 then--优先加入群攻人数多的队列
                                                if #team_save_tab[k]<8 then--队伍有空位,加入队列
                                                        if job == 40 or job ==70 or job==140 then
                                                                team_save_tab[k][2]= team_save_tab[k][2] +1
                                                        end
                                                        Auto_team_onceplayer_ex(player,k)
                                                        return 0;
                                                end
                                        end
                                end
                        end
                        for w,q in pairs(team_save_tab) do
                                if team_lock_tab[player][1]==team_lock_tab[w][1] then--目的地一致
                                        if job==60 and team_save_tab[w][1]<1 then--队伍内传教小于1人,并且自身为传教
                                                if #team_save_tab[w]<8 then--队伍有空位,加入队列
                                                        team_save_tab[w][1]= team_save_tab[w][1] + 1
                                                        Auto_team_onceplayer_ex(player,w)
                                                        return 0;
                                                end
                                        else
                                                if #team_save_tab[w]<8 then--队伍有空位,加入队列
                                                        if job == 40 or job ==70 or job==140 then
                                                                team_save_tab[w][2]= team_save_tab[w][2] +1
                                                        end
                                                        Auto_team_onceplayer_ex(player,w)
                                                        return 0;
                                                end
                                        end
                                end
                        end
                end
        elseif (team_player_time[player][2]-team_player_time[player][1])<180 then--匹配时间超过3分钟(180秒),未到3分钟,没有人组队,强制1+1组队为2人队伍,[1]内记录时间大的设定为队长
                if tablength(team_save_tab)<1 then
                        for o,p in pairs(team_player_time) do
                                if o~=player then--不是本人
                                        if team_lock_tab[player][1]==team_lock_tab[o][1] then--目的地一致
                                                if team_player_time[o][1] >= team_player_time[player][1] then--比较大的为后匹配组队者,成为新队队长
                                                        team_save_tab[o]={0,0,0,o,player}
                                                        team_player_time[o][1]=team_player_time[player][1]--继承队长的等待时间
                                                        team_player_time[o][2]=os.time()
                                                        local job = Char.GetData(o,%对象_职类ID%)
                                                        if job ==60 then
                                                                team_save_tab[o][1]=team_save_tab[o][1]+1
                                                        end
                                                        if job == 40 or job ==70 or job==140 then
                                                                team_save_tab[o][2]=team_save_tab[o][2]+1
                                                        end
                                                       
                                                        local job2 = Char.GetData(player,%对象_职类ID%)
                                                        if job2 ==60 then
                                                                team_save_tab[o][1]=team_save_tab[o][1]+1
                                                        end
                                                        if job2 == 40 or job2 ==70 or job2 ==140 then
                                                                team_save_tab[o][2]=team_save_tab[o][2]+1
                                                        end
                                                        team_lock_tab[player][2]=o
                                                        team_player_time[player]=nil
                                                        Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",player,0)
                                                        Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",o,0)
                                                        Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",o,10101)--10秒执行一次loop
                                                        team_state_msg(o)
                                                        return 0
                                                else
                                                        team_save_tab[player]={0,0,0,player,o}
                                                        team_player_time[player][1]=team_player_time[o][1]--继承队长的等待时间
                                                        team_player_time[player][2]=os.time()
                                                        local job = Char.GetData(o,%对象_职类ID%)
                                                        if job ==60 then
                                                                team_save_tab[player][1]=team_save_tab[player][1]+1
                                                        end
                                                        if job == 40 or job ==70 or job==140 then
                                                                team_save_tab[player][2]=team_save_tab[player][2]+1
                                                        end
                                                       
                                                        local job2 = Char.GetData(player,%对象_职类ID%)
                                                        if job2 ==60 then
                                                                team_save_tab[player][1]=team_save_tab[player][1]+1
                                                        end
                                                        if job2 == 40 or job2 ==70 or job2 ==140 then
                                                                team_save_tab[player][2]=team_save_tab[player][2]+1
                                                        end
                                                        team_lock_tab[o][2]=player
                                                        team_player_time[o]=nil
                                                        Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",player,0)
                                                        Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",o,0)
                                                        Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",player,10101)--10秒执行一次loop
                                                        team_state_msg(player)
                                                        return 0
                                                end
                                        end
                                end
                        end
                else--有队列
                        local job = Char.GetData(player,%对象_职类ID%)
                        for k,v in pairs(team_save_tab) do
                                if team_lock_tab[player][1]==team_lock_tab[k][1] then--目的地一致
                                        if job==60 and team_save_tab[k][1]<1 then--队伍内传教小于1人,并且自身为传教
                                                if #team_save_tab[k]<8 then--队伍有空位,计入排队列表
                                                        team_save_tab[k][1]= team_save_tab[k][1] + 1
                                                        Auto_team_onceplayer_ex(player,k)--K为队长的index
                                                        return 0;
                                                end
                                        elseif team_save_tab[k][2] >= 2 then--优先加入群攻人数多的队列
                                                if #team_save_tab[k]<8 then--队伍有空位,加入队列
                                                        if job == 40 or job ==70 or job==140 then
                                                                team_save_tab[k][2]= team_save_tab[k][2] +1
                                                        end
                                                        Auto_team_onceplayer_ex(player,k)
                                                        return 0;
                                                end
                                        end
                                end
                        end
                        for w,q in pairs(team_save_tab) do
                                if team_lock_tab[player][1]==team_lock_tab[w][1] then--目的地一致
                                        if job==60 and team_save_tab[w][1]<1 then--队伍内传教小于1人,并且自身为传教
                                                if #team_save_tab[w]<8 then--队伍有空位,加入队列
                                                        team_save_tab[w][1]= team_save_tab[w][1] + 1
                                                        Auto_team_onceplayer_ex(player,w)
                                                        return 0;
                                                end
                                        else
                                                if #team_save_tab[w]<8 then--队伍有空位,加入队列
                                                        if job == 40 or job ==70 or job==140 then
                                                                team_save_tab[w][2]= team_save_tab[w][2] +1
                                                        end
                                                        Auto_team_onceplayer_ex(player,w)
                                                        return 0;
                                                end
                                        end
                                end
                        end
                end
        else--匹配时间超过3分钟,强制出发,配置假人佣兵
                NLG.DischargeParty(player)--解散当前队列,避免出错
                local Fd=Protocol.GetFdByChar(player)
                Protocol.Send(Fd,"Teamviewer 3")
                local mapnow=team_lock_tab[player][1]
                for i=1,10000 do
                        local warpnum1=math.random(mudidi[mapnow][3],mudidi[mapnow][6])
                        local warpnum2=math.random(mudidi[mapnow][4],mudidi[mapnow][7])
                        if(Map.WalkAble(mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2) == 1)then
                                NLG.Warp(player,mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2)
                                break
                        end
                end
                local gold=mudidi[mapnow][5]
                NLG.AddGold(player,-gold)
                team_player_time[player]=nil
                Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",player,0)
                --配置假人进队
                for t= 1,3 do
                        NPC_mate_summon(player,t,team_lock_tab[player][1])
                end
                team_lock_tab[player]=nil
                NLG.SystemMessage(player,"[匹配组队]:勇者们应邀加入了您的队伍!")
        end
        return 0;
end


function Auto_team_templayer_Loop(player)
        --print("\n\n 团队loop开始了~!")
        local count = 1
        for i = 1,4 do
                local GroupIndex = Char.GetTeamIndex(player, i);
                if GroupIndex>=0 then
                        count = count +1
                end
        end
        if count==5 then
                team_templayer_warp(player)
                return
        end
        local tim = os.time()
        if team_player_time[player] then
                team_player_time[player][2]=tim
        end
        --NLG.SystemMessage(-1,"记录的初始出发时间是"..team_player_time[player][1].."当前时间是"..tim)
        if (team_player_time[player][2]-team_player_time[player][1])<180 then--匹配时间未到3分钟(180秒)
                local length=#team_save_tab[player]
                for k_index,_ in pairs(team_save_tab) do--刷选直接能出发的队伍(2+3,3+2)
                        if k_index~=player then
                                if team_save_tab[k_index] then--队列存在
                                        if team_lock_tab[player][1]==team_lock_tab[k_index][1] then--目的地一致
                                                if #team_save_tab[k_index] + length == 11 then
                                                        if team_save_tab[player][3]==0 and team_player_time[k_index][3]>0 then--当player队列没佣兵,k_index队列有佣兵时,加入k_index队
                                                                for i=4,8 do
                                                                        if team_save_tab[player][i]~=nil then
                                                                                table.insert(team_save_tab[k_index],team_save_tab[player][i])--加入新队伍的表
                                                                        end
                                                                end
                                                                team_templayer_warp(k_index)
                                                                return 0;
                                                        elseif team_save_tab[player][3]>0 and team_player_time[k_index][3]==0 then--当k_index队列没佣兵,player队列有佣兵时,加入player队
                                                                for i=4,8 do
                                                                        if team_save_tab[k_index][i]~=nil then
                                                                                table.insert(team_save_tab[player],team_save_tab[k_index][i])--加入新队伍的表
                                                                        end
                                                                end
                                                                team_templayer_warp(player)
                                                                return 0;
                                                        elseif team_player_time[k_index][1] >= team_player_time[player][1] and team_save_tab[player][3]==0 then--比较大的为后匹配组队者,成为新队队长(合并的后者队列要没有佣兵)
                                                                for i=4,8 do
                                                                        if team_save_tab[player][i]~=nil then
                                                                                table.insert(team_save_tab[k_index],team_save_tab[player][i])--加入新队伍的表
                                                                        end
                                                                end
                                                                team_templayer_warp(k_index)
                                                                return 0;
                                                        elseif team_player_time[k_index][1] < team_player_time[player][1] and team_save_tab[k_index][3]==0 then
                                                                for i=4,8 do
                                                                        if team_save_tab[k_index][i]~=nil then
                                                                                table.insert(team_save_tab[player],team_save_tab[k_index][i])--加入新队伍的表
                                                                        end
                                                                end
                                                                team_templayer_warp(player)
                                                                return 0;
                                                        end
                                                end
                                        end
                                end
                        end
                end
                for K_index,_ in pairs(team_save_tab) do--刷选出2+2为4的队伍
                        if K_index~=player then
                                if team_save_tab[K_index] then--队列存在
                                        if team_lock_tab[player][1]==team_lock_tab[K_index][1] then--目的地一致
                                                if #team_save_tab[K_index] + length == 10 then
                                                        if team_save_tab[K_index][3]>=1 and team_player_time[player][3]==0 then--K_index队列有佣兵,player队列没佣兵,K_index为队长
                                                                for i=4,8 do
                                                                        local groupindex=team_save_tab[player][i] or -1
                                                                        if groupindex>=0 then
                                                                                table.insert(team_save_tab[K_index],groupindex)
                                                                                team_lock_tab[groupindex][2]=K_index
                                                                                local job = Char.GetData(groupindex,%对象_职类ID%)
                                                                                if job==60 then
                                                                                        team_save_tab[K_index][1]=team_save_tab[K_index][1]+1
                                                                                end
                                                                                if job == 40 or job ==70 or job==140 then
                                                                                        team_save_tab[K_index][2]=team_save_tab[K_index][2]+1
                                                                                end
                                                                        end
                                                                end
                                                                team_player_time[player]=nil
                                                                team_save_tab[player]=nil
                                                                Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",player,0)--结束匹配
                                                                team_state_msg(K_index)
                                                                return 0;
                                                        elseif team_save_tab[player][3]>=1 and team_player_time[K_index][3]==0 then--player队列有佣兵,K_index队列没佣兵,player为队长
                                                                for i=4,8 do
                                                                        local groupindex=team_save_tab[K_index][i] or -1
                                                                        if groupindex>=0 then
                                                                                table.insert(team_save_tab[player],groupindex)
                                                                                team_lock_tab[groupindex][2]=player
--local job = Char.GetData(groupindex,%对象_职类ID%)
                                                                                local job = Char.GetData(groupindex,%对象_职类ID%)
                                                                                if job==60 then
                                                                                        team_save_tab[player][1]=team_save_tab[player][1]+1
                                                                                end
                                                                                if job == 40 or job ==70 or job==140 then
                                                                                        team_save_tab[player][2]=team_save_tab[player][2]+1
                                                                                end
                                                                        end
                                                                end
                                                                team_player_time[K_index]=nil
                                                                team_save_tab[K_index]=nil
                                                                Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",K_index,0)--队长结束匹配
                                                                team_state_msg(player)
                                                                return 0;
                                                        elseif team_player_time[K_index][1] >= team_player_time[player][1] and team_save_tab[player][3]==0 then--比较大的为后匹配组队者,成为新队队长
                                                                for i=4,8 do
                                                                        local groupindex=team_save_tab[player][i] or -1
                                                                        if groupindex>=0 then
                                                                                table.insert(team_save_tab[K_index],groupindex)
                                                                                team_lock_tab[groupindex][2]=K_index
                                                                                local job = Char.GetData(groupindex,%对象_职类ID%)
                                                                                if job==60 then
                                                                                        team_save_tab[K_index][1]=team_save_tab[K_index][1]+1
                                                                                end
                                                                                if job == 40 or job ==70 or job==140 then
                                                                                        team_save_tab[K_index][2]=team_save_tab[K_index][2]+1
                                                                                end
                                                                        end
                                                                end
                                                                team_player_time[player]=nil
                                                                team_save_tab[player]=nil
                                                                Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",player,0)--队长结束匹配
                                                                team_state_msg(K_index)
                                                                return 0;
                                                        elseif team_player_time[K_index][1] < team_player_time[player][1] and team_save_tab[K_index][3]==0 then
                                                                for i=4,8 do
                                                                        local groupindex=team_save_tab[K_index][i] or -1
                                                                        if groupindex>=0 then
                                                                                table.insert(team_save_tab[player],groupindex)
                                                                                team_lock_tab[groupindex][2]=player
--local job = Char.GetData(groupindex,%对象_职类ID%)
                                                                                local job = Char.GetData(groupindex,%对象_职类ID%)
                                                                                if job==60 then
                                                                                        team_save_tab[player][1]=team_save_tab[player][1]+1
                                                                                end
                                                                                if job == 40 or job ==70 or job==140 then
                                                                                        team_save_tab[player][2]=team_save_tab[player][2]+1
                                                                                end
                                                                        end
                                                                end
                                                                team_player_time[K_index]=nil
                                                                team_save_tab[K_index]=nil
                                                                Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",K_index,0)--队长结束匹配
                                                                team_state_msg(player)
                                                                return 0;
                                                        end
                                                end
                                        end
                                end
                        end
                end
        else--匹配5分钟没有出发,自动加入佣兵后出发
                local place = team_lock_tab[player][1]
                team_templayer_warp(player)--出发函数
                --判断以player为队长的新队伍人数,然后配置假人进队
                local teamnum=0
                for i = 1,4 do
                        local GroupIndex = Char.GetTeamIndex(player, i);
                        if(GroupIndex < 0)then
                                teamnum=teamnum+1
                        end
                end
                if teamnum>3 then
                        teamnum=3
                end
                for t= 1,teamnum do
                        NPC_mate_summon(player,t,place)
                end
        end
        return 0
end

function team_templayer_warp(player)--团队出发
        local dz = Char.GetData(player,%对象_组队模式%)
        if dz==2 then--队列队长在其他队伍中当队员
                NLG.DischargeParty(player)--解散原始队列等待重组
        end
        local mapnow=team_lock_tab[player][1]
        local gold=mudidi[mapnow][5]
        for i=4,8 do
                local teamindex=team_save_tab[player][i] or -1
                if teamindex>=0 then
                        local Fd=Protocol.GetFdByChar(teamindex)
                        Protocol.Send(Fd,"Teamviewer 3")
--local jobnum = Char.GetData(teamindex,%对象_职类ID%)
                        local jobnum = Char.GetData(teamindex,%对象_职类ID%)
                        if jobnum~=540 then--佣兵不扣钱
                                NLG.AddGold(teamindex,-gold)
                                if teamindex~=player then
                                        if team_save_tab[teamindex] then
                                                team_save_tab[teamindex]=nil
                                        end
                                end
                                if team_player_time[teamindex] then
                                        team_player_time[teamindex]=nil
                                end
                                Char.SetLoopEvent(nil, nil,teamindex,0)--队长结束匹配
                        end
                        if team_lock_tab[teamindex] then
                                team_lock_tab[teamindex]=nil
                        end
                        if teamindex==player then
                                NLG.SystemMessage(player,"[匹配组队]:勇者们应邀加入了您的队伍!")
                        elseif jobnum~=540 then--佣兵不管
                                local capIndexb = Char.GetTeamIndex(teamindex,0) or -1
                                if capIndexb~=player then--如果队员的队长不是匹配队列队长
                                        if capIndexb~=-1 then--如果为-1就是单人状态,无队长,无需解散队伍
                                                NLG.DischargeParty(teamindex)--解散队伍
                                        end
                                        Char.JoinParty(teamindex,player)--加入匹配队列队长的队伍
                                        NLG.SystemMessage(teamindex,"[匹配组队]:您加入了队伍!")
                                end
                        end
                        for i=1,10000 do
                                local warpnum1=math.random(mudidi[mapnow][3],mudidi[mapnow][6])
                                local warpnum2=math.random(mudidi[mapnow][4],mudidi[mapnow][7])
                                if(Map.WalkAble(mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2) == 1)then
                                        NLG.Warp(teamindex,mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2)
                                        break
                                end
                        end
                end
        end
        team_save_tab[player]=nil
end

function team_templayer_warp2(player,Page_2)--直接出发
        local dz = Char.GetData(player,%对象_组队模式%)
        if dz==2 then--队列队长在其他队伍中当队员
                NLG.DischargeParty(player)--解散原始队列等待重组
        end
        local mapnow=Page_2
        local gold=mudidi[mapnow][5]
        if dz~=0 then
                for i=0,4 do
                        local teamindex=Char.GetTeamIndex(player, i)
                        if teamindex>=0 then
                                local jobnum = Char.GetData(teamindex,%对象_职类ID%)
                                local Fd=Protocol.GetFdByChar(teamindex)
                                Protocol.Send(Fd,"Teamviewer 3")
                                if jobnum~=540 then--佣兵不扣钱
                                        NLG.AddGold(teamindex,-gold)
                                end
                                if team_lock_tab[teamindex] then
                                        team_lock_tab[teamindex]=nil
                                end
                                if teamindex==player then
                                        NLG.SystemMessage(player,"[匹配组队]:勇者们应邀加入了您的队伍!")
                                elseif jobnum~=540 then--佣兵不管
                                        local capIndexb = Char.GetTeamIndex(teamindex,0) or -1
                                        if capIndexb~=player then--如果队员的队长不是匹配队列队长
                                                if capIndexb~=-1 then--如果为-1就是单人状态,无队长,无需解散队伍
                                                        NLG.DischargeParty(teamindex)--解散队伍
                                                end
                                                Char.JoinParty(teamindex,player)--加入匹配队列队长的队伍
                                                NLG.SystemMessage(teamindex,"[匹配组队]:您加入了队伍!")
                                        end
                                end
                                for i=1,10000 do
                                        local warpnum1=math.random(mudidi[mapnow][3],mudidi[mapnow][6])
                                        local warpnum2=math.random(mudidi[mapnow][4],mudidi[mapnow][7])
                                        if(Map.WalkAble(mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2) == 1)then
                                                NLG.Warp(teamindex,mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2)
                                                break
                                        end
                                end
                        end
                end
        else
                local Fd=Protocol.GetFdByChar(player)
                Protocol.Send(Fd,"Teamviewer 3")
                NLG.AddGold(player,-gold)
                if team_lock_tab[player] then
                        team_lock_tab[player]=nil
                end
                for i=1,10000 do
                        local warpnum1=math.random(mudidi[mapnow][3],mudidi[mapnow][6])
                        local warpnum2=math.random(mudidi[mapnow][4],mudidi[mapnow][7])
                        if(Map.WalkAble(mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2) == 1)then
                                NLG.Warp(player,mudidi[mapnow][1],mudidi[mapnow][2],warpnum1,warpnum2)
                                break
                        end
                end
        end
end

function Auto_team_onceplayer_ex(player,k)--K为队长的index
        Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",player,0)
        table.insert(team_save_tab[k],player)
        team_player_time[player]=nil
        team_lock_tab[player][2]=k
        if #team_save_tab[k]==8 then--满员出发
                team_templayer_warp(k)
        else
                team_state_msg(k)
        end
end

function Match_team_off(player,modl)--modl:0为不发送消息,1为地图切换,2为主动退出队伍,3为被动离开队伍
        if team_lock_tab2[player] then
                team_lock_tab2[player]=nil
        end
        if team_lock_tab[player] then--正在匹配组队中
                if team_player_time[player] and team_save_tab[player]==nil then--没有队伍
                        team_player_time[player]=nil
                        Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",player,0)
                        team_lock_tab[player]=nil
                        local Fd=Protocol.GetFdByChar(player)
                        Protocol.Send(Fd,"Teamviewer 3")
                        if modl==1 then
                                NLG.SystemMessage(player,"[系统]:您的『匹配组队状态』由于地图切换而中断")
                        elseif modl==2 then
                                NLG.SystemMessage(player,"[系统]:您退出了『匹配组队』")
                        elseif modl==3 then
                                NLG.SystemMessage(player,"[系统]:您的『匹配组队状态』由于离开队伍而中断")
                        end
                elseif team_player_time[player] and team_save_tab[player] then--队长
                        for u=4,1,-1 do--先让组队队友全部离开匹配队列
                                local GroupIndex = Char.GetTeamIndex(player,u)
                                if GroupIndex>=0 then
                                        for i=#team_save_tab[player],5,-1 do
                                                local teamindex=team_save_tab[player][i]
                                                if GroupIndex==teamindex then
                                                        team_lock_tab[teamindex]=nil
                                                        local yi=table.remove(team_save_tab[player],i)
                                                end
                                        end
                                        local Fd = Protocol.GetFdByChar(GroupIndex)
                                        Protocol.Send(Fd,"Teamviewer 3")
                                end
                        end
                        if #team_save_tab[player]==5 then--假设匹配队列里还剩1人,组成单人队列
                                local newcaptain = team_save_tab[player][5]
                                team_player_time[newcaptain]={team_player_time[player][1],team_player_time[player][2]}--继承等待的时间
                                team_lock_tab[newcaptain]={team_lock_tab[player][1],newcaptain}
                                Char.SetLoopEvent(nil, "Auto_team_onceplayer_Loop",newcaptain,5023)
                                team_state_msg(newcaptain)
                        elseif #team_save_tab[player]>=6 then--队伍里还有2人以上,组成新组队队列
                                local newcaptain = -1
                                for i=5,#team_save_tab[player] do
--local job = Char.GetData(team_save_tab[player][i],%对象_职类ID%)
                                        local job = Char.GetData(team_save_tab[player][i],%对象_职类ID%)
                                        if job~=540 then
                                                newcaptain = team_save_tab[player][i]
                                                break
                                        end
                                end
                                team_player_time[newcaptain]={team_player_time[player][1],team_player_time[player][2]}--继承等待的时间
                                team_save_tab[newcaptain]={0,0,0,newcaptain}
                                for e=5,8 do
                                        local GroupIndex=team_save_tab[player][e] or -1
                                        if GroupIndex>=0 and newcaptain~=GroupIndex then
                                                local job = Char.GetData(GroupIndex,%对象_职类ID%)
                                                if job~=540 then--职业不为佣兵时,计入新的队列
                                                        team_lock_tab[GroupIndex]={team_lock_tab[player][1],newcaptain}--目的地地图类型
                                                        if job==60 then
                                                                team_save_tab[newcaptain][1]=team_save_tab[newcaptain][1]+1
                                                        end
                                                        if job == 40 or job ==70 or job==140 then
                                                                team_save_tab[newcaptain][2]=team_save_tab[newcaptain][2]+1
                                                        end
                                                        table.insert(team_save_tab[newcaptain],GroupIndex)
                                                end
                                        end
                                end
                                Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",newcaptain,10101)--10秒执行一次loop
                                team_state_msg(newcaptain)
                        end
                        Char.SetLoopEvent(nil, "Auto_team_templayer_Loop",player,0)
                        team_lock_tab[player]=nil
                        team_player_time[player]=nil
                        team_save_tab[player]=nil
                        local Fd=Protocol.GetFdByChar(player)
                        Protocol.Send(Fd,"Teamviewer 3")
                        if modl==1 then
                                NLG.SystemMessage(player,"[系统]:您的『匹配组队状态』由于地图切换而中断")
                        elseif modl==2 then
                                NLG.SystemMessage(player,"[系统]:您退出了『匹配组队』")
                        elseif modl==3 then
                                NLG.SystemMessage(player,"[系统]:您的『匹配组队状态』由于离开队伍而中断")
                        end
                elseif team_player_time[player]==nil and team_save_tab[player]==nil then--队员
                        local dzIndex = team_lock_tab[player][2]--获取队长index
                        local dz = Char.GetData(player,%对象_组队模式%)
                        if dz==0 or dz==2 then
                                for i=8,4,-1 do
                                        local teamindex=team_save_tab[dzIndex][i]
                                        if teamindex==player then
                                                local job = Char.GetData(player,%对象_职类ID%)
                                                if job==60 then
                                                        team_save_tab[dzIndex][1]=team_save_tab[dzIndex][1]-1
                                                end
                                                if job == 40 or job ==70 or job==140 then
                                                        team_save_tab[dzIndex][2]=team_save_tab[dzIndex][2]-1
                                                end
                                                table.remove(team_save_tab[dzIndex],i)
                                        end
                                end
                                team_state_msg(dzIndex)
                                team_lock_tab[player]=nil
                                local Fd=Protocol.GetFdByChar(player)
                                Protocol.Send(Fd,"Teamviewer 3")
                        elseif dz==1 then--队长
                                for t=0,4 do
                                        local GroupIndex = Char.GetTeamIndex(player, t) or -1
                                        if GroupIndex>=0 then
                                                for i=8,4,-1 do
                                                        local teamindex=team_save_tab[dzIndex][i]
                                                        if teamindex==GroupIndex then
                                                                local job = Char.GetData(GroupIndex,%对象_职类ID%)
                                                                if job==60 then
                                                                        team_save_tab[dzIndex][1]=team_save_tab[dzIndex][1]-1
                                                                end
                                                                if job == 40 or job ==70 or job==140 then
                                                                        team_save_tab[dzIndex][2]=team_save_tab[dzIndex][2]-1
                                                                end
                                                                table.remove(team_save_tab[dzIndex],i)
                                                        end
                                                end
                                                team_lock_tab[GroupIndex]=nil
                                                local Fd=Protocol.GetFdByChar(GroupIndex)
                                                Protocol.Send(Fd,"Teamviewer 3")
                                        end
                                end
                                team_state_msg(dzIndex)
                        end
                        if modl==1 then
                                NLG.SystemMessage(player,"[系统]:您的『匹配组队状态』由于地图切换而中断")
                        elseif modl==2 then
                                NLG.SystemMessage(player,"[系统]:您退出了『匹配组队』")
                        elseif modl==3 then
                                NLG.SystemMessage(player,"[系统]:您的『匹配组队状态』由于离开队伍而中断")
                        end
                end
        end
end

回复

使用道具 举报

Archiver|魔力研究社

GMT+8, 2025-5-15 17:27 , Processed in 0.130342 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表