Advertisement
Guest User

Untitled

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