mwy5ym 发表于 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 armormax <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
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define PLUGIN "Reward And Punish"
#define VERSION "1.0"
#define AUTHOR "mwy5ym"

new
active_flag,max_armor,max_health,
no_armor,no_health,no_punish,no_reward,
hs_armor,hs_health,hs_punish,hs_reward,
kn_armor,kn_health,kn_punish,kn_reward,
he_armor,he_health,he_punish,he_reward;

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

max_armor=200; max_health=200;
no_armor=0; no_health=0; no_punish=0; no_reward=0;
hs_armor=10; hs_health=10; hs_punish=0; hs_reward=0;
kn_armor=10; kn_health=10; kn_punish=300; kn_reward=0;
he_armor=10; he_health=10; he_punish=300; he_reward=0;
}
public Action()
{
if(!get_pcvar_num(active_flag))
return PLUGIN_HANDLED;
new killer = read_data(1);
new victim = read_data(2);
new weapon;
if( (killer == victim) || (get_user_team(killer)==get_user_team(victim)) )
return PLUGIN_HANDLED;
read_data(4,weapon,23);

karmor(killer,no_armor);
khealth(killer,no_health);
kmoney(killer,no_reward);
vmoney(victim,no_punish);
if(read_data(3))
{
karmor(killer,hs_armor);
khealth(killer,hs_health);
kmoney(killer,hs_reward);
vmoney(victim,hs_punish);
}
if(weapon == 'k')
{
karmor(killer,kn_armor);
khealth(killer,kn_health);
kmoney(killer,kn_reward);
vmoney(victim,kn_punish);
}
if(weapon == 'r')
{
karmor(killer,he_armor);
khealth(killer,he_health);
kmoney(killer,he_reward);
vmoney(victim,he_punish);
}
return PLUGIN_HANDLED;
}
public ViewRAP(id, level, cid)
{
if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED;
console_print(id, " normal headshot knife hegrenade themax");
console_print(id, "armor %5d %5d %5d %5d %5d",no_armor,hs_armor,kn_armor,he_armor,max_armor);
console_print(id, "health %5d %5d %5d %5d %5d",no_health,hs_health,kn_health,he_health,max_health);
console_print(id, "punish %5d %5d %5d %5d",no_punish,hs_punish,kn_punish,he_punish);
console_print(id, "reward %5d %5d %5d %5d",no_reward,hs_reward,kn_reward,he_reward);
return PLUGIN_HANDLED;
}
public SetRAP(id, level, cid)
{
if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED;
new ItemFlag,KillFlag,TheDigit,number;
read_argv(1,ItemFlag,6);
read_argv(2,KillFlag,3);
read_argv(3,TheDigit,6);
number=str_to_num(TheDigit);

if(ItemFlag=='a'||ItemFlag=='h')
{
if(number<0)number=0;
if(number>200)number=200;
if(KillFlag=='m' && number<100)number=100;
}else
{
if(number<0)number=0;
if(number>16000)number=16000;
}

switch(ItemFlag)
{
case 'a':
{
if(KillFlag=='m')max_armor=number;
if(KillFlag=='n'&&KillFlag=='o')no_armor=number;
if(KillFlag=='h'&&KillFlag=='s')hs_armor=number;
if(KillFlag=='k'&&KillFlag=='n')kn_armor=number;
if(KillFlag=='h'&&KillFlag=='e')he_armor=number;
}
case 'h':
{
if(KillFlag=='m')max_health=number;
if(KillFlag=='n'&&KillFlag=='o')no_health=number;
if(KillFlag=='h'&&KillFlag=='s')hs_health=number;
if(KillFlag=='k'&&KillFlag=='n')kn_health=number;
if(KillFlag=='h'&&KillFlag=='e')he_health=number;
}
case 'p':
{
if(KillFlag=='n'&&KillFlag=='o')no_punish=number;
if(KillFlag=='h'&&KillFlag=='s')hs_punish=number;
if(KillFlag=='k'&&KillFlag=='n')kn_punish=number;
if(KillFlag=='h'&&KillFlag=='e')he_punish=number;
}
case 'r':
{
if(KillFlag=='n'&&KillFlag=='o')no_reward=number;
if(KillFlag=='h'&&KillFlag=='s')hs_reward=number;
if(KillFlag=='k'&&KillFlag=='n')kn_reward=number;
if(KillFlag=='h'&&KillFlag=='e')he_reward=number;
}
}
return PLUGIN_HANDLED
}
karmor(index,howmuch)
{
set_user_armor(index,get_user_armor(index) + howmuch);
if(get_user_armor(index)>max_armor)
set_user_armor(index,max_armor);
}
khealth(index,howmuch)
{
set_user_health(index,get_user_health(index) + howmuch);
if(get_user_health(index)>max_health)
set_user_health(index,max_health);
}
kmoney(index,howmuch)
{
cs_set_user_money(index,cs_get_user_money(index) + howmuch);
}
vmoney(index,howmuch)
{
cs_set_user_money(index,cs_get_user_money(index) - howmuch);
if(cs_get_user_money(index)<0)cs_set_user_money(index,0);
}

summerice 发表于 2009-1-18 20:26:12

编译通过,测试成功,但时间还得测试长点才行。

d4server 发表于 2009-1-18 20:44:47

对普通服来讲还是比较高的娱乐性的,收藏!

shote 发表于 2009-1-19 01:39:03

希望用过朋友发下感受

yang586 发表于 2009-1-19 02:59:28

这个怎么保存啊?用什么格式存啊?

mwy5ym 发表于 2009-1-19 10:51:48

本帖最后由 mwy5ym 于 2009-1-19 10:58 编辑

这个怎么保存啊?用什么格式存啊?
yang586 发表于 2009-1-19 02:59 http://www.dt-club.net/forum/images/common/back.gif
普通格式应该可以吧,不行就保存为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里测试可以编译成功

8874323 发表于 2009-1-19 11:22:45

这样子贫富差距更大

此人已失踪 发表于 2012-8-7 20:09:04

编译通过,测试成功,但时间还得测试长点才行。
页: [1]
查看完整版本: 我的第一个插件(奖励和惩罚,有点无聊),大家来测测