- -- 步步遇敌开关
- isYD = {};
- -- 监测一级宠物开关
- isTS = {};
- -- 挂机战斗开关
- isZD = {};
-
- function Chat_Split( str, reps )
- local resultStrList = {}
- string.gsub(str,'[^'..reps..']+', function ( w )
- table.insert(resultStrList, w)
- end)
- return resultStrList;
- end
-
- function Encount_Battle(_player)
- if (not isYD[_player]) then
- return;
- end
- if (Char.GetData(_player,%对象_战斗状态%) > 0) then
- return;
- end
- if (Char.PartyNum(_player) > 1 and Char.GetPartyMember(_player,0) ~= _player) then
- isYD[_player] = false;
- NLG.SystemMessage(_player,"【步步遇敌】关闭,你不是队长!");
- return;
- end
- Battle.Encount(_player,_player);
- if (Char.GetData(_player,%对象_战斗状态%) > 0) then
- return;
- end
- isYD[_player] = false;
- NLG.SystemMessage(_player,"【步步遇敌】关闭,当前地图无法遇敌!");
- return;
- end
-
- function Find_LevelOnePet(_battle)
- if Battle.GetType(_battle) ~= %战斗_普通% then
- return 0;
- end
- for _target=10,19 do
- _pet = Battle.GetPlayer(_battle, _target);
- if(_pet > -1) and Char.GetData(_pet, %对象_等级%) == 1 then
- for _member=0,9 do
- _player = Battle.GetPlayer(_battle, _member);
- if(_player > -1 and isTS[_player]) then
- NLG.SystemMessage(_player,"战斗 " .. _battle .. "【出现一级宠物】" .. Char.GetData(_pet,%对象_名字%));
- end
- end
- end
- end
- return 0;
- end
-
- function Order_TalkEvent(_player, _msg, _color, _range, _size)
- if string.byte(_msg) ~= 47 then
- return;
- end
- local params = Chat_Split(_msg, ' ');
- local cmd = string.sub(params[1], 2);
- if type(tonumber(cmd)) == "number" then
- return 0;
- elseif string.len(cmd) == 0 then
- return;
- end
- cmd = string.upper(cmd);
-
- -- 步步遇敌
- if cmd == 'YD' then
- if (isYD[_player] == nil) then
- Char.SetWalkPostEvent(nil,"Encount_Battle",_player);
- isYD[_player] = false;
- end
- if (not isYD[_player]) then
- if (Char.PartyNum(_player) > 1 and Char.GetPartyMember(_player,0) ~= _player) then
- NLG.SystemMessage(_player,"【步步遇敌】仅队长可开启!");
- return 0;
- end
- isYD[_player] = true;
- NLG.SystemMessage(_player,"【步步遇敌】开启");
- else
- isYD[_player] = false;
- NLG.SystemMessage(_player,"【步步遇敌】关闭");
- end
- return 0;
- end
-
- -- 提示1级宠物
- if cmd == 'TS' then
- if(isTS[_player] == nil) then
- isTS[_player] = false;
- end
- if(isTS[_player]) then
- isTS[_player] = false;
- NLG.SystemMessage(_player,"【提示1级宠物】关闭");
- else
- isTS[_player] = true;
- NLG.SystemMessage(_player,"【提示1级宠物】开启");
- end
- return 0;
- end
-
- -- 观战
- if cmd == 'GZ' then
- local tName = params[2];
- if(tName == nil or string.len(tName) < 1) then
- NLG.SystemMessage(_player,"观战指令格式:/gz <name>");
- return 0;
- end
- local select = string.format("SELECT CdKey FROM tbl_character WHERE Name=\'%s\' ", tName);
- local rset = SQL.Run(select);
- if (Char.PartyNum(_player) > 1 and Char.GetPartyMember(_player,0) ~= _player) then
- NLG.SystemMessage(_player,"仅队长可开启观战!");
- return 0;
- end
- if(type(rset) == "table" and rset["0_0"]) then
- local tplayer = NLG.FindUser(rset["0_0"]);
- if(_player == tplayer) then
- NLG.SystemMessage(_player,"无法观战自己。");
- return 0;
- end
- if(tplayer > -1) then
- NLG.WatchBattle(_player, tplayer);
- else
- NLG.SystemMessage(_player,"该玩家不在线。");
- end
- else
- NLG.SystemMessage(_player,"未查询到名为" ..tName.. "的玩家。");
- end
- return 0;
- end
-
- -- 查看声望
- if cmd == 'SW' then
- local sw = Char.GetData(_player, %对象_声望%);
- NLG.SystemMessage(_player,"您当前的声望为" ..sw.. ".");
- return 0;
- end
-
- -- 测试
- if cmd == 'TEST' then
- local rand = NLG.Rand(0, 10);
- NLG.SystemMessage(_player,"随机数" ..rand.. ".");
- return 0;
- end
- end
-
- function Init_isYD(_player)
- if(isYD[_player]) then
- NLG.SystemMessage(_player,"检测到登出,【步步遇敌】关闭。");
- isYD[_player] = false;
- end
- return;
- end
-
- -- 注册事件
- NL.RegTalkEvent(nil,"Order_TalkEvent");
- NL.RegBattleStartEvent(nil, 'Find_LevelOnePet');
-
- -- 重置步步遇敌开关
- NL.RegLogoutEvent(nil, "Init_isYD");
- NL.RegLoginGateEvent(nil, "Init_isYD");
复制代码
|