99Max综合娱乐网站(旧版)

 找回密码
 立即注册
查看: 2121|回复: 7

[教程] 自定义商城点数变量商店系统[第一期]

  [复制链接]

升级   100%

发表于 2013-6-17 11:37:04 | 显示全部楼层 |阅读模式
此系统目的在于,除了普通的现金商店以外,可以自定义其他变量的商店系统,比如说在线积分等等,方便编写积分购物等脚本

第一步:
  1.         npc.h
  2.         struct npc_data {
复制代码
原:

  1.                 struct {
  2.                         struct npc_item_list* shop_item;
  3.                         int count;
  4.                 } shop;
  5.         
复制代码
改:

  1.                 struct {
  2.                         struct npc_item_list* shop_item;
  3.                         int count;
  4.                         char *cash_var, *point_var; //变量名称
  5.                         short cash_vartype, point_vartype; //1 = 全局帐号变量, 2 = 帐号变量, 3 = 人物变量
  6.                         int itemid;
  7.                 } shop;
  8.         
复制代码
第二步:

  1.         npc.c
  2.         npc_cashshop_buylist
  3.         
复制代码
原:

  1.                 // Payment Process ----------------------------------------------------
  2.                 if( sd->kafraPoints < points || sd->cashPoints < (vt - points) )
  3.                         return 6;
  4.                 pc_paycash(sd,vt,points);
复制代码
改:

  1.                 // Payment Process
  2.                 if( (pc_readregistry(sd,nd->u.shop.point_var,nd->u.shop.point_vartype)  < points) || (pc_readregistry(sd,nd->u.shop.cash_var,nd->u.shop.cash_vartype) < vt - points) )
  3.                         return 6;
  4.                 if (!strcasecmp(nd->u.shop.cash_var,"#CASHPOINTS") && !strcasecmp(nd->u.shop.point_var,"#KAFRAPOINTS"))
  5.                         pc_paycash(sd, vt, points);
  6.                 else{
  7.                         pc_setregistry(sd,nd->u.shop.cash_var,pc_readregistry(sd,nd->u.shop.cash_var,nd->u.shop.cash_vartype) - (vt - points),nd->u.shop.cash_vartype);
  8.                         pc_setregistry(sd,nd->u.shop.point_var,pc_readregistry(sd,nd->u.shop.point_var,nd->u.shop.point_vartype) - points,nd->u.shop.point_vartype);
  9.                 }
  10.         
复制代码
第三步:

  1.         npc.c
  2.         npc_cashshop_buy
  3.         
复制代码
原:

  1.                 if( (sd->kafraPoints < points) || (sd->cashPoints < price - points) )
  2.                         return 6;
  3.                
  4.                 pc_paycash(sd, price, points);
复制代码
改:

  1.                 if( (pc_readregistry(sd,nd->u.shop.point_var,nd->u.shop.point_vartype)  < points) || (pc_readregistry(sd,nd->u.shop.cash_var,nd->u.shop.cash_vartype) < price - points) )
  2.                         return 6;

  3.                 if (!strcasecmp(nd->u.shop.cash_var,"#CASHPOINTS") && !strcasecmp(nd->u.shop.point_var,"#KAFRAPOINTS"))
  4.                         pc_paycash(sd, price, points);
  5.                 else{
  6.                         pc_setregistry(sd,nd->u.shop.cash_var,pc_readregistry(sd,nd->u.shop.cash_var,nd->u.shop.cash_vartype) - (price - points),nd->u.shop.cash_vartype);
  7.                         pc_setregistry(sd,nd->u.shop.point_var,pc_readregistry(sd,nd->u.shop.point_var,nd->u.shop.point_vartype) - points,nd->u.shop.point_vartype);
  8.                 }
复制代码
第四步:
  1.         npc.c
  2.         int npc_unload(struct npc_data* nd, bool single) {
复制代码
原:
  1.                 if( (nd->subtype == SHOP || nd->subtype == CASHSHOP) && nd->src_id == 0) //src check for duplicate shops [Orcao]
  2.                         aFree(nd->u.shop.shop_item);
  3.                         
复制代码
改:
  1.                 if( (nd->subtype == SHOP || nd->subtype == CASHSHOP) && nd->src_id == 0){ //src check for duplicate shops [Orcao]
  2.                         aFree(nd->u.shop.shop_item);
  3.                         aFree(nd->u.shop.cash_var);
  4.                         aFree(nd->u.shop.point_var);
  5.                 }
复制代码
温馨提示:
1. 本站模拟器源于网络,经 99Max.mE 二次开发,仅供个人学习娱乐使用,切勿用于商业用途,否则后果自负!
2. 如需更好体验游戏内容,请前往官方游戏!不具备合法的运营模式,都是强盗,请勿擅自搭建私服!
3. 如本站内容有侵犯您的权益,请发送信息至QQ:372607220 或 EMAIL:372607220@qq.com ,我们会及时删除。

升级   69.33%

发表于 2013-6-17 19:07:44 | 显示全部楼层
您开源的那份源码里有这些吧

升级   100%

 楼主| 发表于 2013-6-18 08:52:33 | 显示全部楼层
对的,有这些

升级   25.8%

发表于 2015-12-22 13:42:22 | 显示全部楼层
自定义商城点数变量商店系统

升级   28%

发表于 2016-4-3 23:00:36 | 显示全部楼层
没头没尾,菜鸟表示看不懂

升级   3.33%

发表于 2016-6-17 13:26:24 | 显示全部楼层
表示不知在哪里修改

升级   79.33%

群组: JRO日本客户端

发表于 2019-3-18 14:16:48 | 显示全部楼层
也是云里雾里!

升级   0%

群组: JRO日本客户端

发表于 2020-6-21 06:34:30 | 显示全部楼层
前来学习经验。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|99Max综合娱乐网站(旧版) ( 沪ICP备11024206号-1 )

GMT+8, 2024-5-2 08:31 , Processed in 0.084350 second(s), 25 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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