找回密码
 注册/Sign up
搜索
查看: 2307|回复: 9

[Lua] 自助踢号 & 自助清理崩端卡号

[复制链接]
发表于 2021-12-17 12:13:38 | 显示全部楼层 |阅读模式
本帖最后由 muscipular 于 2021-12-17 12:16 编辑
  1. ---模块类
  2. local Module = ModuleBase:createModule('autoUnlock')
  3. function Module:onLogin(fd, head, data)
  4.   local user = SQL.querySQL('select RegistNumber from tbl_lock where CdKey = ' .. SQL.sqlValue(data[3]), true);
  5.   if user then
  6.     local charIndex = NLG.FindUser(data[3], tonumber(user[1][1]));
  7.     if charIndex >= 0 then
  8.       return 0;
  9.     end
  10.     self:logInfo('解锁', data[3])
  11.     SQL.querySQL('delete from tbl_lock where CdKey = ' .. SQL.sqlValue(data[3]));
  12.   end
  13. end
  14. function Module:onTalked(charIndex, msg, color, range, size)
  15.   local command = msg:match('^/([%w]+)')
  16.   if command and string.lower(command) == 'selfkickout' then
  17.     local arg = msg:match('^/[%w]+ +(.+)$')
  18.     arg = arg and string.split(arg, ' ') or {}
  19.     if #arg >= 2 then
  20.       local ret = SQL.querySQL("select 1 from tbl_user where CdKey = " .. SQL.sqlValue(arg[1]) .. ' and AccountPassWord = ' .. SQL.sqlValue(arg[2]), true)
  21.       if ret ~= nil then
  22.         local targetChar = NLG.FindUser(arg[1]);
  23.         if targetChar >= 0 then
  24.           self:logInfoF("%s(%s) 踢出 %s(%s)",
  25.             Char.GetData(charIndex, CONST.CHAR_名字),
  26.             Char.GetData(charIndex, CONST.CHAR_CDK),
  27.             Char.GetData(targetChar, CONST.CHAR_名字),
  28.             Char.GetData(targetChar, CONST.CHAR_CDK)
  29.           )
  30.           NLG.DropPlayer(targetChar);
  31.           NLG.SystemMessage(charIndex, string.format('操作成功'));
  32.         else
  33.           NLG.SystemMessage(charIndex, string.format('该账户不在线'));
  34.         end
  35.       else
  36.         --todo 安全防护
  37.         NLG.SystemMessage(charIndex, string.format('账号或密码不正确'));
  38.       end
  39.     else
  40.       NLG.SystemMessage(charIndex, string.format('指令错误: /selfKickOut 账号 密码'));
  41.     end
  42.     return 0
  43.   end
  44.   return 1
  45. end
  46. --- 加载模块钩子
  47. function Module:onLoad()
  48.   self:logInfo('load')
  49.   self:regCallback('ProtocolOnRecv', Func.bind(self.onLogin, self), 'JFVf');
  50.   self:regCallback('TalkEvent', Func.bind(self.onTalked, self));
  51. end
  52. --- 卸载模块钩子
  53. function Module:onUnload()
  54.   self:logInfo('unload')
  55. end
  56. return Module;
复制代码

基于框架v0.1.17 https://github.com/Muscipular/cgmsv-lua/releases/tag/v0.1.17

评分

参与人数 1金币 +1 收起 理由
Zack + 1 原创资源贴

查看全部评分

发表于 2021-12-17 16:11:29 | 显示全部楼层
大佬牛皮!
对了,能不能完善一下假人系统,让右键点击假人的时候可以激活NPC对话、或是自定义函数?
 楼主| 发表于 2021-12-17 20:06:53 | 显示全部楼层
2bman 发表于 2021-12-17 16:11
大佬牛皮!
对了,能不能完善一下假人系统,让右键点击假人的时候可以激活NPC对话、或是自定义函数?
...

这种自己组合一下吧,应该不难的。

发表于 2021-12-17 20:23:21 | 显示全部楼层
muscipular 发表于 2021-12-17 20:06
这种自己组合一下吧,应该不难的。

我试过把假人和透明NPC放一起,但是右键点击假人会弹出系统提示,CGMSV的右键点击事件无法屏蔽这个系统消息。
 楼主| 发表于 2021-12-17 21:01:31 来自手机 | 显示全部楼层
2bman 发表于 2021-12-17 20:23
我试过把假人和透明NPC放一起,但是右键点击假人会弹出系统提示,CGMSV的右键点击事件无法屏蔽这个系统消 ...

估计是cg行为?应该跟gm菜单lua差不多才对..

发表于 2021-12-18 13:18:31 | 显示全部楼层
本帖最后由 2bman 于 2021-12-18 13:19 编辑
muscipular 发表于 2021-12-17 21:01
估计是cg行为?应该跟gm菜单lua差不多才对..

应该是服务器的触发,GM菜单同样也没办法禁止『提示!XXX的简介设置为不公开。』这个提示。
NL.RegRightClickEvent 是没办法阻止服务器的默认动作的,所以总是会发出提示。

我尝试在 cgmsv.exe 里删除提示文本,不过会导致右键假人、玩家时清空整个聊天栏。

发表于 2021-12-18 16:40:25 | 显示全部楼层
大佬是真心牛逼

发表于 2021-12-25 20:26:02 | 显示全部楼层
给捕蝇草大老推一个
 楼主| 发表于 2021-12-25 20:55:24 | 显示全部楼层
麻利小六 发表于 2021-12-25 20:26
给捕蝇草大老推一个

看来是ro大佬

发表于 2022-1-4 00:33:20 | 显示全部楼层
看来是ro大佬
您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

GMT+8, 2026-6-5 09:15 , Processed in 0.033012 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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