搜索
查看: 3670|回复: 7

[AMXX 带源码] 我的第一个插件(奖励和惩罚,有点无聊),大家来测测

[复制链接]
发表于 2009-1-18 20:10:36 | 显示全部楼层 |阅读模式 来自 中国–浙江–温州–平阳县
本帖最后由 mwy5ym 于 2009-1-20 18:38 编辑

插件名字是RewardAndPunish,简称rap。
参考了国外网站上的一个插件UMR,但是我的和他的可是大不一样的哦。大家来测试下。

插件描述:
插件效果 发生在一次kill之后。
根据kill的类型(普通no/爆头hs/刀杀kn/炸死he),对 杀手 和 牺牲者 进行 奖励 和 惩罚
奖励包括 加护甲armor,加生命health,加钱money; 惩罚包括扣钱money;
奖励 和 惩罚 效果可以叠加。比如爆头就包括 普通杀 + 爆头的结果,用刀或手雷爆头就是3者的叠加了。

大致就是这样,大家来测试下吧

Cvars :
rap_view :浏览插件设置
rap_enable <1/0> : 插件开关
rap_set armor  max <100~200> : 每个人的最大护甲值
rap_set health max <100~200> : 每个人的最大生命值
xx表示(no:normal killing/hs:headshot killing/kn:knife killing/he:hegrenade killing)
rap_set armor xx <0~200> : 杀手在xx下杀敌得到的护甲
rap_set health xx <0~200> : 杀手在xx下杀敌得到的生命
rap_set reward xx <0~16000> : 杀手在xx下杀敌得到的钱
rap_set punish xx <0~16000> : 牺牲者在被xx杀死后失去的钱
<name> <default>
rap_view
rap_enable 1
rap_set armor max 200
rap_set health max 200
rap_set armor no 0
rap_set health no 0
rap_set punish no 0
rap_set reward no 0
rap_set armor hs 10
rap_set health hs 10
rap_set punish hs 0
rap_set reward hs 0
rap_set armor kn 10
rap_set health kn 10
rap_set punish kn 300
rap_set reward kn 0
rap_set armor he 10
rap_set health he 10
rap_set punish he 300
rap_set reward he 0

  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <fun>

  5. #define PLUGIN "Reward And Punish"
  6. #define VERSION "1.0"
  7. #define AUTHOR "mwy5ym"

  8. new
  9. active_flag,max_armor,max_health,
  10. no_armor,no_health,no_punish,no_reward,
  11. hs_armor,hs_health,hs_punish,hs_reward,
  12. kn_armor,kn_health,kn_punish,kn_reward,
  13. he_armor,he_health,he_punish,he_reward;

  14. public plugin_init()
  15. {
  16. register_plugin(PLUGIN, VERSION, AUTHOR);
  17. register_event("DeathMsg","Action","a");
  18. register_concmd("rap_set","SetRAP", ADMIN_LEVEL_A,"<flag> <flag> <n>");
  19. register_concmd("rap_view","ViewRAP", ADMIN_LEVEL_A,"- View The RAP Set");
  20. active_flag = register_cvar("rap_enable","1");

  21. max_armor=200; max_health=200;
  22. no_armor=0; no_health=0; no_punish=0; no_reward=0;
  23. hs_armor=10; hs_health=10; hs_punish=0; hs_reward=0;
  24. kn_armor=10; kn_health=10; kn_punish=300; kn_reward=0;
  25. he_armor=10; he_health=10; he_punish=300; he_reward=0;
  26. }
  27. public Action()
  28. {
  29. if(!get_pcvar_num(active_flag))
  30. return PLUGIN_HANDLED;
  31. new killer = read_data(1);
  32. new victim = read_data(2);
  33. new weapon[24];
  34. if( (killer == victim) || (get_user_team(killer)==get_user_team(victim)) )
  35. return PLUGIN_HANDLED;
  36. read_data(4,weapon,23);

  37. karmor(killer,no_armor);
  38. khealth(killer,no_health);
  39. kmoney(killer,no_reward);
  40. vmoney(victim,no_punish);
  41. if(read_data(3))
  42. {
  43. karmor(killer,hs_armor);
  44. khealth(killer,hs_health);
  45. kmoney(killer,hs_reward);
  46. vmoney(victim,hs_punish);
  47. }
  48. if(weapon[0] == 'k')
  49. {
  50. karmor(killer,kn_armor);
  51. khealth(killer,kn_health);
  52. kmoney(killer,kn_reward);
  53. vmoney(victim,kn_punish);
  54. }
  55. if(weapon[1] == 'r')
  56. {
  57. karmor(killer,he_armor);
  58. khealth(killer,he_health);
  59. kmoney(killer,he_reward);
  60. vmoney(victim,he_punish);
  61. }
  62. return PLUGIN_HANDLED;
  63. }
  64. public ViewRAP(id, level, cid)
  65. {
  66. if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED;
  67. console_print(id, " normal headshot knife hegrenade themax");
  68. console_print(id, "armor %5d %5d %5d %5d %5d",no_armor,hs_armor,kn_armor,he_armor,max_armor);
  69. console_print(id, "health %5d %5d %5d %5d %5d",no_health,hs_health,kn_health,he_health,max_health);
  70. console_print(id, "punish %5d %5d %5d %5d",no_punish,hs_punish,kn_punish,he_punish);
  71. console_print(id, "reward %5d %5d %5d %5d",no_reward,hs_reward,kn_reward,he_reward);
  72. return PLUGIN_HANDLED;
  73. }
  74. public SetRAP(id, level, cid)
  75. {
  76. if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED;
  77. new ItemFlag[7],KillFlag[4],TheDigit[7],number;
  78. read_argv(1,ItemFlag,6);
  79. read_argv(2,KillFlag,3);
  80. read_argv(3,TheDigit,6);
  81. number=str_to_num(TheDigit);

  82. if(ItemFlag[0]=='a'||ItemFlag[0]=='h')
  83. {
  84. if(number<0)number=0;
  85. if(number>200)number=200;
  86. if(KillFlag[0]=='m' && number<100)number=100;
  87. }else
  88. {
  89. if(number<0)number=0;
  90. if(number>16000)number=16000;
  91. }

  92. switch(ItemFlag[0])
  93. {
  94. case 'a':
  95. {
  96. if(KillFlag[0]=='m')max_armor=number;
  97. if(KillFlag[0]=='n'&&KillFlag[1]=='o')no_armor=number;
  98. if(KillFlag[0]=='h'&&KillFlag[1]=='s')hs_armor=number;
  99. if(KillFlag[0]=='k'&&KillFlag[1]=='n')kn_armor=number;
  100. if(KillFlag[0]=='h'&&KillFlag[1]=='e')he_armor=number;
  101. }
  102. case 'h':
  103. {
  104. if(KillFlag[0]=='m')max_health=number;
  105. if(KillFlag[0]=='n'&&KillFlag[1]=='o')no_health=number;
  106. if(KillFlag[0]=='h'&&KillFlag[1]=='s')hs_health=number;
  107. if(KillFlag[0]=='k'&&KillFlag[1]=='n')kn_health=number;
  108. if(KillFlag[0]=='h'&&KillFlag[1]=='e')he_health=number;
  109. }
  110. case 'p':
  111. {
  112. if(KillFlag[0]=='n'&&KillFlag[1]=='o')no_punish=number;
  113. if(KillFlag[0]=='h'&&KillFlag[1]=='s')hs_punish=number;
  114. if(KillFlag[0]=='k'&&KillFlag[1]=='n')kn_punish=number;
  115. if(KillFlag[0]=='h'&&KillFlag[1]=='e')he_punish=number;
  116. }
  117. case 'r':
  118. {
  119. if(KillFlag[0]=='n'&&KillFlag[1]=='o')no_reward=number;
  120. if(KillFlag[0]=='h'&&KillFlag[1]=='s')hs_reward=number;
  121. if(KillFlag[0]=='k'&&KillFlag[1]=='n')kn_reward=number;
  122. if(KillFlag[0]=='h'&&KillFlag[1]=='e')he_reward=number;
  123. }
  124. }
  125. return PLUGIN_HANDLED
  126. }
  127. karmor(index,howmuch)
  128. {
  129. set_user_armor(index,get_user_armor(index) + howmuch);
  130. if(get_user_armor(index)>max_armor)
  131. set_user_armor(index,max_armor);
  132. }
  133. khealth(index,howmuch)
  134. {
  135. set_user_health(index,get_user_health(index) + howmuch);
  136. if(get_user_health(index)>max_health)
  137. set_user_health(index,max_health);
  138. }
  139. kmoney(index,howmuch)
  140. {
  141. cs_set_user_money(index,cs_get_user_money(index) + howmuch);
  142. }
  143. vmoney(index,howmuch)
  144. {
  145. cs_set_user_money(index,cs_get_user_money(index) - howmuch);
  146. if(cs_get_user_money(index)<0)cs_set_user_money(index,0);
  147. }
复制代码
发表于 2009-1-18 20:26:12 | 显示全部楼层 来自 中国–广东–惠州
编译通过,测试成功,但时间还得测试长点才行。
回复

使用道具 举报

发表于 2009-1-18 20:44:47 | 显示全部楼层 来自 中国–广东–河源
对普通服来讲还是比较高的娱乐性的,收藏!
回复

使用道具 举报

发表于 2009-1-19 01:39:03 | 显示全部楼层 来自 中国–广西–防城港
希望用过朋友发下感受
回复

使用道具 举报

发表于 2009-1-19 02:59:28 | 显示全部楼层 来自 中国–广西–南宁
这个怎么保存啊?用什么格式存啊?
回复

使用道具 举报

 楼主| 发表于 2009-1-19 10:51:48 | 显示全部楼层 来自 中国–浙江–温州–平阳县
本帖最后由 mwy5ym 于 2009-1-19 10:58 编辑
这个怎么保存啊?用什么格式存啊?
yang586 发表于 2009-1-19 02:59

普通格式应该可以吧,不行就保存为UTF-8
复制后放到记事本里,另存为RewardAndPunish.sma(注意扩展名)
放到amxmodx\scripting\下面,双击该目录下的compile.exe
会生成1个compiled文件夹,里面有个RewardAndPunish.amxx
把这个RewardAndPunish.amxx放到amxmodx\plugins\下面
打开amxmodx\configs\下面的plugins.ini,
在其最下面添加一行
RewardAndPunish.amxx        ; Reward And Punish 奖励和处罚
保存.

我在AMXMODX 1.8.1里测试可以编译成功

点评

实在太感谢了,下了好多源码不知道转的 现在终于找到了  发表于 2012-8-3 23:53
回复

使用道具 举报

发表于 2009-1-19 11:22:45 | 显示全部楼层 来自 中国–广东–韶关
这样子  贫富差距更大
回复

使用道具 举报

发表于 2012-8-7 20:09:04 | 显示全部楼层 来自 中国–云南–玉溪
编译通过,测试成功,但时间还得测试长点才行。
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

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