From 6e38897c4625e5366ae10a0ec8ea75ca5d45f879 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 10 二月 2025 11:19:49 +0800
Subject: [PATCH] 1111 【英文】【越南】【BT】【砍树】修复改名成功后扣除道具时物品可能已变更导致的bug;

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py      |   12 ++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/UpdatePlayerName.py |    6 +++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
index 718f9f7..cdc47a3 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
@@ -176,6 +176,18 @@
         
     return None
 
+def FindPlayerItemByType(curPlayer, packindex, itemType):
+    curPack = curPlayer.GetItemManager().GetPack(packindex)
+    for i in range(0, curPack.GetCount()):
+        item = curPack.GetAt(i)
+        
+        if not ItemCommon.CheckItemCanUse(item):
+            continue
+        
+        if item.GetType() == itemType:
+            return item
+        
+    return None
 
 ## 检查是否可以换马匹
 #  @param curPlayer 当前玩家
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/UpdatePlayerName.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/UpdatePlayerName.py
index 9117a39..9db01ba 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/UpdatePlayerName.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/UpdatePlayerName.py
@@ -29,6 +29,7 @@
 import ChPyNetSendPack
 import NetPackCommon
 import EventReport
+import ItemControler
 #------------------------------------------------------------------------------ 
 
 ## 合服首登
@@ -169,7 +170,10 @@
         #扣除物品
         itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
         curItem = itemPack.GetAt(itemIndex)
-        if curItem:
+        if not __CheckItemUpdatePlayerName(curPlayer, curItem):
+            # 物品可能已经变更,不是改名道具了或为空,重新找一遍
+            curItem = ItemControler.FindPlayerItemByType(curPlayer, IPY_GameWorld.rptItem, ChConfig.Def_ItemType_ChangePlayerName)
+        if ItemCommon.CheckItemCanUse(curItem):
             ItemCommon.DelItem(curPlayer, curItem, 1, True, 'UpdatePlayerName')
     
     #改名次数+1

--
Gitblit v1.8.0