HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4.  
  5. new bool:can_plant
  6. new planter
  7. new g_state
  8. new g_bombEnts[2] = {0,0}
  9.  
  10. public plugin_init()
  11. {
  12. register_plugin("Plant Anywhere", "0.2", "KRoTaL")
  13. register_concmd("amx_plantanywhere", "cmdPlantAnywhere", ADMIN_LEVEL_A, "<0/1>")
  14. register_cvar("sv_c4plant", "60")
  15. register_event("TextMsg", "game_restart", "a", "1=4", "2&#Game_C", "2&#Game_w")
  16. register_event("SendAudio", "round_end", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw")
  17. register_logevent("new_round", 2, "0=World triggered", "1=Round_Start")
  18. register_event("StatusIcon", "gotbomb", "be", "1=1", "1=2", "2=c4")
  19. g_state = 0
  20. }
  21.  
  22. public cmdPlantAnywhere(id,level,cid)
  23. {
  24. if(!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED
  25. new arg[32]
  26. read_argv(1,arg,31)
  27. new state1 = str_to_num(arg) ? 1 : 0
  28. if(g_state == state1)
  29. {
  30. console_print(id, "Bárhol lerakhatod most is %s", g_state ? "enabled" : "disabled")
  31. return PLUGIN_HANDLED
  32. }
  33. g_state = state1
  34. if(g_state) create_bombtarget()
  35. else remove_bombtarget()
  36. console_print(id, "Bárhová lerakhattad %s", g_state ? "enabled" : "disabled")
  37. return PLUGIN_HANDLED
  38.  
  39. }
  40.  
  41. public gotbomb(id)
  42. {
  43. planter = id
  44. return PLUGIN_CONTINUE
  45. }
  46.  
  47. public round_end()
  48. {
  49. set_task(4.0, "disable_planting", 78645135)
  50. }
  51.  
  52. public game_restart()
  53. {
  54. set_task(0.5, "disable_planting", 71586461)
  55. }
  56.  
  57. public disable_planting()
  58. {
  59. if(task_exists(97564673)) remove_task(97564673)
  60. planter = 0
  61. can_plant = false
  62. }
  63.  
  64. public new_round()
  65. {
  66. set_task(get_cvar_float("sv_c4plant"), "enable_planting", 97564673)
  67. }
  68.  
  69. public enable_planting()
  70. {
  71. can_plant = true
  72. }
  73.  
  74. public create_bombtarget()
  75. {
  76. new old_bomtarget = find_ent_by_class(-1, "func_bomb_target")
  77. if(old_bomtarget > 0)
  78. {
  79. new Float:origin[3]
  80. entity_get_vector(old_bomtarget, EV_VEC_origin, origin)
  81. new bombtarget = create_entity("func_bomb_target")
  82. if(bombtarget > 0)
  83. {
  84. DispatchKeyValue(bombtarget, "classname", "func_bomb_target")
  85. DispatchSpawn(bombtarget)
  86. entity_set_size(bombtarget, Float:{-1000000.0,-1000000.0,-1000000.0}, Float:{1000000.0,1000000.0,1000000.0})
  87. entity_set_string(bombtarget, EV_SZ_classname, "func_bomb_target")
  88. entity_set_origin(bombtarget, origin)
  89. g_bombEnts[0] = bombtarget
  90. }
  91. bombtarget = create_entity("info_bomb_target")
  92. if(bombtarget > 0)
  93. {
  94. DispatchKeyValue(bombtarget, "classname", "info_bomb_target")
  95. DispatchSpawn(bombtarget)
  96. entity_set_size(bombtarget, Float:{-1000000.0,-1000000.0,-1000000.0}, Float:{1000000.0,1000000.0,1000000.0})
  97. entity_set_string(bombtarget, EV_SZ_classname, "info_bomb_target")
  98. entity_set_origin(bombtarget, origin)
  99. g_bombEnts[1] = bombtarget
  100. }
  101. }
  102. }
  103.  
  104. public remove_bombtarget()
  105. {
  106. if(is_valid_ent(g_bombEnts[0])) remove_entity(g_bombEnts[0])
  107. if(is_valid_ent(g_bombEnts[1])) remove_entity(g_bombEnts[1])
  108. }
  109.  
  110. public client_prethink(id)
  111. {
  112. if(g_state && id == planter && !can_plant)
  113. {
  114. new clip, ammo, weapon = get_user_weapon(id, clip, ammo)
  115. if(weapon == CSW_C4)
  116. {
  117. entity_set_int(id, EV_INT_button, entity_get_int(id, EV_INT_button) & ~IN_ATTACK)
  118. }
  119. }
  120. }
  121.