HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. * _______ _ _ __ __
  3. * | _____/ | | | | \ \ __ / /
  4. * | | | | | | | | / \ | |
  5. * | | | |____| | | |/ __ \| |
  6. * | | ___ | ______ | | / \ |
  7. * | | |_ | | | | | | / \ |
  8. * | | | | | | | | | | | |
  9. * | |____| | | | | | | | | |
  10. * |_______/ |_| |_| \_/ \_/
  11. *
  12. *
  13. *
  14. * Last Edited: 12-30-07
  15. *
  16. * ============
  17. * Changelog:
  18. * ============
  19. *
  20. * v2.0
  21. * -Added ML
  22. * -Optimized Code
  23. *
  24. * v1.0
  25. * -Initial Release
  26. *
  27. */
  28.  
  29. #define VERSION "2.0"
  30.  
  31. #include <amxmodx>
  32. #include <amxmisc>
  33. #include <fun>
  34.  
  35. static const sound1[32] = "sleep.wav"
  36. static const sound2[32] = "bagyawn.wav"
  37. static const sound1b[32] = "sound/sleep.wav"
  38. static const sound2b[32] = "sound/bagyawn.wav"
  39.  
  40. new bool:playsound1
  41. new bool:playsound2
  42.  
  43. new bool:asleep[33]
  44.  
  45. new max_health
  46.  
  47. public plugin_init()
  48. {
  49. register_plugin("Sleep Mod",VERSION,"GHW_Chronic")
  50.  
  51. register_clcmd("say /sleep","cmd_sleep")
  52. register_clcmd("say /wakeup","cmd_wakeup")
  53. register_clcmd("say_team /sleep","cmd_sleep")
  54. register_clcmd("say_team /wakeup","cmd_wakeup")
  55. register_clcmd("say /alvas","cmd_sleep")
  56. register_clcmd("say /felkel","cmd_wakeup")
  57. register_clcmd("say_team /alvas","cmd_sleep")
  58. register_clcmd("say_team /felkel","cmd_wakeup")
  59.  
  60. max_health = register_cvar("sleep_maxhp","100")
  61.  
  62. register_dictionary("GHW_Sleepmod.txt")
  63. }
  64.  
  65. public plugin_precache()
  66. {
  67. if(file_exists(sound1b))
  68. {
  69. playsound1=true
  70. precache_sound(sound1)
  71. }
  72. if(file_exists(sound2b))
  73. {
  74. playsound2=true
  75. precache_sound(sound2)
  76. }
  77. }
  78.  
  79. public client_connect(id) asleep[id]=false
  80. public client_disconnect(id) asleep[id]=false
  81.  
  82. public cmd_wakeup(id)
  83. {
  84. if(!asleep[id]) client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOWAKEUP")
  85. else asleep[id]=false
  86. }
  87.  
  88. public cmd_sleep(id)
  89. {
  90. if(asleep[id]) client_print(id,print_chat,"[AMXX] %L",id,"MSG_NOSLEEP")
  91. else if(!is_user_alive(id)) client_print(id,print_chat," %L",id,"MSG_NOSLEEP2")
  92. else
  93. {
  94. asleep[id]=true
  95. set_task(0.2,"fadeout",id,"",0,"b")
  96. client_print(id,print_center,"[AMXX] %L",id,"MSG_SLEEP")
  97. client_print(id,print_chat,"[AMXX] %L",id,"MSG_WAKEUP")
  98. if(playsound1) emit_sound(id,CHAN_VOICE,sound1,VOL_NORM,ATTN_NORM,0,PITCH_NORM)
  99. }
  100. }
  101.  
  102. public fadeout(id)
  103. {
  104. if(!asleep[id])
  105. {
  106. set_user_maxspeed(id,320.0)
  107. client_cmd(id,"-duck")
  108.  
  109. if(playsound2) emit_sound(id,CHAN_VOICE,sound2,VOL_NORM,ATTN_NORM,0,PITCH_NORM)
  110. client_print(id,print_center,"[AMXX] %L",id,"MSG_WAKEUP2")
  111.  
  112. set_user_rendering(id)
  113.  
  114. message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
  115. write_short(~0)
  116. write_short(~0)
  117. write_short(1<<12)
  118. write_byte(0)
  119. write_byte(0)
  120. write_byte(0)
  121. write_byte(0)
  122. message_end()
  123. remove_task(id)
  124. }
  125. else if(!is_user_alive(id))
  126. {
  127. asleep[id]=false
  128. fadeout(id)
  129. }
  130. else
  131. {
  132. new health = get_user_health(id)
  133. if(health>=get_pcvar_num(max_health))
  134. {
  135. asleep[id]=false
  136. fadeout(id)
  137. }
  138. else
  139. {
  140. set_user_maxspeed(id,1.0)
  141. client_cmd(id,"+duck")
  142.  
  143. set_user_health(id,health + 1)
  144.  
  145. set_user_rendering(id,kRenderFxGlowShell,0,255,0,kRenderTransAlpha,25)
  146.  
  147. message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
  148. write_short(~0)
  149. write_short(~0)
  150. write_short(1<<12)
  151. write_byte(0)
  152. write_byte(0)
  153. write_byte(0)
  154. write_byte(255)
  155. message_end()
  156. }
  157. }
  158. }
  159.