HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <fakemeta_util>
  6.  
  7. #define MSG_SHOW_MIN_TIME 0.1
  8.  
  9. new is_glowing[33]
  10.  
  11. new last_ent[33],can_touch[33]
  12. new onoff,dist,glow,glow_color
  13.  
  14. new red,green,blue
  15.  
  16. public plugin_init() {
  17. register_plugin("E betûre fegyver felvétel","0.9","Sh!nE")
  18.  
  19. onoff = register_cvar("amx_rwpickup","1")
  20. dist = register_cvar("amx_rwp_distance","150")
  21. glow = register_cvar("amx_rwp_glow","1")
  22. glow_color = register_cvar("amx_rwp_glow_color","255 4 44")
  23.  
  24. register_logevent("round_start",2,"1=Round_Start")
  25.  
  26. register_forward(FM_CmdStart,"cmd_start")
  27.  
  28. RegisterHam(Ham_Touch,"weaponbox","touch_weapon")
  29. RegisterHam(Ham_Touch,"armoury_entity","touch_weapon")
  30. RegisterHam(Ham_Touch,"weapon_shield","touch_weapon")
  31.  
  32. register_forward(FM_AddToFullPack,"addtofullpack",1)
  33. }
  34.  
  35. public round_start() {
  36. new temp_rgb[12],temp_rgb2[3][4]
  37. get_pcvar_string(glow_color,temp_rgb,11)
  38.  
  39. parse(temp_rgb,temp_rgb2[0],3,temp_rgb2[1],3,temp_rgb2[2],3)
  40.  
  41. red=str_to_num(temp_rgb2[0])
  42. green=str_to_num(temp_rgb2[1])
  43. blue=str_to_num(temp_rgb2[2])
  44. }
  45.  
  46. public addtofullpack(es_handle,e,ent,id,hostflags,player,pSet) {
  47. if(!is_user_alive(id) || !get_pcvar_num(onoff) || !get_pcvar_num(glow) || (id==ent) || is_user_bot(id)) return FMRES_IGNORED
  48.  
  49. if(is_glowing[id]==ent) {
  50. new rgb[3]
  51.  
  52. rgb[0]=red
  53. rgb[1]=green
  54. rgb[2]=blue
  55.  
  56. set_es(es_handle,ES_RenderMode,kRenderNormal)
  57. set_es(es_handle,ES_RenderFx,kRenderFxGlowShell)
  58. set_es(es_handle,ES_RenderAmt,16)
  59. set_es(es_handle,ES_RenderColor,rgb)
  60. }
  61. return FMRES_IGNORED
  62. }
  63.  
  64. public cmd_start(id,uc_handle,random_seed) {
  65. if(!is_user_alive(id) || !get_pcvar_num(onoff) || is_user_bot(id)) return FMRES_IGNORED
  66.  
  67. static buttons
  68. buttons=get_uc(uc_handle,UC_Buttons)
  69.  
  70. new ent = get_aim_origin_ent(id)
  71.  
  72. if(ent!=last_ent[id]) {
  73. is_glowing[id]=0
  74. last_ent[id]=ent
  75. }
  76.  
  77. if(!ent) {
  78. remove_task(id)
  79. return FMRES_IGNORED
  80. }
  81.  
  82. is_glowing[id]=ent
  83.  
  84. if(!task_exists(id)) set_task(MSG_SHOW_MIN_TIME,"show_pickup",id,_,_,"b")
  85.  
  86. if(buttons & IN_USE) {
  87. can_touch[id]=ent
  88. dllfunc(DLLFunc_Touch,ent,id)
  89. }
  90. else if(!(buttons & IN_USE)) can_touch[id]=0
  91.  
  92. return FMRES_IGNORED
  93. }
  94.  
  95. public show_pickup(id) {
  96. set_hudmessage(0,255,0,-1.0,0.88,0,6.0,MSG_SHOW_MIN_TIME)
  97. show_hudmessage(id,"Nyomd meg az E betűt, hogy felvedd")
  98. }
  99.  
  100. public client_disconnect(id) {
  101. is_glowing[id]=0
  102. last_ent[id]=0
  103. can_touch[id]=0
  104.  
  105. remove_task(id)
  106. }
  107.  
  108. public touch_weapon(ent,id) {
  109. if(!is_user_alive(id) || !get_pcvar_num(onoff) || is_user_bot(id)) return HAM_IGNORED
  110.  
  111. if(can_touch[id]==ent) {
  112. can_touch[id]=0
  113. return HAM_IGNORED
  114. }
  115. return HAM_SUPERCEDE
  116. }
  117.  
  118. stock get_aim_origin_ent(id) {
  119. new ent=-1
  120. static Float:origin[2][3]
  121.  
  122. pev(id,pev_origin,origin[0])
  123. fm_get_aim_origin(id,origin[1])
  124.  
  125. if(get_distance_f(origin[0],origin[1]) > float(get_pcvar_num(dist))) return 0
  126.  
  127. while((ent = engfunc(EngFunc_FindEntityInSphere,ent,origin[1],5.0))) {
  128. static classname[33]
  129. pev(ent,pev_classname,classname,32)
  130.  
  131. if(equal(classname,"weaponbox") || equal(classname,"armoury_entity") || equal(classname,"weapon_shield")) return ent
  132. }
  133. return 0
  134. }