HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #define USING_AMX 0 // 1 = Using AMX \ 0 = Using AMXX
  2.  
  3. #if USING_AMX
  4. #include <amxmod>
  5. #include <VexdUM>
  6. #else
  7. #include <amxmodx>
  8. #include <engine>
  9. #include <cstrike>
  10. #include <fun>
  11. #endif
  12.  
  13.  
  14. new gMsgDeathMsg
  15. new gCurrentNade
  16.  
  17. public plugin_init()
  18. {
  19. // Plugin Info
  20. register_plugin("Grenades Are Heavy", "1.0", "AssKicR")
  21. register_event("RoundTime", "newRound", "bc")
  22. register_cvar("amx_heimpactdmg","5")
  23. register_cvar("amx_fbimpactdmg","5")
  24. register_cvar("amx_sgimpactdmg","5")
  25. register_cvar("amx_obeyff", "1")
  26. gMsgDeathMsg = get_user_msgid("DeathMsg")
  27. }
  28. public newRound() {
  29. new Float:roundtime = get_cvar_float("mp_roundtime") * 60.0
  30. new rtime = read_data(1)
  31. if(roundtime == rtime) {
  32. gCurrentNade=0
  33. }
  34. }
  35.  
  36. public pfn_touch(ptr, ptd)
  37. {
  38. if (ptd!=0 && ptr!=0) {
  39. new ptrname[32], ptdname[32], ptrModel[32]
  40. entity_get_string(ptr, EV_SZ_classname, ptrname, 31)
  41. entity_get_string(ptd, EV_SZ_classname, ptdname, 31)
  42. if(equal(ptrname, "grenade") && equal(ptdname, "player")) {
  43. if (gCurrentNade==ptr) return
  44. gCurrentNade=ptr
  45. new ptrOwner = entity_get_edict(ptr, EV_ENT_owner)
  46.  
  47. new bool:HitFriend=false
  48. new ObeyFF = get_cvar_num("amx_obeyff") ? 1:0
  49. new FFOn = get_cvar_num("mp_friendlyfire") ? 1:0
  50. if(!FFOn && ObeyFF) {
  51. if(get_user_team(ptd) == get_user_team(ptrOwner)) {
  52. HitFriend=true
  53. }
  54. }
  55.  
  56. if(!HitFriend) {
  57. entity_get_string(ptr, EV_SZ_model, ptrModel, 31)
  58. //client_print(0, 3, "Grenade with model ^"%s^" has hit a player",ptrModel) //This is for debugging
  59. if (equali(ptrModel,"models/w_hegrenade.mdl")) {
  60. emit_sound(ptr, CHAN_ITEM, "weapons/ric_metal-1.wav", 0.7, ATTN_NORM, 0, PITCH_NORM)
  61. emit_sound(ptd, CHAN_BODY, "player/bhit_flesh-1.wav", 0.7, ATTN_NORM, 0, PITCH_NORM)
  62. ImpactDamage(ptd,ptr)
  63. ScreenShake(ptd,
  64. 14, 14, 14 )
  65. ScreenFlash(ptd, 255, 0, 0, 1, 200 )
  66. HazedView(ptd, 120 )
  67. ExtraDamage(ptd, ptrOwner, get_cvar_num("amx_heimpactdmg"), "grenade" )
  68. }else if (equali(ptrModel,"models/w_flashbang.mdl")) {
  69. emit_sound(ptr, CHAN_ITEM, "weapons/ric_metal-1.wav", 0.7, ATTN_NORM, 0, PITCH_NORM)
  70. emit_sound(ptd, CHAN_BODY, "player/bhit_flesh-1.wav", 0.7, ATTN_NORM, 0, PITCH_NORM)
  71. ImpactDamage(ptd,ptr)
  72. ScreenShake(ptd, 14, 14, 14 )
  73. ScreenFlash(ptd, 255, 0, 0, 1, 200 )
  74. HazedView(ptd, 120 )
  75. ExtraDamage(ptd, ptrOwner, get_cvar_num("amx_fbimpactdmg"), "flashbang" )
  76. }else if (equali(ptrModel,"models/w_smokegrenade.mdl")) {
  77. emit_sound(ptr, CHAN_ITEM, "weapons/ric_metal-1.wav", 0.7, ATTN_NORM, 0, PITCH_NORM)
  78. emit_sound(ptd, CHAN_BODY, "player/bhit_flesh-1.wav", 0.7, ATTN_NORM, 0, PITCH_NORM)
  79. ImpactDamage(ptd,ptr)
  80. ScreenShake(ptd, 14, 14, 14 )
  81. ScreenFlash(ptd, 255, 0, 0, 1, 200 )
  82. HazedView(ptd, 120 )
  83. ExtraDamage(ptd, ptrOwner, get_cvar_num("amx_sgimpactdmg"), "smokegrenade" )
  84. }
  85. }
  86. }
  87. }
  88. }
  89.  
  90. public ExtraDamage(id, attacker, damage, weaponDescription[] )
  91. {
  92. if ( is_user_alive(id) )
  93. {
  94. new userHealth=get_user_health(id)
  95. set_msg_block(gMsgDeathMsg, BLOCK_SET)
  96. set_user_health(id, userHealth - damage )
  97. set_msg_block(gMsgDeathMsg, BLOCK_NOT)
  98. if ( userHealth - damage <= 0 )
  99. {
  100. logKill(attacker,id, weaponDescription)
  101. if ( get_user_team(id) != get_user_team(attacker) )
  102. {
  103. // The person dying shouldn't get negative credit for this kill (so add it back)
  104. set_user_frags( id, get_user_frags(id) + 1 )
  105.  
  106. // The killing should get credit for the frag
  107. set_user_frags( attacker, get_user_frags(attacker)+ 1 )
  108.  
  109. MoneyEvent(attacker,300,1)
  110. }
  111. else
  112. {
  113. // The person dying shouldn't get negative credit for this kill (so add it back)
  114. set_user_frags( id, get_user_frags(id)+ 1 )
  115.  
  116. // The killer killed a teammember or self
  117. // Engine gives credit for the kill so let's take away that + 1
  118. set_user_frags( attacker, get_user_frags(attacker) - 2)
  119.  
  120. MoneyEvent(attacker,150,0)
  121. }
  122.  
  123. message_begin( MSG_BROADCAST, get_user_msgid("DeathMsg"),{0,0,0},0)
  124. write_byte(attacker)
  125. write_byte(id)
  126. write_byte(0)
  127. write_string(weaponDescription)
  128. message_end()
  129. }
  130. }
  131. }
  132.  
  133. #if USING_AMX
  134. stock cs_get_user_money(index) return get_user_money(index)
  135. stock cs_set_user_money(index, money, flash = 1) set_user_money(index, money, flash)
  136. #endif
  137.  
  138. public MoneyEvent(id,money,plus) {
  139. new HasMoney
  140.  
  141. HasMoney = cs_get_user_money(id)
  142.  
  143. if (plus)
  144. {
  145. if (HasMoney < 16000)
  146. {
  147. if (HasMoney+money > 16000)
  148. {
  149. cs_set_user_money(id,16000)
  150. }else{
  151. cs_set_user_money(id,HasMoney+money)
  152. }
  153. }
  154. }else{
  155. if (HasMoney > 0 )
  156. {
  157. if (HasMoney-money < 0)
  158. {
  159. cs_set_user_money(id,0)
  160. }else{
  161. cs_set_user_money(id,HasMoney-money)
  162. }
  163. }
  164. }
  165. }
  166.  
  167.  
  168. public logKill(id, victim, weaponDescription[] )
  169. {
  170. //Save Hummiliation
  171. new namea[24],namev[24],authida[20],authidv[20],teama[8],teamv[8]
  172.  
  173. //Info On Attacker
  174. get_user_name(id,namea,23)
  175. get_user_team(id,teama,7)
  176. get_user_authid(id,authida,19)
  177. //Info On Victim
  178. get_user_name(victim,namev,23)
  179. get_user_team(victim,teamv,7)
  180. get_user_authid(victim,authidv,19)
  181. //Log This Kill
  182. log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",
  183. namea,get_user_userid(id),authida,teama,namev,get_user_userid(victim),authidv,teamv, weaponDescription )
  184. }
  185.  
  186. public ScreenShake(id, amplitude, duration, frequency )
  187. {
  188. if ( !is_user_alive(id) ) return
  189. message_begin(MSG_ONE, get_user_msgid("ScreenShake"),{0,0,0},id)
  190. write_short( 1<<amplitude )// amplitude
  191. write_short( 1<<duration )// duration
  192. write_short( 1<<frequency )// frequency
  193. message_end()
  194. }
  195.  
  196. public ScreenFlash(id, red, green, blue, decisecs, alpha)
  197. {
  198. if ( !is_user_alive(id) ) return
  199. message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
  200. write_short( decisecs<<12 ) // fade lasts this long duration
  201. write_short( 1<<16 ) // fade lasts this long hold time
  202. write_short( 1<<1 ) // fade type (in / out)
  203. write_byte( red ) // fade red
  204. write_byte( green ) // fade green
  205. write_byte( blue ) // fade blue
  206. write_byte( alpha ) // fade alpha
  207. message_end()
  208. }
  209.  
  210. public HazedView(id, frequency )
  211. {
  212. if ( !is_user_alive(id) ) return
  213. message_begin(MSG_ONE, get_user_msgid("SetFOV"), {0,0,0}, id)
  214. write_byte( frequency ) // FOV Distance
  215. message_end()
  216. set_task(2.0,"RestoreVision",id)
  217. }
  218.  
  219. public RestoreVision(id)
  220. {
  221. message_begin(MSG_ONE, get_user_msgid("SetFOV"), {0,0,0}, id)
  222. write_byte( 90 ) // FOV Default
  223. message_end()
  224. }
  225.  
  226. public ImpactDamage(id,grenadeid) {
  227. new Float:gorigin[3], origin[3]
  228. entity_get_vector(grenadeid, EV_VEC_origin, gorigin)
  229. origin[0]=floatround(gorigin[0])
  230. origin[1]=floatround(gorigin[1])
  231. origin[2]=floatround(gorigin[2])
  232. if ( !is_user_alive(id) ) return
  233. message_begin(MSG_ONE, get_user_msgid("Damage"), {0,0,0}, id)
  234. write_byte(30) // dmg_save
  235. write_byte(30) // dmg_take
  236. write_long(0) // visibleDamageBits
  237. write_coord(origin[0]) // damageOrigin.x
  238. write_coord(origin[1]) // damageOrigin.y
  239. write_coord(origin[2]) // damageOrigin.z
  240. message_end()
  241. }