From 546dcbc1cd69927955b15ff65caae657dc04bdde Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 13 二月 2026 14:23:43 +0800
Subject: [PATCH] 1111 【后台】执行命令支持;

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMTExec/Test.py          |   47 +++++++++++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_Execfile.py |   70 +++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+), 0 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_Execfile.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_Execfile.py
new file mode 100644
index 0000000..3fed771
--- /dev/null
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_Execfile.py
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+# -*- coding: GBK -*-
+#-------------------------------------------------------------------------------
+#
+##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_Execfile
+#
+# @todo:GM工具命令 - 执行命令
+# @author hxp
+# @date 2026-02-13
+# @version 1.0
+#
+# 详细描述: GM工具命令 - 执行命令
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2026-02-13 14:30"""
+#-------------------------------------------------------------------------------
+
+import GMCommon
+import GameWorld
+import DataRecordPack
+import traceback
+import os
+
+## 收到gm命令执行
+# @param gmCmdDict:gm命令字典
+# @return None 
+def OnExec(gmCmdDict):
+    
+    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
+    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
+    cmdInfo = gmCmdDict.get('cmdInfo', '')
+    if not cmdInfo:
+        return GMCommon.Def_ParamErr
+    GMT_Name = gmCmdDict.get(GMCommon.Def_GMKey_Type, '') 
+    
+    playerID, playerName, accID = 0, "", ""
+    curPlayer = None
+    errorMsg = ""
+    if playerFind:
+        from GMToolLogicProcess import  ProjSpecialProcess
+        Result, curPlayer = ProjSpecialProcess.GMCmdPlayerValidation(gmCmdDict, False)
+        if Result != GMCommon.Def_Success:
+            return Result, errorMsg
+        if not curPlayer:
+            return Result, "玩家不在线"
+        playerID = curPlayer.GetPlayerID()
+        playerName = curPlayer.GetPlayerName()
+        accID = curPlayer.GetAccID()
+        
+    backDir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+    execfilepath = os.path.join(backDir, "GMTExec\\%s.py" % cmdInfo)
+    GameWorld.Log("GMT_Execfile: %s" % execfilepath)
+    
+    if not os.path.exists(execfilepath):
+        return GMCommon.Def_ParamErr, "%s is not exists!" % cmdInfo
+    
+    resultDict = {"cmdInfo":cmdInfo}
+    
+    try:
+        execfile(execfilepath, globals(), locals())
+    except:
+        errMsg = traceback.format_exc()
+        GameWorld.ErrLog(errMsg)
+        
+        resultDict["errMsg"] = errMsg
+        return GMCommon.Def_Unknow, resultDict
+    
+    #流向
+    DataRecordPack.DR_ToolGMOperate(playerID, playerName, accID, GMT_Name, resultDict)
+    return GMCommon.Def_Success, resultDict
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMTExec/Test.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMTExec/Test.py
new file mode 100644
index 0000000..d755441
--- /dev/null
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMTExec/Test.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+# -*- coding: GBK -*-
+#-------------------------------------------------------------------------------
+#
+##@package Script.PyMongoDB.GMToolLogicProcess.GMTExec.Test
+#
+# @todo:测试命令文件运行
+# @author hxp
+# @date 2026-02-13
+# @version 1.0
+#
+# 详细描述: 测试命令文件运行
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2026-02-13 14:30"""
+#-------------------------------------------------------------------------------
+
+def runMyTest(exec_locals):
+    ''' 运行命令函数
+    @param exec_locals: GY_Query_GMTExecfile 模块中的 DoLogic 函数 locals()
+    
+    import 其他模块需要写在此函数里,不然无法引用到
+    '''
+    import GameWorld
+    
+    cmdInfo = exec_locals["cmdInfo"]
+    curPlayer = exec_locals.get("curPlayer", None)
+    resultDict = exec_locals["resultDict"] # 建议都进行更新结果字典记录详细处理信息,GY_Query_GMTExecfile 模块会统一写入流向
+    playerID = 0
+    
+    # 以下为详细处理逻辑
+    # 指定玩家的逻辑
+    if curPlayer:
+        playerID = curPlayer.GetPlayerID()
+        resultDict.update({"LV":curPlayer.GetLV(), "PlayerID":curPlayer.GetPlayerID()})
+        
+    # 无玩家的逻辑
+    else:
+        resultDict.update({"OK":1})
+        
+    GameWorld.Log("GMT_Execfile run %s" % cmdInfo, playerID)
+    return
+
+exec_locals = locals()
+if exec_locals.get("cmdInfo"):
+    runMyTest(exec_locals)
+    
\ No newline at end of file

--
Gitblit v1.8.0