搜索
查看: 1876|回复: 1

求助:玩家死亡后变急救包插件

[复制链接]
发表于 2007-8-2 16:55:41 | 显示全部楼层 |阅读模式 来自 中国–甘肃–兰州
已经是二次发贴了:
最近在Super Hero的官方网上找到了一个很有趣的英雄,他的技能有点像七龙珠里的魔人布欧(sh_majinbuu.amxx),可以把玩家打死后让其变成巧克力(急救包),无论谁去捡起掉在地上的急救包都可以增加50HP!

所以,我想把这个英雄插件改成普通的大家都能共享的插件,改后的插件可以增加以下指令:

amx_medkit 1 // 插件开关控制
amx_medkithealth 50 // 急救包补充的血值(默认是50)


我自己试着把插件的源代码改了一下,但无法成功地在Amxmodx1.76d下编译出来。我知道里面肯定还有很多地方没有修改好,麻烦大家帮帮忙了......:burn:
  1. */
  2. #include <amxmodx>
  3. #include <cstrike>
  4. #include <csx>
  5. // GLOBAL VARIABLES
  6. #define Smoke
  7. //----------------------------------------------------------------------------------------------
  8. public plugin_init()
  9. {
  10. // Plugin Info
  11. register_plugin("AMX Medkit","1.0","duper/Rockell")
  12. // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
  13. [color=red]register_cvar("amx_medkit", "1" )
  14. register_cvar("amx_medkithealth", "50")
  15. [/color]
  16. // REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
  17. // INIT
  18. register_event("ResetHUD", "newRound","b")
  19. register_event("DeathMsg","deathevent","a")
  20. }
  21. //----------------------------------------------------------------------------------------------
  22. public newRound()
  23. {
  24.         new chocolate = find_ent_by_class(-1, "chocolate")
  25. while(chocolate) {
  26. remove_entity(chocolate)
  27. chocolate = find_ent_by_class(chocolate, "chocolate")
  28.         }
  29. }
  30. //----------------------------------------------------------------------------------------------
  31. public deathevent()
  32. {
  33. new killer = read_data(1)
  34. new victim = read_data(2)
  35. if ( killer != victim )
  36.         {
  37. if ( gHasBuuPower[killer] && is_user_alive(killer) )
  38. {
  39. createChocolate(victim)
  40. new aimvec[3]
  41. get_user_origin(victim, aimvec)
  42. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  43. write_byte(23)
  44. write_coord(aimvec[0])
  45. write_coord(aimvec[1])
  46. write_coord(aimvec[2])
  47. write_short(Smoke)
  48. write_byte(001)
  49. write_byte(65)
  50. write_byte(200)
  51. message_end()
  52. aimvec[2] -= 100
  53. set_user_origin(victim, aimvec)
  54. }
  55. }
  56. return PLUGIN_HANDLED
  57. }
  58. //----------------------------------------------------------------------------------------------
  59. public createChocolate(victim)
  60. {
  61. new Float:vAim[3], Float:vOrigin[3]
  62. entity_get_vector(victim, EV_VEC_origin, vOrigin)
  63. VelocityByAim(victim, random_num(2, 4), vAim)
  64. vOrigin[0] += vAim[0]
  65. vOrigin[1] += vAim[1]
  66. vOrigin[2] += 30.0
  67. new chocolate = create_entity("info_target")
  68. entity_set_string(chocolate, EV_SZ_classname, "chocolate")
  69. entity_set_model(chocolate, "models/w_medkit.mdl")
  70. entity_set_size(chocolate, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
  71. entity_set_int(chocolate, EV_INT_solid, 2)
  72. entity_set_int(chocolate, EV_INT_movetype, 6)
  73. entity_set_vector(chocolate, EV_VEC_origin, vOrigin)
  74. }
  75. //----------------------------------------------------------------------------------------------
  76. public plugin_precache() {
  77. precache_model("models/w_medkit.mdl")
  78. Smoke = precache_model("sprites/wall_puff4.spr")
  79. }
  80. //----------------------------------------------------------------------------------------------
  81. public pfn_touch(ptr, ptd)
  82. {
  83. if(!is_valid_ent(ptd) || !is_valid_ent(ptr))
  84.   return PLUGIN_CONTINUE
  85. if(!is_user_connected(ptd) || !is_user_alive(ptd))
  86.   return PLUGIN_CONTINUE
  87. if( !gHasBuuPower[ptd] )
  88.   return PLUGIN_CONTINUE
  89. new classname[32]
  90. entity_get_string(ptr, EV_SZ_classname, classname, 31)
  91. if(equal(classname, "chocolate"))
  92. {
  93. new gOrigHealth = get_user_health(ptd)
  94. new health = gOrigHealth + get_cvar_num("buu_chocolatehealth")
  95. set_user_health(ptd, health)
  96. remove_entity(ptr)
  97. }
  98. return PLUGIN_CONTINUE
  99. }  
复制代码
 楼主| 发表于 2007-8-4 19:40:21 | 显示全部楼层 来自 中国–甘肃–兰州

回复: 求助:玩家死亡后变急救包插件

呵呵,问题已经解决了!
回复

使用道具 举报

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

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