Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <hamsandwich>
  3. new count_puke[33]
  4. new bool:PukeFlag[33], bool:aim[33], counter[33], limite_vomitar[33];
  5. new player_origins[33][3], maxplayers;
  6.  
  7. new const CMD[][]= { "puke", "vomir" }
  8. public plugin_precache()
  9. {
  10. if (file_exists("sound/puke/puke.wav"))
  11. precache_sound("puke/puke.wav")
  12. if (file_exists("sound/puke/puke2.wav"))
  13. precache_sound("puke/puke2.wav")
  14.  
  15. return PLUGIN_CONTINUE
  16. }
  17. public plugin_init()
  18. {
  19. register_plugin("AMX Puke","0.2","KRoTaL")
  20. for(new i = 0; i < sizeof(CMD); i++) { register_clcmd(CMD[i], "pukecmd"); }
  21. register_clcmd("say /puke","puke_help",0,"- Displays puke help")
  22. register_cvar("amx_maxpukes","3")
  23. register_cvar("amx_puke_admin","0")
  24. register_event("DeathMsg","death_event","a")
  25. register_event("ResetHUD", "reset_hud", "be")
  26. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  27. RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
  28.  
  29. maxplayers = get_maxplayers();
  30. }
  31. public fwHamPlayerSpawnPost(iPlayer) {
  32. if (is_user_alive(iPlayer)) {
  33. PukeFlag[iPlayer] = true
  34. }
  35. }
  36. public client_connect(id)
  37. {
  38. PukeFlag[id]=false
  39. count_puke[id]=1
  40. }
  41. public client_disconnect(id)
  42. {
  43. reset_hud(id)
  44. }
  45. public death_event()
  46. {
  47. new victim = read_data(2)
  48. #if !defined NO_CS_CZ
  49. get_user_origin(victim,player_origins[victim],0)
  50. #endif
  51.  
  52. if(PukeFlag[victim])
  53. reset_puke(victim)
  54.  
  55. return PLUGIN_CONTINUE
  56. }
  57. public reset_hud(id)
  58. {
  59. if(task_exists(2412+id))
  60. remove_task(2412+id)
  61. emit_sound(id,CHAN_VOICE,"puke/puke.wav", 0.0, ATTN_NORM, 0, PITCH_NORM)
  62. PukeFlag[id]=false
  63.  
  64. count_puke[id]=1
  65.  
  66. return PLUGIN_CONTINUE
  67. }
  68. public event_round_start() {
  69. for(new i = 1; i <= maxplayers; i++) {
  70. limite_vomitar[i] = 0;
  71. }
  72. }
  73. public reset_puke(id)
  74. {
  75. if(task_exists(2412+id))
  76. remove_task(2412+id)
  77. emit_sound(id,CHAN_VOICE,"puke/puke.wav", 0.0, ATTN_NORM, 0, PITCH_NORM)
  78. PukeFlag[id]=false
  79.  
  80. return PLUGIN_CONTINUE
  81. }
  82. public puke_help(id)
  83. {
  84. client_print(id, print_chat, "Para vomitar escribe en consola bind ^"z^" ^"puke^"")
  85.  
  86. return PLUGIN_CONTINUE
  87. }
  88. public pukecmd(const id) {
  89. if(limite_vomitar[id] > 2) {
  90. client_print(id, print_chat,"[AMXX] No puedes vomitar mas de 2 veces por ronda.")
  91. return;
  92. }
  93. if(!is_user_alive(id)) {
  94. client_print(id, print_chat,"[AMXX] No puedes vomitar estando muerto.")
  95. return;
  96. }
  97. count_puke[id]+=1
  98. new ids[1]
  99. ids[0]=id
  100. PukeFlag[id]=true
  101. aim[id]=false
  102. counter[id]=0
  103. new rand_sound=random_num(0,1)
  104. new player_name[33]; get_user_name(id, player_name, charsmax(player_name));
  105. client_print(0, print_chat,"%s Esta Vomitando !!", player_name)
  106. switch(rand_sound)
  107. {
  108.  
  109. case 0: emit_sound(id, CHAN_VOICE, "puke/puke.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  110. case 1: emit_sound(id, CHAN_VOICE, "puke/puke2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  111. }
  112. set_task(0.3,"make_puke",2412+id,ids,1,"a",9)
  113. limite_vomitar[id]++
  114. }
  115. public sqrt(num)
  116. {
  117. new div = num
  118. new result = 1
  119. while (div > result) {
  120. div = (div + result) / 2
  121. result = num / div
  122. }
  123. return div
  124. }
  125. public make_puke(ids[])
  126. {
  127. new id=ids[0]
  128. new vec[3]
  129. new aimvec[3]
  130. new velocityvec[3]
  131. new length
  132. get_user_origin(id,vec, 1)
  133. get_user_origin(id,aimvec,3)
  134. new distance = get_distance(vec,aimvec)
  135. new speed = floatround(distance*1.9)
  136.  
  137. velocityvec[0]=aimvec[0]-vec[0]
  138. velocityvec[1]=aimvec[1]-vec[1]
  139. velocityvec[2]=aimvec[2]-vec[2]
  140.  
  141. length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2])
  142.  
  143. velocityvec[0]=velocityvec[0]*speed/length
  144. velocityvec[1]=velocityvec[1]*speed/length
  145. velocityvec[2]=velocityvec[2]*speed/length
  146.  
  147. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  148. write_byte(101)
  149. write_coord(vec[0])
  150. write_coord(vec[1])
  151. write_coord(vec[2]-2)
  152. write_coord(velocityvec[0])
  153. write_coord(velocityvec[1])
  154. write_coord(velocityvec[2])
  155. write_byte(82) // color
  156. write_byte(160) // speed
  157. message_end()
  158.  
  159. counter[id]++
  160. if(counter[id]==9)
  161. PukeFlag[id]=false
  162.  
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement