搜索
LUA

LUA

本版块未设置版块简介!请后台版块编辑添加。
  •  帖子: 115
  •  讨论: 115
  •  关注: 0

Login.lua--原地登陆

GP 发表于 2025-5-10 02:50:51 | 显示全部楼层 |阅读模式
150 0
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


回复

使用道具 举报

全部评论

暂无评论,期待您打破宁静

TA的帖子
相关帖子
  • admin 2025-5-10

    #先到阿斯提亞鎮 打完UD找到NPC卡蓮 拿到給LBLS 的信 然後去打LBLS 再打完 LBLS以後 ...

  • admin 2025-5-10

    用本目录下文件"内容"覆盖服务器data目录下同名文件相应"内容" 请勿直接覆盖文件本身 ...

  • admin 2025-5-11

    ############## 城城的武器强化系统 ############## #剑1 block StrCmpChat == 700 W ...

  • admin 2025-5-11

    魔力宝贝手动架设中遇到的问题及解决方法魔力宝贝手动架设教程—魔力私服,魔力宝贝私 ...

  • admin 2025-5-12

    起始地点法兰城的竞技场的贝贝(34.36)头目战╳ 必要条件---必要等级Lv1 职业限定---建 ...

  • admin 2025-5-12

    1.与里谢里雅堡的H1N1防疫宣传员(28,77)说话,取得"防疫小口罩"。 图例物品名称等级种 ...

  • admin 2025-5-12

    魅惑的哈密瓜无取得宠物「哈密瓜公主」╳╳○ 起始地点魔法大学头目战╳ 必要条件--- ...

  • admin 2025-5-12

    起始地点法兰城的里谢里雅堡头目战○ 必要条件---必要等级--- 职业限定---建议等级--- ...

  • admin 2025-5-12

    起始地点法兰城的里谢里雅堡头目战○ 必要条件---必要等级--- 职业限定---建议等级--- ...

  • admin 2025-5-12

    起始地点法兰城的冒险者旅馆头目战○ 必要条件---必要等级--- 职业限定---建议等级LV8 ...

发布 联系QQ