local OnlyGmLogin = 0 --是否只允许gm登录,1为只允许GM登陆,0为关闭该功能
local NPCName = "原地登录领取员"; --设置领取原地登录的NPC名字
local NPCPoint = {99261,1000,232,106,4}; --原地登录领取员的原型,地图,X坐标,Y坐标,方向
local LoginNumber = 10;--设置人物登陆次数
local NoMyloginMap= {};--原地登录无效地图,下面是固定书写格式,NoMyloginMap[地图编号]=1
NoMyloginMap[62300] = 1
NoMyloginMap[62301] = 1
----------------------------------------------↑设置↑--------------------------------------
--Global_Reg.RegLoginEvent ("MyLoginEvent");
Global_Reg.RegInit("Login_Init");
Global_Reg.RegLoginGateEvent("MyLoginGatet");
Global_old_place_Num = {};--建立存储玩家唯一码的表
function MyLoginEvent(_charaIndex)
if Char.GetData(_charaIndex,51) ~=540 then--对象不是佣兵时启动原地登陆
if OnlyGmLogin == 1 and NLG.Get_Char_Date(_charaIndex,145) == 0 then--只允许GM登陆功能
NLG.Close_Socket(_charaIndex);
return
elseif NoMyloginMap[Char.GetData(_charaIndex,%对象_地图%)]==1 then--判断是否处于限制原地登陆地图
NLG.SystemMessage(_charaIndex, "[原地登录系统] 位于禁止原地登陆区域,传送回定居点");
gobacklogin(_charaIndex)
else
local playerObj = Char.GetData(_charaIndex,%对象_帐号%)..Char.GetData(_charaIndex,48);
if Global_old_place_Num[playerObj] == nil then
Global_old_place_Num[playerObj] = LoginNumber;
local maptype,mapid,posx,posy=savemapinfo(_charaIndex)
NLG.SystemMessage(_charaIndex,"[系统]原地登录:您已回到"..string.sub(Map.GetMapName(maptype,mapid),1,-3).."("..posx..","..posy..")")
NLG.SystemMessage(_charaIndex, "[系统]原地登陆:原地登录剩余次数:" .. Global_old_place_Num[playerObj]);
elseif Global_old_place_Num[playerObj] ~= 0 then
Global_old_place_Num[playerObj] = Global_old_place_Num[playerObj] - 1
if(Global_old_place_Num[playerObj]==0)then
local maptype,mapid,posx,posy=savemapinfo(_charaIndex)
NLG.SystemMessage(_charaIndex,"[系统]原地登录:您已回到"..string.sub(Map.GetMapName(maptype,mapid),1,-3).."("..posx..","..posy..")")
NLG.SystemMessage(_charaIndex, "[系统]原地登陆:这是您的最后一次原地登录,下次登录将回到定居点。");
else
local maptype,mapid,posx,posy=savemapinfo(_charaIndex)
NLG.SystemMessage(_charaIndex,"[系统]原地登录:您已回到"..string.sub(Map.GetMapName(maptype,mapid),1,-3).."("..posx..","..posy..")")
NLG.SystemMessage(_charaIndex, "[系统]原地登陆:原地登录剩余次数:" .. Global_old_place_Num[playerObj]);
end
else
gobacklogin(_charaIndex)
NLG.SystemMessage(_charaIndex,"[系统]原地登陆:您的重连次数已耗尽,本次登录回到定居点并补充原地登录次数为"..LoginNumber.."次。");
Global_old_place_Num[playerObj] = LoginNumber;
end
end
end
return 0;
end
function PlaceNumNpc_Init()
local PlaceNumNpc = NL.CreateNpc(nil, "initLogin_Init");
Char.SetData(PlaceNumNpc,%对象_形象%,NPCPoint[1]);
Char.SetData(PlaceNumNpc,%对象_原形%,NPCPoint[1]);
Char.SetData(PlaceNumNpc,%对象_X%,NPCPoint[3]);
Char.SetData(PlaceNumNpc,%对象_Y%,NPCPoint[4]);
Char.SetData(PlaceNumNpc,%对象_地图%,NPCPoint[2]);
Char.SetData(PlaceNumNpc,%对象_方向%,NPCPoint[5]);
Char.SetData(PlaceNumNpc,%对象_原名%,NPCName);
NLG.UpChar(PlaceNumNpc)
LuaNpcIndex["PlaceNumNpc_Init"]=PlaceNumNpc;
InstallNpc("PlaceNumNpc_Init",PlaceNumNpc);
if (Char.SetTalkedEvent(nil, "PlaceNum_Talked",PlaceNumNpc) < 0) then
print("PlaceNum_Talked 注册事件失败。");
return false;
end
return true;
end
function gobacklogin(_charaIndex)
if Char.EndEvent(_charaIndex,0) == 0 and Char.GetData(_charaIndex,4) == 1530 then
elseif Char.EndEvent(_charaIndex,0) == 0 then--玩家处于刚创建角色,还未做完新手任务的状态
NLG.Warp(_charaIndex,0,1530,15,6);
NLG.SystemMessage(_charaIndex,"[系统]原地登录:您已回到召唤之间")
elseif Char.GetData(_charaIndex,151) == 0 then--判断玩家定居点为0号定居点
local rd = math.random(1,6);
if rd == 1 then
NLG.Warp(_charaIndex,0,1000,233,78);
elseif rd == 2 then
NLG.Warp(_charaIndex,0,1000,242,100);
elseif rd == 3 then
NLG.Warp(_charaIndex,0,1000,141,148);
elseif rd == 4 then
NLG.Warp(_charaIndex,0,1000,63,79);
elseif rd == 5 then
NLG.Warp(_charaIndex,0,1000,162,130);
else
NLG.Warp(_charaIndex,0,1000,72,123);
end
elseif Char.GetData(_charaIndex,151) == 1 then--判断玩家定居点为1
NLG.Warp(_charaIndex,0,33200,99,165);--阿凯鲁法村定居点坐标
elseif Char.GetData(_charaIndex,151) == 2 then--判断玩家定居点为2
NLG.Warp(_charaIndex,0,43100,120,107);--哥拉尔镇定居点坐标
else
NLG.Warp(_charaIndex,0,1000,233,78);
end
end
function savemapinfo(_charaIndex)
local maptype = Char.GetData(_charaIndex,%对象_地图类型%)
local mapid = Char.GetData(_charaIndex,%对象_地图%)
local posx = Char.GetData(_charaIndex,%对象_X%)
local posy = Char.GetData(_charaIndex,%对象_Y%)
return maptype,mapid,posx,posy
end
function PlaceNum_Talked( _MeIndex, _PlayerIndex)
if(NLG.CheckInFront(_PlayerIndex, _MeIndex, 1) == false) then
return ;
end
Global_old_place_Num[Char.GetData(_PlayerIndex,%对象_帐号%)..Char.GetData(_PlayerIndex,48)] = LoginNumber;
NLG.ShowWindowTalked(_PlayerIndex, 0, 1, 0, "\n\n 您的原地次数已补充至 "..LoginNumber.." 次!", _MeIndex);
return ;
end
function initLogin_Init(index)
return true;
end
function Login_Init()
PlaceNumNpc_Init();
end
function MyLoginGatet(_charaIndex)
local playerObj = Char.GetData(_charaIndex,%对象_帐号%)..Char.GetData(_charaIndex,48);
Global_old_place_Num[playerObj] = LoginNumber;
NLG.SystemMessage(_charaIndex,"[系统]原地登陆:您登出到定居点,原地登陆次数自动补充为"..LoginNumber.."次!您也可以去"..string.sub(Map.GetMapName(0,NPCPoint[2]),1,-3).."("..NPCPoint[3]..","..NPCPoint[4]..")".."寻找"..NPCName.."补充登陆次数。");
return 0
end
|
|