找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 589|回复: 0

兑换点数

[复制链接]

35

主题

9

回帖

214

积分

中级会员

积分
214
发表于 2021-12-8 15:50:20 | 显示全部楼层 |阅读模式
本帖最后由 20000 于 2021-12-8 15:57 编辑

一、客户端
1、补丁修改 Interface 目录下 YuanbaoExchange\YuanbaoExchange.xml

  1. <Window Type="TLBB_EditBoxNormal" Name="YuanbaoExchange_Moral_Value">
  2.         <Property Name="UnifiedSize" Value="{{1.000000,-120.000000},{0.000000,20.000000}}"/>
  3.         <Property Name="UnifiedPosition" Value="{{0.000000,38.000000},{1.000000,-93}}"/>
  4.         //此条表示这个输入框最大长度只能输入 5 位数
  5.         <Property Name="MaxTextLength" Value="5" />
  6.         //下面表示此输入框表示只能输入0-9的数字。[0-9]* 是正则验证规则
  7.         <Property Name="ValidationString" Value="[0-9]*" />
  8.         //下面表示是此框的事件,调用了方法。对应的方法在 UI 对应的 Lua 脚本里面定义了逻辑
  9.         <Event Name="TextChanged" Function="YuanbaoExchange_Count_Change();" />
  10. </Window>
  11. YuanbaoExchange_Count_Change() 此方法为记录输入框数据改变,可以在UI界面对应的 lua 脚本里面查询到具体代码的逻辑。

  12. <Window Type="TLBB_ButtonCommon" Name="YuanbaoExchange_Max">
  13.         <Property Name="UnifiedSize" Value="{{0.000000,40.000000},{0.000000,20.000000}}"/>
  14.         <Property Name="UnifiedPosition" Value="{{1.000000,-78.000000},{1.000000,-93}}"/>
  15.         <Property Name="Text" Value="#{INTERFACE_XML_903}" />
  16.         <Event Name="Clicked" Function="YuanbaoExchange_Max_Clicked();" />
  17. </Window>

  18. YuanbaoExchange_Max_Clicked() 此该当为最大兑换方法,可以在UI界面对应的 lua 脚本里面查询到具体代码的逻辑。

  19. <Window Type="TLBB_ButtonCommon" Name="YuanbaoExchange_OK">
  20.     <Property Name="UnifiedPosition" Value="{{1.000000,-82.000000},{1.000000,-20.000000}" />
  21.     <Property Name="AbsoluteSize" Value="w:40.000000 h:20.000000" />
  22.     <Property Name="Text" Value="#{INTERFACE_XML_258}" />
  23.     <Event Name="Clicked" Function="YuanbaoExchange_OK_Clicked();" />
  24. </Window>

  25. YuanbaoExchange_OK_Clicked() 此该当为兑换方法,可以在UI界面对应的 lua 脚本里面查询到兑换的主要逻辑
复制代码



2、补丁修改 Interface 目录下 YuanBaoExchange\YuanbaoExchange.lua

  1. -- 此方法为记录输入框数据改变,可以在UI界面对应的 lua 脚本里面查询到具体代码的逻辑。
  2. function YuanbaoExchange_Count_Change()
  3.     -- 获取输入的值,点数
  4.     local str = YuanbaoExchange_Moral_Value : GetText();
  5.     local strNumber = 0;
  6.     if ( str == nil ) then
  7.         return;
  8.     elseif( str == "" ) then
  9.         strNumber = 1;
  10.     else
  11.         strNumber = tonumber( str );
  12.     end
  13.     str = tostring( strNumber );
  14.     YuanbaoExchange_Moral_Value:SetTextOriginal( str );
  15.     YuanbaoExchange_Text3 : SetText("需要花费点数:"..tostring( Exchange_Rate * strNumber ) )
  16. end

  17. -- 点击界面最大值的方法
  18. function YuanbaoExchange_Max_Clicked()
  19.     -- 最大值限定在10万,
  20.     local maxYuanBao = 100000;
  21.     local point2YuanBao = g_Point/Exchange_Rate;
  22.     if point2YuanBao < 0 then point2YuanBao = 0; end

  23.     YuanbaoExchange_Moral_Value:SetProperty("ClearOffset", "True");
  24.     if point2YuanBao > maxYuanBao then
  25.         YuanbaoExchange_Moral_Value:SetText(tostring(maxYuanBao));
  26.     else
  27.         YuanbaoExchange_Moral_Value:SetText(tostring(point2YuanBao));
  28.     end
  29.     YuanbaoExchange_Moral_Value:SetProperty("CaratIndex", 1024);
  30. end

  31. -- 调用兑换元宝,赠点的逻辑
  32. function YuanbaoExchange_OK_Clicked()
  33.     local str = YuanbaoExchange_Moral_Value : GetText();

  34.     if str == nil or str == "" then
  35.         YuanbaoExchange_Text3 : SetText("需要花费点数:0")
  36.         PushDebugMessage("请输入要兑换的元宝数额")
  37.         return
  38.     end

  39.     if tonumber(str) > 100000 then
  40.         PushDebugMessage("每次兑换的元宝数量最多为100000点,请输入小于等于100000点的数字。")
  41.         return
  42.     end
  43.     if( tonumber(str) <= 0 ) then
  44.         PushDebugMessage("每次兑换的元宝数量最少为1点,请输入大于等于1点的数字。")
  45.         return
  46.     end

  47.     --AxTrace(0,0,"YuanbaoExchange_OK_Clicked 2");
  48.     -- 调用服务端接口,进行兑换赠点,元宝
  49.     Clear_XSCRIPT();
  50.         Set_XSCRIPT_Function_Name("BuyYuanbao");
  51.         Set_XSCRIPT_ScriptID(181000);
  52.         Set_XSCRIPT_Parameter(0,tonumber(str));
  53.         Set_XSCRIPT_Parameter(1,tonumber(g_Point));
  54.         Set_XSCRIPT_ParamCount(2);
  55.     Send_XSCRIPT();

  56.     YuanbaoExchange_Close();
  57. end
复制代码



二、服务端

1、通过调用关系,找到对应脚本。一般的版本都是在 主脚本 tlbb\Public\Data\Script\obj\qianzhuang\oqianzhuang_yuanbao.lua
-- 通过客户端调用的关系 BuyYuanbao 在里面查找到对应的方法

  1. function x181000_BuyYuanbao( sceneId, selfId, nYuanBao, leftPoint )
  2.     if leftPoint==0 then
  3.         x181000_NotifyTip( sceneId, selfId, "你没有任何可兑换的点数,请充值后重试。" )
  4.         return
  5.     end
  6.     x181000_NotifyTip( sceneId, selfId,"身上剩余点数:"..leftPoint..",兑换的点数:"..nYuanBao)
  7.     local zd=ZengDian(sceneId,selfId,targetId,3)
  8.     if nYuanBao*100000+zd>2100000000 then
  9.         x181000_NotifyTip( sceneId, selfId, "兑换赠点的值超过系统上限,请使用一部分后再兑换。" )
  10.         return
  11.     end
  12.     -- 此项,进行核心功能的调用 PRIZE_SCRIPT_ID 此ID可以在 Script.dat 里面查找到是哪个脚本
  13.     CallScriptFunction( PRIZE_SCRIPT_ID, "AskYuanBao", sceneId, selfId, nYuanBao,nYuanBao)
  14. end
  15. ·
  16. ·
  17. ·
  18. -- 通过上面查找,找到兑换的核心脚本 lua
  19. -- tlbb\Public\Data\Script\event\prize\eprize.lua
  20. --**********************************
  21. -- 购买 元宝
  22. --**********************************
  23. function x888899_AskYuanBao( sceneId, selfId, nYuanBao, nPoint )
  24.     -- 调用引擎方法。通过回调方法进行处理。nYuanBao 和 nPoint 是由客户端传递过来。
  25.     -- 因为传输的类型不一样。nPoint*10才能与对应的版本对应上。
  26.     GetCharPrize(sceneId,selfId,3,999,nYuanBao,nPoint*10);
  27. end

  28. --**********************************
  29. -- 购买 元宝 的返回回调函数
  30. -- ntype 请参考 enum PRIZE_TYPE_ENUM
  31. -- 1 代表 OPT_YUANBAO_ADD 增加元宝
  32. --**********************************
  33. function x888899_BuyRet( sceneId, selfId, ntype, nYuanBao, nLeftPoint )
  34.     if( 2 == ntype ) then
  35.         zd=nYuanBao
  36.         local mg=nYuanBao*100000
  37.         local t_mg=mg
  38.         local nMenpaiPoint=GetHumanMenpaiPoint(sceneId, selfId)
  39.         mg=mg+nMenpaiPoint
  40.         SetHumanMenpaiPoint(sceneId, selfId, mg)
  41.         YuanBao(sceneId,selfId,targetId,1,mg)
  42.         ZengDian(sceneId,selfId,targetId,1,zd)
  43.         BuyYuanBaoCount(sceneId,selfId,-1,1,nYuanBao)
  44.         local mecount = BuyYuanBaoCount(sceneId,selfId,-1,3,0)
  45.         local curmost = LuaFnGetWorldGlobalData(1)
  46.         if mecount > curmost then
  47.             LuaFnSetWorldGlobalData(1,mecount)
  48.             local nMonsterNum = GetMonsterCount(sceneId)
  49.             for i=0, nMonsterNum-1 do
  50.                 local MonsterId = GetMonsterObjID(sceneId,i)
  51.                 local MosDataID = GetMonsterDataID(sceneId, MonsterId )
  52.                 if MosDataID == 15735 then
  53.                     SetCharacterName(sceneId,MonsterId,GetName(sceneId,selfId))
  54.                 end
  55.             end
  56.         end
  57.         BeginEvent(sceneId)
  58.             strText = "您成功的兑换了"..tostring(zd).."点赠点!"
  59.             AddText(sceneId,strText)
  60.         EndEvent(sceneId)
  61.         DispatchMissionTips(sceneId,selfId)
  62.     end
  63. end
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|魅力松滋 ( 鄂ICP备2024076975号-1 )

GMT+8, 2025-5-6 11:30 , Processed in 0.053259 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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