|
战神引擎传奇元宝商城改金币购物_YBShopScript.pas
下拉到最底部 复制代码粘贴到 _YBShopScript.pas即可使用
- PROGRAM Mir2;
- const // 赤金钥匙|白银钥匙|紫铜钥匙|神秘钥匙|传音筒|
- C_NeedLoadGoodsNames_001 = '随机传送石|修复神水|千里传音|千里传音(大)|1元宝|5元宝|10元宝|50元宝|100元宝|金条|珠宝箱';
- C_NeedLoadGoodsNames_002 = '随机传送石|修复神水|千里传音|千里传音(大)|1元宝|5元宝|10元宝|50元宝|100元宝|金条|珠宝箱';
- var
- UsingGoodsName: string;
- //提供加载配置商品接口 入参:需要加载的商品(格式:商品1|商品2|...) 返回:成功失败
- //function SendYBShopConfig(const NeedLoadGoodsNames: string): Boolean;
- //提供记录日志和记录销售排行接口 入参:商品名称 商品编号(查日志用) 商品数量 总价 返回:写入数据库的Idx, > 0为成功, <= 0为失败
- //function AddToBuyGoodsLogByScript(const GoodsName: string; const GoodsIdx, GoodsWantNum, TotalPrice: Integer): Integer;
- //设置配置信息刷新时间,更新此设置需重新加载脚本 入参:时间格式HH:MM:SS
- //procedure SetYBShopRefreshTime(const str: string);
- function IsUsingGoodsName(const GoodsName: string): Boolean;
- var
- Str, TempStr: string;
- begin
- Result := False;
- Str := UsingGoodsName;
- while Str <> '' do
- begin
- Str := GetValidStr(Str, TempStr, '|');
- if TempStr = GoodsName then
- begin
- Result := True;
- Exit;
- end;
- end;
- end;
- function GetJBGoodsName(Gid:integer):string;
- begin
- case Gid of //需要金币购买的商品名字
- 1 : result := '随机传送石';
- 2 : result := '修复神水';
- 3 : result := '千里传音';
- end;
- end;
- function GetYBShopConfig(GoodsName: string; out vClassName: string; out vItemList: string; out vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount: Word): string;
- var
- vEffectImg: Integer; //传递给客户端显示属性
- vEffectCount: Word; //传递给客户端显示属性
- vGoodsExplain: string; //传递给客户端显示属性
- begin
- //返回值提供给程序加载 因为程序无法通过var修改参数
- //var提供脚本直接使用
- //vClassCode需按序
- vClassName := '';
- vItemList := '';
- vGoodsIdx := 0;
- vSrcPrice := 0;
- vCurPrice := 0;
- vEffectImg := 0;
- vEffectCount := 0;
- vGoodsExplain := '';
- vLimitType := 0; //0不限购 1每日限购 2终身限购
- vLimitCount := 0;
- case GoodsName of
- '金条':
- begin
- vClassName := '强化';
- vItemList := '金条:1';
- vGoodsIdx := 390;
- vSrcPrice := 5; //原价
- vCurPrice := 5; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 2;
- vGoodsExplain := '价值100万金币|双击即可使用|每次扣除2000金币手续费';
- end;
- '珠宝箱':
- begin
- vClassName := '强化';
- vItemList := '珠宝箱:1';
- vGoodsIdx := 390;
- vSrcPrice := 100; //原价
- vCurPrice := 100; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 2;
- vGoodsExplain := '价值2500万金币|双击即可使用';
- end;
- '随机传送石':
- begin
- vClassName := '强化';
- vItemList := '随机传送石:1';
- vGoodsIdx := 247;
- vSrcPrice := 20; //原价
- vCurPrice := 20; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 2;
- vGoodsExplain := '随机传送|双击即可在当前地图内|随机传送|让您随意穿梭于玛法大陆|可使用50次,非绑定物品';
- end;
- '修复神水':
- begin
- vClassName := '强化';
- vItemList := '修复神水:1';
- vGoodsIdx := 248;
- vSrcPrice := 5; //原价
- vCurPrice := 5; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 2;
- vGoodsExplain := '修复全部装备|放于包裹中|双击即可特修所有|已穿戴装备|可累计修复100点持久|非绑定物品';
- end;
- '千里传音':
- begin
- vClassName := '限量';
- vItemList := '千里传音:1';
- vGoodsIdx := 208;
- vSrcPrice := 50; //原价
- vCurPrice := 50; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 429;
- vEffectCount :=5;
- vGoodsExplain := '向全服喊话|装备于角色栏中|使用 @传 命令|向所有玩家发布紫色公告|购买后与角色绑定|可使用10次';
- end;
- '千里传音(大)':
- begin
- vClassName := '限量';
- vItemList := '千里传音(大):1';
- vGoodsIdx := 225;
- vSrcPrice := 100; //原价
- vCurPrice := 100; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 429;
- vEffectCount := 5;
- vGoodsExplain := '向全服喊话|装备于角色栏中|使用 @传 命令|向所有玩家发布紫色公告|购买后与角色绑定|可使用20次';
- end;
- '1元宝':
- begin
- vClassName := '强化';
- vItemList := '1元宝:1';
- vGoodsIdx := 403;
- vSrcPrice := 1; //原价
- vCurPrice := 1; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 1;
- vGoodsExplain := '双击使用|获得等额元宝';
- end;
- '5元宝':
- begin
- vClassName := '强化';
- vItemList := '5元宝:1';
- vGoodsIdx := 403;
- vSrcPrice := 5; //原价
- vCurPrice := 5; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 1;
- vGoodsExplain := '双击使用|获得等额元宝';
- end;
- '10元宝':
- begin
- vClassName := '强化';
- vItemList := '10元宝:1';
- vGoodsIdx := 403;
- vSrcPrice := 10; //原价
- vCurPrice := 10; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 1;
- vGoodsExplain := '双击使用|获得等额元宝';
- end;
- '50元宝':
- begin
- vClassName := '强化';
- vItemList := '50元宝:1';
- vGoodsIdx := 403;
- vSrcPrice := 50; //原价
- vCurPrice := 50; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 1;
- vGoodsExplain := '双击使用|获得等额元宝';
- end;
- '100元宝':
- begin
- vClassName := '强化';
- vItemList := '100元宝:1';
- vGoodsIdx := 403;
- vSrcPrice := 100; //原价
- vCurPrice := 100; //折扣价
- vLimitType := 0; //限购类型
- vLimitCount := 0; //限购数量
- vEffectImg := 380;
- vEffectCount := 1;
- vGoodsExplain := '双击使用|获得等额元宝';
- end;
- end;
- if (vClassName <> '') and IsUsingGoodsName(GoodsName) then
- Result := vClassName + '$'
- + vItemList + '$'
- + IntToStr(vGoodsIdx) + '$'
- + IntToStr(vSrcPrice) + '$'
- + IntToStr(vCurPrice) + '$'
- + IntToStr(vLimitType) + '$'
- + IntToStr(vLimitCount) + '$'
- + IntToStr(vEffectImg) + '$'
- + IntToStr(vEffectCount) + '$'
- + vGoodsExplain
- else
- Result := '';
- end;
- function GetLimitValue(const GoodsName: string): Integer;
- begin
- //客户端需要通过该方法取得当前限购次数,不要去掉
- Result := 0;
- case GoodsName of
- // '金条': Result := This_Player.GetV(89, 1);
- // '随机传送石': Result := This_Player.GetV(91, 1);
- '王者之剑': Result := This_Player.GetV(91, 2);
- end;
- end;
- procedure SetLimitValue(const GoodsName: string; const Value: Integer);
- begin
- //暂定91为每日清空
- case GoodsName of
- // '金条': This_Player.SetV(89, 1, Value);
- // '随机传送石': This_Player.SetV(91, 1, Value);
- '王者之剑': This_Player.SetV(91, 2, Value);
- end;
- end;
- procedure EverydayClearLimitValue;
- var
- I: Integer;
- begin
- for I := 1 to 50 do
- begin
- This_Player.SetV(91, I, 0);
-
- if This_Player.GetV(89, I) < 0 then
- This_Player.SetV(89, I, 0);
- end;
- end;
- procedure ClientBuy(const GoodsName: string; const WantNum, NeedNum: Integer; const IsUseGloryPoint: Boolean);
- var
- vClassName: string;
- vItemList: string;
- vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount: Word;
- Price,i: Integer;
- CurLimitValue: Integer;
- Codes:Boolean;
- begin
- //if This_Player.GetS(80, 40) <> GetDateNum(GetNow) then
- //begin
- //EverydayClearLimitValue;
- //This_Player.SetS(80, 40, GetDateNum(GetNow));
- //end;
- if This_Player.FreeBagNum >= NeedNum then
- begin
- if GetYBShopConfig(GoodsName, vClassName, vItemList, vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount) <> '' then
- begin
- if (WantNum > 0) and (WantNum < 1000) then
- begin
- CurLimitValue := GetLimitValue(GoodsName);
- if not ((vLimitType > 0) and (CurLimitValue + WantNum > vLimitCount)) then //限购类型判断
- begin
- Price := WantNum * vCurPrice; //总价
- Codes := False;
- for i:= 1 to 30 do
- begin
- if GoodsName = GetJBGoodsName(i) then
- begin
- Codes := True;
- break;
- end;
- end;
- if Codes = True then
- begin
- if This_Player.GoldNum >= Price then
- begin
- This_Player.DecGold(Price);
- This_Player.Give(GoodsName,1);exit;
- end
- else
- This_Player.PlayerDialog('身上没有足够的金币。');exit;
- end;
-
- if This_Player.YBNum >= Price then
- begin
- if This_Player.AddToBuyGoodsLogByScript(GoodsName, vGoodsIdx, WantNum, Price) > 0 then
- begin
- if This_Player.PsYBConsumEx(2, 'YBShopBuy_YB', GoodsName, vGoodsIdx, vCurPrice, WantNum) then
- begin
- //提交扣费成功
- if vLimitType > 0 then
- begin
- SetLimitValue(GoodsName, CurLimitValue + WantNum);
- end;
- end
- else
- This_Player.PlayerDialog('申请扣元宝失败!');
- end
- else
- This_Player.PlayerDialog('系统繁忙,操作失败。');
- end
- else
- This_Player.PlayerDialog('身上没有足够的元宝。');
- end
- else
- This_Player.PlayerDialog('已达到限购数上限。');
- end
- else
- This_Player.PlayerDialog('购买数量不合法。');
- end
- else
- This_Player.PlayerDialog('商城未出售此物品。');
- end
- else
- This_Player.PlayerDialog('您身上没有足够的空间。');
- end;
- function YBShopBuy_YB(const DescName: string; const Price, Num: Integer): Boolean;
- //procedure DecLF(const DescName: string; const Price, Num: Integer): Boolean;
- var
- vClassName,T_name : string;
- vItemList: string;
- vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount: Word;
- Str, TempStr, SubTempStr: string;
- begin
- Result := False;
- if GetYBShopConfig(DescName, vClassName, vItemList, vGoodsIdx, vSrcPrice, vCurPrice, vLimitType, vLimitCount) <> '' then
- begin
- if This_Player.FreeBagNum > 0 then
- begin
- Str := vItemList;
- while Str <> '' do
- begin
- Str := GetValidStr(Str, TempStr, '/');
- if TempStr <> '' then
- begin
- TempStr := GetValidStr(TempStr, SubTempStr, ':');
- //SubTempStr 物品名
- //TempStr 物品数量
- if copy(SubTempStr,length(SubTempStr) - 3 , length(SubTempStr)) = '(绑)' then
- This_Player.GiveBindItem(SubTempStr, StrToIntDef(TempStr, 0))
- else
- This_Player.Give(SubTempStr, StrToIntDef(TempStr, 0));
- This_Player.AddLogRec(51, SubTempStr, 333333, StrToIntDef(TempStr, 0), '商城购入' + DescName);
- end;
- end;
- Result := True;
- end
- else
- This_Player.PlayerDialog('您身上没有空间,请联系GM补领物品。');
- end
- else
- This_Player.PlayerDialog('商品被下架,获取物品失败,请联系管理员补领物品。');
- end;
- procedure Execute;
- var
- nowDay: Integer;
- begin
- nowDay := StrToIntDef(MirDateTimeToStr('yyyyMMdd' , GetNow), -1);
- if (nowDay >= 20160802) and (nowDay <= 20160927) then
- UsingGoodsName := C_NeedLoadGoodsNames_001
- else
- UsingGoodsName := C_NeedLoadGoodsNames_002;
- if not SendYBShopConfig(UsingGoodsName) then
- DebugOut('[Error]YBShopScript加载' + UsingGoodsName + '失败!');
- end;
- procedure Initialize;
- begin
- UsingGoodsName := C_NeedLoadGoodsNames_001; //脚本加载的初始值
- SetYBShopRefreshTime('00:00:00');
- SetYBShopRefreshTime('06:00:00');
- SetYBShopRefreshTime('12:00:00');
- Execute;
- end;
- Begin
- end.
复制代码
|
上一篇:战神引擎商城明文传奇源代码mir2.scenes.main.panel.shop下一篇:传奇3火鸟插件客户端Ai源码文件MagicEx.xml
|