|
发表于 2008-12-16 13:10:53
|
显示全部楼层
来自 中国–北京–北京–朝阳区
回复: 求受伤后自动缓慢回血的插件
- #include <amxmodx>
- #include <fun>
- #define PLUGIN "Test"
- #define AUTHOR "Jim"
- #define VERSION "1.0"
- new pchp
- new pcmaxhp
- new pct
- new task[33]
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- pchp = register_cvar("recover_hp", "1")
- pcmaxhp = register_cvar("recover_maxhp", "100")
- pct = register_cvar("recover_interval", "1")
- register_event("Damage", "event_damage", "be")
- register_event("DeathMsg", "event_death", "a")
- }
- public client_disconnect(id)
- {
- remove_task(id)
- task[id] = 0
- }
- public event_death()
- {
- new id = read_data(2)
- remove_task(id)
- task[id] = 0
- }
- public event_damage(id)
- {
- if(!task[id])
- {
- task[id] = set_task(float(get_pcvar_num(pct)), "addhp", id, _, _, "b")
- }
- }
- public addhp(id)
- {
- new maxhp = get_pcvar_num(pcmaxhp)
- new hp = get_user_health(id) + get_pcvar_num(pchp)
- if(hp < maxhp)
- {
- set_user_health(id, hp)
- }
- else
- {
- set_user_health(id, maxhp)
- remove_task(id)
- task[id] = 0
- }
- }
复制代码 |
|