| New file |
| | |
| | | #!/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
|