---------------***********************************************************---------------
local Talk_Winml_Msg = Talk_Winml_Msg or {};
channel_CharTable = channel_CharTable or {};
channel_mseTable = channel_mseTable or {}
local Talk_SetConfig = Talk_SetConfig or {};--次数,几秒一次,颜色,字体大小
---------------***********************************************************---------------
Global_Reg.RegLoginEvent("channel_login");--人物登入
Global_Reg.RegLogoutEvent("channel_out");--登出
Global_Reg.RegTalkEvent ("channel_control");--玩家说话
---------------***********************************************************---------------
function channel_login(player)
local job = Char.GetData(player,51)
if job~=540 then
local fd = Protocol.GetFdByChar(player)
Protocol.Send(fd,"WinmlTalk Set $8简易|$0普通|$4世界|$3区域|");--$1家族|$2活动 频道顺序:0,1,2,3
Talk_SetConfig[player]={30,2,4,2}
if Talk_Winml_Msg[player] then
Talk_Winml_Msg[player]=nil
end
end
return 0;
end
function channel_out(CharIndex)--登出
if channel_CharTable[CharIndex] then
channel_CharTable[CharIndex]=nil
end
if channel_mseTable[CharIndex] then
channel_mseTable[CharIndex]=nil
end
if Talk_SetConfig[CharIndex] then
Talk_SetConfig[CharIndex]=nil
end
if Talk_Winml_Msg[player] then
Talk_Winml_Msg[player]=nil
end
return 0
end
function Win_Channel_msg(fd,packet,player)
local TalkMsg = WinMl_LocalSplit(packet," ");
local Channel = tonumber(TalkMsg[2])
if channel_CharTable[player]==nil then
channel_CharTable[player]= 1
channel_mseTable[player]={"","","","","","","","","","","","","","","","","","","",""}--参考{"4,战斗信息","1,战斗信息"}
return 0
elseif Channel ~= channel_CharTable[player] then
channel_CharTable[player]=Channel
if Channel == 0 then
NLG.SystemMessage(player,"您切换到了[简易]频道,该频道不会接收伙伴战斗提示信息,当您切换回[普通]频道时,将会显示最多20条屏蔽的战斗信息");
elseif Channel == 1 then--切换到普通频道,显示预存信息
for _,v in pairs(channel_mseTable[player]) do
if v~="" then
local msginfo = WinMl_LocalSplit(v,"|");
local colour = tonumber(msginfo[1])
local msg = msginfo[2]
NLG.TalkToCli(player, msg, colour, 4);
end
end
elseif Channel == 2 then
NLG.SystemMessage(player,"您切换到了[世界]频道,该频道发言一次收费5000G");
elseif Channel == 3 then
NLG.SystemMessage(player,"您切换到了[区域]频道,该频道发言可被整个地图内的玩家接收");
end
end
return 0
end
function channel_control(player, msg, color, range, size,channeltype)
local ScapeMsg = WinMl_LocaleScape(msg);
Talk_Winml_Msg[player] = ScapeMsg;
Talk_SetConfig[player][3]=color
Talk_SetConfig[player][4]=size
local msg=string.sub(msg,3,-1)
local Channel = channel_CharTable[player]
local GM = NLG.Get_Char_Date(player,145)--返回0为正常玩家,返回1为GM
if GM~=1 then
if Channel==2 then
local gold = Char.GetData(player,53)
if gold<5000 then
NLG.SystemMessage(player,"您身上的魔币不足5000G,无法使用[世界]频道");
return -1;
else
local redgold = NLG.AddGold(player, -5000);
local name = Char.GetData(player,2000)
msg = "[世界]"..name..":"..msg
NLG.SystemMessage(-1,msg);
return -1;
end
elseif Channel==3 then
local mapfloor = Char.GetData(player,%对象_地图类型%)
local mapID = Char.GetData(player,%对象_地图%)
local name = Char.GetData(player,2000)
msg = "[区域]"..name..":"..msg
if mapfloor==0 and (mapID==1000 or mapID==60005 or mapID==60039 or mapID==60037 or mapID==60038 or mapID==60054) then
NLG.TalkToFloor(mapfloor,1000,msg, color, size);
NLG.TalkToFloor(mapfloor,60005,msg, color, size);
NLG.TalkToFloor(mapfloor,60039,msg, color, size);
NLG.TalkToFloor(mapfloor,60037,msg, color, size);
NLG.TalkToFloor(mapfloor,60038,msg, color, size);
NLG.TalkToFloor(mapfloor,60054,msg, color, size);
else
NLG.TalkToFloor(mapfloor,mapID,msg, color, size);
end
return -1;
end
end
return 0;
end
function battle_friend_msg(BattleIndex,SD,msg)--给战斗内非0号频道的全部玩家对象发送消息
local msg = tostring(msg)
if msg~="" or msg~=nil then
for i=0,1 do
for Num=0,9 do
local Charindex = Battle.GetPlayIndex(BattleIndex,i,Num);
if Charindex>=0 then
local ifpet=Char.GetData(Charindex,0)
if ifpet==1 then--是人
local job=Char.GetData(Charindex,51)
if job~=540 then--不是佣兵
if channel_CharTable[Charindex]~=0 then--不在简易频道
if SD==1 then
NLG.TalkToCli(Charindex, msg, 1, 4);
else
NLG.TalkToCli(Charindex, msg, 4, 4);
end
elseif channel_CharTable[Charindex]==0 then
if SD==1 then
local count = 0
for k,v in pairs(channel_mseTable[Charindex]) do
if v~="" then
count = count +1
else
local msg = "1|"..msg
channel_mseTable[Charindex][k]=msg
break
end
end
if count==20 then
local msg = "1|"..msg
table.remove(channel_mseTable[Charindex],1)
table.insert(channel_mseTable[Charindex],msg)
end
else
local count = 0
for k,v in pairs(channel_mseTable[Charindex]) do
if v~="" then
count = count +1
else
local msg = "4|"..msg
channel_mseTable[Charindex][k]=msg
break
end
end
if count==20 then
local msg = "4|"..msg
table.remove(channel_mseTable[Charindex],1)
table.insert(channel_mseTable[Charindex],msg)
end
end
end
end
end
end
end
end
end
return 0
end
function Win_loopTalk(Fd,Pack)
local TalkMsg = WinMl_LocalSplit(Pack," ");
if(#TalkMsg < 2)then
return 1;
end
local CharIndex = Protocol.GetCharByFd(Fd);
if(TalkMsg[2] ~= nil and TalkMsg[2] == "Login")then
Talk_Winml_Msg[CharIndex] = nil;
return 1;
end
local Channel = channel_CharTable[CharIndex]
if (Talk_Winml_Msg[CharIndex] ~= nil and Talk_Winml_Msg[CharIndex] ~= "" ) and (Channel==0 or Channel==1) then
local SendBuf = string.format("WinmlTalk %d %d %d %d %s ",Talk_SetConfig[CharIndex][1],Talk_SetConfig[CharIndex][2],Talk_SetConfig[CharIndex][3],Talk_SetConfig[CharIndex][4],Talk_Winml_Msg[CharIndex]);
Protocol.Send(Fd,SendBuf)
NLG.SystemMessage(CharIndex, "[提示]:喊话将持续1分钟");
elseif Channel~=0 and Channel~=1 then
NLG.SystemMessage(CharIndex, "[提示]:喊话只能在[简易]和[普通]频道使用");
else
NLG.SystemMessage(CharIndex, "[提示]:使用喊话要先说一句话哦~");
end
return 1;
end
------------------------------------?????-----------------------------------
function WinMl_LocalSplit(szFullString, szSeparator)
if(szFullString == nil) then
return nil;
end
local nFindStartIndex = 1
local nSplitIndex = 1
local nSplitArray = {}
while true do
local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex,true)
if not nFindLastIndex then
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))
break
end
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)
nFindStartIndex = nFindLastIndex + string.len(szSeparator)
nSplitIndex = nSplitIndex + 1
end
return nSplitArray
end
------------------------------????????-----------------------------------
function WinMl_LocaleScape(szFullString)
szFullString = string.gsub(szFullString, "\92\99",",");
szFullString = string.gsub(szFullString, "\92\121","\\")
szFullString = string.gsub(szFullString, "\92\122","|")
szFullString = string.gsub(szFullString, "P|","")
return szFullString;
end
|
|