sm

立即登录 | 账号注册

积分: 0 |用户组: 游客

搜索
服务器租用 传奇3一条龙 支付平台源码 无法下载点击此处反馈
查看: 470|回复: 2

[传奇手游源码] 战神引擎传奇元宝商城改金币购物_YBShopScript.pas

[复制链接]

826

主题

36

回帖

23万

积分

霸王教主

积分
235297
发表于 2023-8-11 01:24:37 | 显示全部楼层 |阅读模式
战神引擎传奇元宝商城改金币购物_YBShopScript.pas

下拉到最底部 复制代码粘贴到 _YBShopScript.pas即可使用
  1. PROGRAM Mir2;

  2. const                                       // 赤金钥匙|白银钥匙|紫铜钥匙|神秘钥匙|传音筒|
  3.   C_NeedLoadGoodsNames_001 = '随机传送石|修复神水|千里传音|千里传音(大)|1元宝|5元宝|10元宝|50元宝|100元宝|金条|珠宝箱';   
  4.   C_NeedLoadGoodsNames_002 = '随机传送石|修复神水|千里传音|千里传音(大)|1元宝|5元宝|10元宝|50元宝|100元宝|金条|珠宝箱';   

  5. var                                      
  6.   UsingGoodsName: string;

  7. //提供加载配置商品接口 入参:需要加载的商品(格式:商品1|商品2|...)  返回:成功失败
  8. //function SendYBShopConfig(const NeedLoadGoodsNames: string): Boolean;

  9. //提供记录日志和记录销售排行接口 入参:商品名称 商品编号(查日志用) 商品数量 总价  返回:写入数据库的Idx, > 0为成功, <= 0为失败
  10. //function AddToBuyGoodsLogByScript(const GoodsName: string; const GoodsIdx, GoodsWantNum, TotalPrice: Integer): Integer;

  11. //设置配置信息刷新时间,更新此设置需重新加载脚本 入参:时间格式HH:MM:SS
  12. //procedure SetYBShopRefreshTime(const str: string);

  13. function IsUsingGoodsName(const GoodsName: string): Boolean;
  14. var
  15.   Str, TempStr: string;
  16. begin
  17.   Result := False;
  18.   Str := UsingGoodsName;
  19.   while Str <> '' do
  20.   begin
  21.     Str := GetValidStr(Str, TempStr, '|');
  22.     if TempStr = GoodsName then
  23.     begin
  24.       Result := True;
  25.       Exit;
  26.     end;
  27.   end;
  28. end;

  29. function GetJBGoodsName(Gid:integer):string;
  30. begin
  31.         case Gid of               //需要金币购买的商品名字
  32.         1 : result := '随机传送石';
  33.         2 : result := '修复神水';
  34.         3 : result := '千里传音';
  35.         end;
  36. end;

  37. function GetYBShopConfig(GoodsName: string; out vClassName: string; out vItemList: string; out vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount: Word): string;
  38. var
  39.   vEffectImg: Integer;     //传递给客户端显示属性
  40.   vEffectCount: Word;   //传递给客户端显示属性
  41.   vGoodsExplain: string;   //传递给客户端显示属性
  42. begin
  43.   //返回值提供给程序加载 因为程序无法通过var修改参数
  44.   //var提供脚本直接使用
  45.   //vClassCode需按序
  46.   vClassName := '';
  47.   vItemList := '';
  48.   vGoodsIdx := 0;
  49.   vSrcPrice := 0;
  50.   vCurPrice := 0;
  51.   vEffectImg := 0;
  52.   vEffectCount := 0;
  53.   vGoodsExplain := '';
  54.   vLimitType := 0;    //0不限购 1每日限购 2终身限购
  55.   vLimitCount := 0;

  56.   case GoodsName of
  57.         '金条':
  58.         begin
  59.           vClassName := '强化';
  60.           vItemList := '金条:1';
  61.           vGoodsIdx := 390;
  62.           vSrcPrice := 5; //原价  
  63.           vCurPrice := 5; //折扣价  
  64.           vLimitType := 0; //限购类型  
  65.           vLimitCount := 0; //限购数量  
  66.           vEffectImg := 380;
  67.           vEffectCount := 2;
  68.           vGoodsExplain := '价值100万金币|双击即可使用|每次扣除2000金币手续费';
  69.         end;
  70.         '珠宝箱':
  71.         begin
  72.           vClassName := '强化';
  73.           vItemList := '珠宝箱:1';
  74.           vGoodsIdx := 390;
  75.           vSrcPrice := 100; //原价  
  76.           vCurPrice := 100; //折扣价  
  77.           vLimitType := 0; //限购类型  
  78.           vLimitCount := 0; //限购数量  
  79.           vEffectImg := 380;
  80.           vEffectCount := 2;
  81.           vGoodsExplain := '价值2500万金币|双击即可使用';
  82.         end;
  83.         '随机传送石':
  84.         begin
  85.           vClassName := '强化';
  86.           vItemList := '随机传送石:1';
  87.           vGoodsIdx := 247;
  88.           vSrcPrice := 20; //原价  
  89.           vCurPrice := 20; //折扣价  
  90.           vLimitType := 0; //限购类型  
  91.           vLimitCount := 0; //限购数量  
  92.           vEffectImg := 380;
  93.           vEffectCount := 2;
  94.           vGoodsExplain := '随机传送|双击即可在当前地图内|随机传送|让您随意穿梭于玛法大陆|可使用50次,非绑定物品';
  95.         end;
  96.         '修复神水':
  97.         begin
  98.           vClassName := '强化';
  99.           vItemList := '修复神水:1';
  100.           vGoodsIdx := 248;
  101.           vSrcPrice := 5; //原价  
  102.           vCurPrice := 5; //折扣价  
  103.           vLimitType := 0; //限购类型  
  104.           vLimitCount := 0; //限购数量  
  105.           vEffectImg := 380;
  106.           vEffectCount := 2;
  107.           vGoodsExplain := '修复全部装备|放于包裹中|双击即可特修所有|已穿戴装备|可累计修复100点持久|非绑定物品';
  108.         end;
  109.         '千里传音':
  110.         begin
  111.           vClassName := '限量';
  112.           vItemList := '千里传音:1';
  113.           vGoodsIdx := 208;
  114.           vSrcPrice := 50; //原价  
  115.           vCurPrice := 50; //折扣价  
  116.           vLimitType := 0; //限购类型  
  117.           vLimitCount := 0; //限购数量  
  118.           vEffectImg := 429;
  119.           vEffectCount :=5;
  120.           vGoodsExplain := '向全服喊话|装备于角色栏中|使用 @传 命令|向所有玩家发布紫色公告|购买后与角色绑定|可使用10次';
  121.         end;
  122.         '千里传音(大)':
  123.         begin
  124.           vClassName := '限量';
  125.           vItemList := '千里传音(大):1';
  126.           vGoodsIdx := 225;
  127.           vSrcPrice := 100; //原价  
  128.           vCurPrice := 100; //折扣价  
  129.           vLimitType := 0; //限购类型  
  130.           vLimitCount := 0; //限购数量  
  131.           vEffectImg := 429;
  132.           vEffectCount := 5;
  133.           vGoodsExplain := '向全服喊话|装备于角色栏中|使用 @传 命令|向所有玩家发布紫色公告|购买后与角色绑定|可使用20次';
  134.         end;
  135.         '1元宝':
  136.         begin
  137.           vClassName := '强化';
  138.           vItemList := '1元宝:1';
  139.           vGoodsIdx := 403;
  140.           vSrcPrice := 1; //原价  
  141.           vCurPrice := 1; //折扣价  
  142.           vLimitType := 0; //限购类型  
  143.           vLimitCount := 0; //限购数量  
  144.           vEffectImg := 380;
  145.           vEffectCount := 1;
  146.           vGoodsExplain := '双击使用|获得等额元宝';
  147.         end;
  148.         '5元宝':
  149.         begin
  150.           vClassName := '强化';
  151.           vItemList := '5元宝:1';
  152.           vGoodsIdx := 403;
  153.           vSrcPrice := 5; //原价  
  154.           vCurPrice := 5; //折扣价  
  155.           vLimitType := 0; //限购类型  
  156.           vLimitCount := 0; //限购数量  
  157.           vEffectImg := 380;
  158.           vEffectCount := 1;
  159.           vGoodsExplain := '双击使用|获得等额元宝';
  160.         end;
  161.         '10元宝':
  162.         begin
  163.           vClassName := '强化';
  164.           vItemList := '10元宝:1';
  165.           vGoodsIdx := 403;
  166.           vSrcPrice := 10; //原价  
  167.           vCurPrice := 10; //折扣价  
  168.           vLimitType := 0; //限购类型  
  169.           vLimitCount := 0; //限购数量  
  170.           vEffectImg := 380;
  171.           vEffectCount := 1;
  172.           vGoodsExplain := '双击使用|获得等额元宝';
  173.         end;
  174.         '50元宝':
  175.         begin
  176.           vClassName := '强化';
  177.           vItemList := '50元宝:1';
  178.           vGoodsIdx := 403;
  179.           vSrcPrice := 50; //原价  
  180.           vCurPrice := 50; //折扣价  
  181.           vLimitType := 0; //限购类型  
  182.           vLimitCount := 0; //限购数量  
  183.           vEffectImg := 380;
  184.           vEffectCount := 1;
  185.           vGoodsExplain := '双击使用|获得等额元宝';
  186.         end;
  187.         '100元宝':
  188.         begin
  189.           vClassName := '强化';
  190.           vItemList := '100元宝:1';
  191.           vGoodsIdx := 403;
  192.           vSrcPrice := 100; //原价  
  193.           vCurPrice := 100; //折扣价  
  194.           vLimitType := 0; //限购类型  
  195.           vLimitCount := 0; //限购数量  
  196.           vEffectImg := 380;
  197.           vEffectCount := 1;
  198.           vGoodsExplain := '双击使用|获得等额元宝';
  199.         end;
  200.   end;

  201.   if (vClassName <> '') and IsUsingGoodsName(GoodsName)  then
  202.     Result := vClassName + '$'
  203.             + vItemList + '$'
  204.             + IntToStr(vGoodsIdx) + '$'
  205.             + IntToStr(vSrcPrice) + '$'
  206.             + IntToStr(vCurPrice) + '$'
  207.             + IntToStr(vLimitType) + '$'
  208.             + IntToStr(vLimitCount) + '$'
  209.             + IntToStr(vEffectImg) + '$'
  210.             + IntToStr(vEffectCount) + '$'
  211.             + vGoodsExplain
  212.   else
  213.     Result := '';
  214. end;

  215. function GetLimitValue(const GoodsName: string): Integer;
  216. begin
  217.   //客户端需要通过该方法取得当前限购次数,不要去掉
  218.   Result := 0;
  219.   case GoodsName of
  220.        //   '金条': Result := This_Player.GetV(89, 1);
  221.    // '随机传送石': Result := This_Player.GetV(91, 1);
  222.         '王者之剑': Result := This_Player.GetV(91, 2);
  223.   end;
  224. end;

  225. procedure SetLimitValue(const GoodsName: string; const Value: Integer);
  226. begin
  227.   //暂定91为每日清空
  228.   case GoodsName of
  229.    //       '金条': This_Player.SetV(89, 1, Value);
  230.    // '随机传送石': This_Player.SetV(91, 1, Value);
  231.       '王者之剑': This_Player.SetV(91, 2, Value);
  232.   end;
  233. end;

  234. procedure EverydayClearLimitValue;
  235. var
  236.   I: Integer;
  237. begin
  238.   for I := 1 to 50 do
  239.   begin
  240.     This_Player.SetV(91, I, 0);
  241.    
  242.     if This_Player.GetV(89, I) < 0 then
  243.     This_Player.SetV(89, I, 0);
  244.   end;
  245. end;

  246. procedure ClientBuy(const GoodsName: string; const WantNum, NeedNum: Integer; const IsUseGloryPoint: Boolean);
  247. var
  248.   vClassName: string;
  249.   vItemList: string;
  250.   vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount: Word;
  251.   Price,i: Integer;
  252.   CurLimitValue: Integer;
  253.   Codes:Boolean;
  254. begin
  255.   //if This_Player.GetS(80, 40) <> GetDateNum(GetNow) then
  256.   //begin
  257.     //EverydayClearLimitValue;
  258.     //This_Player.SetS(80, 40, GetDateNum(GetNow));
  259.   //end;

  260.   if This_Player.FreeBagNum >= NeedNum then
  261.   begin
  262.     if GetYBShopConfig(GoodsName, vClassName, vItemList, vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount) <> '' then
  263.     begin
  264.       if (WantNum > 0) and (WantNum < 1000) then
  265.       begin
  266.         CurLimitValue := GetLimitValue(GoodsName);

  267.         if not ((vLimitType > 0) and (CurLimitValue + WantNum > vLimitCount)) then   //限购类型判断
  268.         begin
  269.           Price := WantNum * vCurPrice;   //总价
  270.           Codes := False;
  271.           for i:= 1 to 30 do
  272.           begin
  273.                if GoodsName = GetJBGoodsName(i) then
  274.                begin
  275.                Codes := True;
  276.                break;
  277.                            end;
  278.           end;
  279.           if Codes = True then
  280.           begin
  281.              if This_Player.GoldNum >= Price then
  282.              begin
  283.                 This_Player.DecGold(Price);
  284.                 This_Player.Give(GoodsName,1);exit;
  285.              end
  286.              else
  287.                 This_Player.PlayerDialog('身上没有足够的金币。');exit;
  288.              end;
  289.                          
  290.           if This_Player.YBNum >= Price then
  291.           begin
  292.             if This_Player.AddToBuyGoodsLogByScript(GoodsName, vGoodsIdx, WantNum, Price) > 0 then
  293.             begin
  294.               if This_Player.PsYBConsumEx(2, 'YBShopBuy_YB', GoodsName, vGoodsIdx, vCurPrice, WantNum) then
  295.               begin
  296.                 //提交扣费成功
  297.                 if vLimitType > 0 then
  298.                 begin
  299.                   SetLimitValue(GoodsName, CurLimitValue + WantNum);
  300.                 end;
  301.               end
  302.               else
  303.                 This_Player.PlayerDialog('申请扣元宝失败!');
  304.             end
  305.             else
  306.               This_Player.PlayerDialog('系统繁忙,操作失败。');
  307.           end
  308.           else
  309.             This_Player.PlayerDialog('身上没有足够的元宝。');
  310.         end
  311.         else
  312.           This_Player.PlayerDialog('已达到限购数上限。');
  313.       end
  314.       else
  315.         This_Player.PlayerDialog('购买数量不合法。');
  316.     end
  317.     else
  318.       This_Player.PlayerDialog('商城未出售此物品。');
  319.   end
  320.   else
  321.     This_Player.PlayerDialog('您身上没有足够的空间。');
  322. end;

  323. function YBShopBuy_YB(const DescName: string; const Price, Num: Integer): Boolean;
  324. //procedure DecLF(const DescName: string; const Price, Num: Integer): Boolean;
  325. var
  326.   vClassName,T_name : string;
  327.   vItemList: string;
  328.   vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount: Word;
  329.   Str, TempStr, SubTempStr: string;
  330. begin
  331.   Result := False;
  332.   if GetYBShopConfig(DescName, vClassName, vItemList, vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount) <> '' then
  333.   begin
  334.     if This_Player.FreeBagNum > 0 then
  335.     begin
  336.       Str := vItemList;
  337.       while Str <> '' do
  338.       begin
  339.         Str := GetValidStr(Str, TempStr, '/');
  340.         if TempStr <> '' then
  341.         begin
  342.           TempStr := GetValidStr(TempStr, SubTempStr, ':');

  343.           //SubTempStr 物品名
  344.           //TempStr 物品数量
  345.           if copy(SubTempStr,length(SubTempStr) - 3 , length(SubTempStr)) = '(绑)' then
  346.           This_Player.GiveBindItem(SubTempStr, StrToIntDef(TempStr, 0))
  347.           else
  348.           This_Player.Give(SubTempStr, StrToIntDef(TempStr, 0));

  349.           This_Player.AddLogRec(51, SubTempStr, 333333, StrToIntDef(TempStr, 0), '商城购入' + DescName);
  350.         end;
  351.       end;

  352.       Result := True;
  353.     end
  354.     else
  355.       This_Player.PlayerDialog('您身上没有空间,请联系GM补领物品。');
  356.   end
  357.   else
  358.     This_Player.PlayerDialog('商品被下架,获取物品失败,请联系管理员补领物品。');
  359. end;

  360. procedure Execute;
  361. var
  362.   nowDay: Integer;
  363. begin
  364.   nowDay := StrToIntDef(MirDateTimeToStr('yyyyMMdd' , GetNow), -1);

  365.   if (nowDay >= 20160802) and (nowDay <= 20160927) then
  366.     UsingGoodsName := C_NeedLoadGoodsNames_001
  367.   else
  368.     UsingGoodsName := C_NeedLoadGoodsNames_002;

  369.   if not SendYBShopConfig(UsingGoodsName) then
  370.     DebugOut('[Error]YBShopScript加载' + UsingGoodsName + '失败!');
  371. end;

  372. procedure Initialize;
  373. begin
  374.   UsingGoodsName := C_NeedLoadGoodsNames_001;     //脚本加载的初始值

  375.   SetYBShopRefreshTime('00:00:00');
  376.   SetYBShopRefreshTime('06:00:00');
  377.   SetYBShopRefreshTime('12:00:00');

  378.   Execute;
  379. end;

  380. Begin
  381. end.
复制代码








上一篇:战神引擎商城明文传奇源代码mir2.scenes.main.panel.shop
下一篇:传奇3火鸟插件客户端Ai源码文件MagicEx.xml
回复

使用道具 举报

3

主题

44

回帖

40

积分

旋风流星刀

积分
40
发表于 2023-12-8 14:42:30 | 显示全部楼层
不错啊,看看了!!!!
回复 支持 反对

使用道具 举报

3

主题

44

回帖

40

积分

旋风流星刀

积分
40
发表于 2023-12-11 16:08:45 | 显示全部楼层
很牛批很厉害!!!
回复 支持 反对

使用道具 举报

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

本版积分规则

手机版|美林GM论坛 ( 蜀ICP备2020030293号-2 )|网站地图

禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.如遇版权问题,请及时QQ联系

GMT+8, 2024-4-28 02:01 , Processed in 0.301955 second(s), 57 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024, Tencent Cloud.

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