搜索
查看: 4398|回复: 10

[AMXX 带源码] 找个人帮忙改下自动回血源码。

[复制链接]
发表于 2012-4-7 20:43:44 | 显示全部楼层 |阅读模式 来自 中国–广东–东莞
谁帮我改下这个【自动回血】源码
帮我把他改成OP才可以自动回血
谢谢 了
  1. #include <amxmodx>
  2. #include <fun>
  3. #define PLUGIN    "Test"
  4. #define AUTHOR    "Jim"
  5. #define VERSION    "1.0"
  6. new pchp
  7. new pcmaxhp
  8. new pct
  9. new task[33]
  10. public plugin_init()
  11. {
  12.     register_plugin(PLUGIN, VERSION, AUTHOR)
  13.     pchp = register_cvar("recover_hp", "1")
  14.     pcmaxhp = register_cvar("recover_maxhp", "100")
  15.     pct = register_cvar("recover_interval", "1")
  16.     register_event("Damage", "event_damage", "be")
  17.     register_event("DeathMsg", "event_death", "a")
  18. }
  19. public client_disconnect(id)
  20. {
  21.     remove_task(id)
  22.     task[id] = 0
  23. }
  24. public event_death()
  25. {
  26.     new id = read_data(2)
  27.     remove_task(id)
  28.     task[id] = 0
  29. }
  30. public event_damage(id)
  31. {
  32.     if(!task[id])
  33.     {
  34.         task[id] = set_task(float(get_pcvar_num(pct)), "addhp", id, _, _, "b")
  35.     }
  36. }
  37. public addhp(id)
  38. {
  39.     new maxhp = get_pcvar_num(pcmaxhp)
  40.     new hp = get_user_health(id) + get_pcvar_num(pchp)
  41.     if(hp < maxhp)
  42.     {
  43.         set_user_health(id, hp)
  44.     }
  45.     else
  46.     {
  47.         set_user_health(id, maxhp)
  48.         remove_task(id)
  49.         task[id] = 0
  50.     }
  51. }
复制代码
发表于 2012-4-8 13:58:33 | 显示全部楼层 来自 中国–湖南–长沙
不会  等好心人把
回复

使用道具 举报

 楼主| 发表于 2012-4-8 14:26:42 | 显示全部楼层 来自 中国–广东–东莞
673734294 发表于 2012-4-8 13:58
不会  等好心人把

sXe,我是黑翼恶魔= = 昨天我就知道你不会了,我无语:)
回复

使用道具 举报

 楼主| 发表于 2012-4-8 14:27:42 | 显示全部楼层 来自 中国–广东–东莞
{:soso__9424465344577227664_1:}
好心人啊,快出来吧,不然发个OP自动回血的插件也可以啊。
回复

使用道具 举报

发表于 2012-4-8 23:17:57 | 显示全部楼层 来自 中国–陕西–咸阳
01. #include <amxmodx>
02. #include <fun>
03. #define PLUGIN    "Test"
04. #define AUTHOR    "Jim"
05. #define VERSION    "1.0"
06. new pchp
07. new pcmaxhp
08. new pct
09. new task[33]
10. public plugin_init()
11. {
12. register_plugin(PLUGIN, VERSION, AUTHOR)
13. pchp = register_cvar("recover_hp","1")
14. pcmaxhp = register_cvar("recover_maxhp","100")
15. pct = register_cvar("recover_interval","1")
16. register_event("Damage","event_damage", "be")
17. register_event("DeathMsg","event_death", "a")
18. }
19. public client_disconnect(id)
20. {
21. remove_task(id)
22. task[id] = 0
23. }
24. public event_death()
25. {
26. new id = read_data(2)
27. remove_task(id)
28. task[id] = 0
29. }
30. public event_damage(id)
31. {
32. if(!task[id])
33. {
34. task[id] = set_task(float(get_pcvar_num(pct)), "addhp", id, _, _, "b")
35. }
36. }
37. public addhp(id)
38. {
39. if(get_user_flags(id) & ADMIN_IMMUNITY)
40. {
41. new maxhp = get_pcvar_num(pcmaxhp)
42. new hp = get_user_health(id)   get_pcvar_num(pchp)
43. if(hp < maxhp)
44. {
45. set_user_health(id, hp)
46. }
47. else
48. {
49. set_user_health(id, maxhp)
50. remove_task(id)
51. task[id] = 0
52. }
53. }
貌似好像是这样!但我估计可能不行!我只知道加个OP权限,但我不知该如何去加判断,也不大清楚具体加在哪个位置!不好意思只因俺也是新手!你先试试看吧!不行在帮你搞搞!因为我这没得电脑上网!要么就等好人出现吧

评分

参与人数 1经验 +2 点通币 +15 收起 理由
rsdtt + 2 + 15 在产生task之前判断会剩点资源

查看全部评分

回复

使用道具 举报

发表于 2012-4-9 01:26:23 | 显示全部楼层 来自 中国–广东–深圳–宝安区
#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] && get_user_flags(id) & ADMIN_IMMUNITY)
    {
        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
    }
}


自己试.自己试.自己试.自己试.自己试.自己试.自己试.

点评

给力啊,谢谢了  发表于 2012-4-22 18:07

评分

参与人数 1经验 +2 点通币 +20 收起 理由
rsdtt + 2 + 20 赞一个!

查看全部评分

回复

使用道具 举报

发表于 2012-4-9 10:18:26 | 显示全部楼层 来自 加拿大
我有源码 大家互相帮助








#include <amxmodx>
#include <fun>
#include <cstrike>
#define PLUGIN_NAME     "Set Vip HP"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR   "lovehuai"
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
set_task(1.0,"run_check",422,"",0,"b")
}
public run_check(){
if (get_cvar_num("gg_replinishhealth")==0) return PLUGIN_CONTINUE
new players[32]
new i, numofplayers, id
get_players(players, numofplayers)
for (i=0; i<numofplayers; i++){
  id=players
  if (!is_user_alive(id)) continue
  SetHp(id)
  }
return PLUGIN_CONTINUE
}
public SetHp(id)
{
if(get_user_flags(id) & ADMIN_LEVEL_C)
{
   new armor  = (get_user_armor  (id)) +5
   new health = (get_user_health (id)) +5
     if ( armor > 100) {
         cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM)
     }
     else {
         cs_set_user_armor(id, armor, CS_ARMOR_VESTHELM)
     }
     if ( health > 100) {
         set_user_health (id,100)
     }
     else {
         set_user_health (id,health)
     }
}   
}

点评

哥们,这源码不能编译啊  发表于 2012-4-22 18:30
回复

使用道具 举报

 楼主| 发表于 2012-4-22 18:08:09 | 显示全部楼层 来自 中国–广东–东莞
chungsy 发表于 2012-4-9 10:18
我有源码 大家互相帮助

这个是OP自动回血的?{:3_46:}
回复

使用道具 举报

 楼主| 发表于 2012-4-22 18:33:24 | 显示全部楼层 来自 中国–广东–东莞
By小伟 发表于 2012-4-9 01:26
#include
#include
#define PLUGIN    "Test"

可以帮我改成每秒回5hp不{:3_46:}
回复

使用道具 举报

发表于 2012-4-27 03:31:27 | 显示全部楼层 来自 中国–广东–茂名–高州市
  1. #include <amxmodx>
  2. #include <fun>
  3. #define PLUGIN    "Test"
  4. #define AUTHOR    "Jim"
  5. #define VERSION    "1.0"
  6. new pchp
  7. new pcmaxhp
  8. new pct
  9. new task[33]
  10. public plugin_init()
  11. {
  12.     register_plugin(PLUGIN, VERSION, AUTHOR)
  13.     pchp = register_cvar("recover_hp", "5")//每秒恢复的HP值
  14.     pcmaxhp = register_cvar("recover_maxhp", "100")//恢复HP上限
  15.     pct = register_cvar("recover_interval", "1")//每隔多少秒恢复HP
  16.     register_event("Damage", "event_damage", "be")
  17.     register_event("DeathMsg", "event_death", "a")
  18. }
  19. public client_disconnect(id)
  20. {
  21.     remove_task(id)
  22.     task[id] = 0
  23. }
  24. public event_death()
  25. {
  26.     new id = read_data(2)
  27.     remove_task(id)
  28.     task[id] = 0
  29. }
  30. public event_damage(id)
  31. {

  32.     if(!task[id] && get_user_flags(id) & ADMIN_IMMUNITY)
  33.     {
  34.         task[id] = set_task(float(get_pcvar_num(pct)), "addhp", id, _, _, "b")
  35.     }
  36. }
  37. public addhp(id)
  38. {
  39.     new maxhp = get_pcvar_num(pcmaxhp)
  40.     new hp = get_user_health(id) + get_pcvar_num(pchp)
  41.     if(hp < maxhp)
  42.     {
  43.         set_user_health(id, hp)
  44.     }
  45.     else
  46.     {
  47.         set_user_health(id, maxhp)
  48.         remove_task(id)
  49.         task[id] = 0
  50.     }
  51. }

复制代码
回复

使用道具 举报

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

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