hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2021.02.27. 06:57



Jelenlévő felhasználók

Jelenleg 71 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 69 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Majestic-12 [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 8 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.17. 09:12 
Offline
Jómunkásember
Avatar

Csatlakozott: 2013.12.15. 19:13
Hozzászólások: 419
Megköszönt másnak: 212 alkalommal
Megköszönték neki: 13 alkalommal
Üdv!
Az alábbi SMA-t légyszíves valaki írja át, hogy:
CSAK azt írja ki CHATBE, hogy "Megkaptad a bombát!":

  1. /* AMX Mod X
  2. *   AFK Bomb Transfer
  3. *
  4. * (c) Copyright 2006 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION
  9. *       Plugin allow transfer bomb from AFK terrorist to closest non-AFK teammate.
  10. *       Plugin will have no effect:
  11. *         - at the freezetime
  12. *         - if bomb is planting
  13. *         - on non-bomb maps (comment #define BOMB_MAP_CHECK to suppress)
  14. *
  15. *     MODULES
  16. *       fakemeta
  17. *
  18. *     CVARS
  19. *       afk_bombtransfer_spawn (N: seconds, default: 7) - max. allowed bomb carrier AFK time
  20. *         affects on spawned AFK bomb carrier which never moved after spawn
  21. *
  22. *       afk_bombtransfer_time (N: seconds, default: 15) - max. allowed bomb carrier AFK time
  23. *         affects on any AFK bomb carrier except one which obey previous CVAR
  24. *
  25. *     HUD MESSAGES
  26. *       Terrorist team (green color)
  27. *         Bomb transferred to "NEW_CARRIER_NAME"
  28. *         since "AFK_CARRIER_NAME" is AFK
  29. *
  30. *       New bomb carrier (yellow color)
  31. *         You got the bomb!
  32. *
  33. *       Note: by defult message display time is 7 seconds (define MSG_TIME)
  34. *
  35. *     VERSIONS
  36. *       0.4   backpack transfer method greatly improved
  37. *             added pcvar natives support (backward compatibility saved)
  38. *             few code optimization
  39. *       0.3   now fakemeta instead of engine required (efficiency++ if engine is disabled)
  40. *             "non-bomb map" check can be disabled (//#define BOMB_MAP_CHECK)
  41. *             backpack finding method improved
  42. *             few code optimization
  43. *             added comments to the plugin source code
  44. *       0.2   fixed format issue
  45. *             code optimized
  46. *             description improved
  47. *
  48. *       0.1   first release
  49. */
  50.  
  51. /* *************************************************** Init **************************************************** */
  52.  
  53. #include <amxmodx>
  54. #include <fakemeta>
  55.  
  56. // plugin's main information
  57. #define PLUGIN_NAME "AFK Bomb Transfer"
  58. #define PLUGIN_VERSION "0.4"
  59. #define PLUGIN_AUTHOR "VEN"
  60.  
  61. // comment to avoid autodisabling the plugin on maps which not contain bomb targets
  62. #define BOMB_MAP_CHECK
  63.  
  64. // float value, hud messages display time (in seconds)
  65. #define MSG_TIME 7.0
  66.  
  67. // CVAR name, affects on spawned AFK bomb carrier which never moved after spawn
  68. new CVAR_SPAWN[] = "afk_bombtransfer_spawn"
  69.  
  70. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  71. new DEFAULT_SPAWN[] = "7"
  72.  
  73. // CVAR name, affects on any AFK bomb carrier except one which obey previous CVAR
  74. new CVAR_TIME[] = "afk_bombtransfer_time"
  75.  
  76. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  77. new DEFAULT_TIME[] = "15"
  78.  
  79. // do not set this value less than "maxplayers"
  80. #define MAX_PLAYERS 32
  81.  
  82. // initial AMXX version number supported CVAR pointers in get/set_pcvar_* natives
  83. #define CVAR_POINTERS_AMXX_INIT_VER_NUM 170
  84.  
  85. // determine if get/set_pcvar_* natives can be used
  86. #if defined AMXX_VERSION_NUM && AMXX_VERSION_NUM >= CVAR_POINTERS_AMXX_INIT_VER_NUM
  87.     #define CVAR_POINTERS
  88.     new g_pcvar_spawn
  89.     new g_pcvar_time
  90. #endif
  91.  
  92. new TEAM[] = "TERRORIST"
  93. new WEAPON[] = "weapon_c4"
  94.  
  95. #define FL_ONGROUND (1<<9)
  96.  
  97. new bool:g_freezetime = true
  98. new bool:g_spawn
  99. new bool:g_planting
  100.  
  101. new g_carrier
  102.  
  103. new g_pos[MAX_PLAYERS + 1][3]
  104. new g_time[MAX_PLAYERS + 1]
  105.  
  106. new g_maxplayers
  107.  
  108. public plugin_init() {
  109.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  110.  
  111. #if defined CVAR_POINTERS
  112.     g_pcvar_spawn = register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  113.     g_pcvar_time = register_cvar(CVAR_TIME, DEFAULT_TIME)
  114. #else
  115.     register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  116.     register_cvar(CVAR_TIME, DEFAULT_TIME)
  117. #endif
  118.  
  119. #if defined BOMB_MAP_CHECK
  120.     // is current map not contain bomb targets?
  121.     if (!engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target"))
  122.         return
  123. #endif
  124.  
  125.     register_event("WeapPickup", "event_got_bomb", "be", "1=6")
  126.     register_event("BarTime", "event_bar_time", "be")
  127.     register_event("TextMsg", "event_bomb_drop", "bc", "2=#Game_bomb_drop")
  128.     register_event("TextMsg", "event_bomb_drop", "a", "2=#Bomb_Planted")
  129.     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
  130.  
  131.     register_logevent("logevent_round_start", 2, "1=Round_Start")
  132.  
  133.     set_task(1.0, "task_afk_check", _, _, _, "b") // plugin's core loop
  134.  
  135.     g_maxplayers = get_maxplayers()
  136. }
  137.  
  138. /* *************************************************** Base **************************************************** */
  139.  
  140. public event_new_round() {
  141.     g_freezetime = true
  142.     g_spawn = true
  143.     g_planting = false
  144.     g_carrier = 0
  145. }
  146.  
  147. public event_got_bomb(id) {
  148.     g_carrier = id
  149. }
  150.  
  151. public event_bar_time(id) {
  152.     if (id == g_carrier) {
  153.         g_planting = bool:read_data(1)
  154.         get_user_origin(id, g_pos[id])
  155.         g_time[id] = 0
  156.     }
  157. }
  158.  
  159. public event_bomb_drop() {
  160.     g_spawn = false
  161.     g_planting = false
  162.     g_carrier = 0
  163. }
  164.  
  165. public logevent_round_start() {
  166.     new id[32], num
  167.     get_players(id, num, "ae", TEAM)
  168.  
  169.     if (!num) // is server empty?
  170.         return
  171.  
  172.     g_freezetime = false
  173.  
  174.     // update afk timers and current positions
  175.     new x
  176.     for (new i = 0; i < num; ++i) {
  177.         x = id[i]
  178.         get_user_origin(x, g_pos[x])
  179.         g_time[x] = 0
  180.     }
  181. }
  182.  
  183. public task_afk_check() {
  184.     if (g_freezetime) // is freezetime right now?
  185.         return
  186.  
  187.     // afk check
  188.     new id[32], num, x, origin[3]
  189.     get_players(id, num, "ae", TEAM)
  190.     for (new i = 0; i < num; ++i) {
  191.         x = id[i]
  192.         get_user_origin(x, origin)
  193.         if (origin[0] != g_pos[x][0] || origin[1] != g_pos[x][1] || (x == g_carrier && g_planting)) {
  194.             g_time[x] = 0
  195.             g_pos[x][0] = origin[0]
  196.             g_pos[x][1] = origin[1]
  197.             if (g_spawn && x == g_carrier)
  198.                 g_spawn = false
  199.         }
  200.         else
  201.             g_time[x]++
  202.     }
  203.  
  204.     // is bomb not currently carried or Ts number less than 2?
  205.     if (!g_carrier || num < 2)
  206.         return
  207.  
  208. #if defined CVAR_POINTERS
  209.     new max_time = get_pcvar_num(g_spawn ? g_pcvar_spawn : g_pcvar_time)
  210. #else
  211.     new max_time = get_cvar_num(g_spawn ? CVAR_SPAWN : CVAR_TIME)
  212. #endif
  213.  
  214.     // is plugin disabled (cvar <= 0) or carrier isn't afk?
  215.     if (max_time <= 0 || g_time[g_carrier] < max_time)
  216.         return
  217.  
  218.     // find who from non-afk Ts is the closest to the afk carrier
  219.     get_user_origin(g_carrier, origin)
  220.     new min_dist = 999999, dist, recipient, origin2[3]
  221.     for (new i = 0; i < num; ++i) {
  222.         x = id[i]
  223.         if (g_time[x] < max_time) {
  224.             get_user_origin(x, origin2)
  225.             dist = get_distance(origin, origin2)
  226.             if (dist < min_dist) {
  227.                 min_dist = dist
  228.                 recipient = x
  229.             }
  230.         }
  231.     }
  232.  
  233.     if (!recipient) // is all Ts afk?
  234.         return
  235.  
  236.     new carrier = g_carrier
  237.     engclient_cmd(carrier, "drop", WEAPON) // drop the backpack
  238.     new c4 = engfunc(EngFunc_FindEntityByString, -1, "classname", WEAPON) // find weapon_c4 entity
  239.     if (!c4)
  240.         return
  241.  
  242.     new backpack = pev(c4, pev_owner) // get backpack entity
  243.     if (backpack <= g_maxplayers)
  244.         return
  245.  
  246.     // my backpack transfer trick (improved)
  247.     set_pev(backpack, pev_flags, pev(backpack, pev_flags) | FL_ONGROUND)
  248.     dllfunc(DLLFunc_Touch, backpack, recipient)
  249.  
  250.     // hud messages stuff below
  251.     set_hudmessage(0, 255, 0, 0.35, 0.8, _, _, MSG_TIME)
  252.     new message[128], c_name[32], r_name[32]
  253.     get_user_name(carrier, c_name, 31)
  254.     get_user_name(recipient, r_name, 31)
  255.     format(message, 127, "A bombat att adtak ^"%s^"^n-nek mert ^"%s^" AFKzik!", r_name, c_name)
  256.     for (new i = 0; i < num; ++i)
  257.         show_hudmessage(id[i], "%s", message)
  258.  
  259.     set_hudmessage(255, 255, 0, 0.42, 0.3, _, _, MSG_TIME, _, _, 3)
  260.     show_hudmessage(recipient, "Meg kaptad a Bombat!")
  261. }
  262.  
  263. /* **************************************************** EOF **************************************************** */

Előre is köszönöm!

_________________
2021.03.01-re rem. készen lesz az új SNIPER szerverem RENGETEG egyedi dologgal megfűszerezve.
De nem lövök le előre semmit :)


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.17. 10:59 
Offline
Senior Tag
Avatar

Csatlakozott: 2019.11.03. 22:00
Hozzászólások: 282
Megköszönt másnak: 29 alkalommal
Megköszönték neki: 13 alkalommal
Helló Teszteld

  1. /* AMX Mod X
  2. *   AFK Bomb Transfer
  3. *
  4. * (c) Copyright 2006 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION
  9. *       Plugin allow transfer bomb from AFK terrorist to closest non-AFK teammate.
  10. *       Plugin will have no effect:
  11. *         - at the freezetime
  12. *         - if bomb is planting
  13. *         - on non-bomb maps (comment #define BOMB_MAP_CHECK to suppress)
  14. *
  15. *     MODULES
  16. *       fakemeta
  17. *
  18. *     CVARS
  19. *       afk_bombtransfer_spawn (N: seconds, default: 7) - max. allowed bomb carrier AFK time
  20. *         affects on spawned AFK bomb carrier which never moved after spawn
  21. *
  22. *       afk_bombtransfer_time (N: seconds, default: 15) - max. allowed bomb carrier AFK time
  23. *         affects on any AFK bomb carrier except one which obey previous CVAR
  24. *
  25. *     HUD MESSAGES
  26. *       Terrorist team (green color)
  27. *         Bomb transferred to "NEW_CARRIER_NAME"
  28. *         since "AFK_CARRIER_NAME" is AFK
  29. *
  30. *       New bomb carrier (yellow color)
  31. *         You got the bomb!
  32. *
  33. *       Note: by defult message display time is 7 seconds (define MSG_TIME)
  34. *
  35. *     VERSIONS
  36. *       0.4   backpack transfer method greatly improved
  37. *             added pcvar natives support (backward compatibility saved)
  38. *             few code optimization
  39. *       0.3   now fakemeta instead of engine required (efficiency++ if engine is disabled)
  40. *             "non-bomb map" check can be disabled (//#define BOMB_MAP_CHECK)
  41. *             backpack finding method improved
  42. *             few code optimization
  43. *             added comments to the plugin source code
  44. *       0.2   fixed format issue
  45. *             code optimized
  46. *             description improved
  47. *
  48. *       0.1   first release
  49. */
  50.  
  51. /* *************************************************** Init **************************************************** */
  52.  
  53. #include <amxmodx>
  54. #include <fakemeta>
  55. #include <colorchat>
  56.  
  57. // plugin's main information
  58. #define PLUGIN_NAME "AFK Bomb Transfer"
  59. #define PLUGIN_VERSION "0.4"
  60. #define PLUGIN_AUTHOR "VEN"
  61.  
  62. // comment to avoid autodisabling the plugin on maps which not contain bomb targets
  63. #define BOMB_MAP_CHECK
  64.  
  65. // float value, hud messages display time (in seconds)
  66. #define MSG_TIME 7.0
  67.  
  68. // CVAR name, affects on spawned AFK bomb carrier which never moved after spawn
  69. new CVAR_SPAWN[] = "afk_bombtransfer_spawn"
  70.  
  71. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  72. new DEFAULT_SPAWN[] = "7"
  73.  
  74. // CVAR name, affects on any AFK bomb carrier except one which obey previous CVAR
  75. new CVAR_TIME[] = "afk_bombtransfer_time"
  76.  
  77. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  78. new DEFAULT_TIME[] = "15"
  79.  
  80. // do not set this value less than "maxplayers"
  81. #define MAX_PLAYERS 32
  82.  
  83. // initial AMXX version number supported CVAR pointers in get/set_pcvar_* natives
  84. #define CVAR_POINTERS_AMXX_INIT_VER_NUM 170
  85.  
  86. // determine if get/set_pcvar_* natives can be used
  87. #if defined AMXX_VERSION_NUM && AMXX_VERSION_NUM >= CVAR_POINTERS_AMXX_INIT_VER_NUM
  88.     #define CVAR_POINTERS
  89.     new g_pcvar_spawn
  90.     new g_pcvar_time
  91. #endif
  92.  
  93. new TEAM[] = "TERRORIST"
  94. new WEAPON[] = "weapon_c4"
  95.  
  96. #define FL_ONGROUND (1<<9)
  97.  
  98. new bool:g_freezetime = true
  99. new bool:g_spawn
  100. new bool:g_planting
  101.  
  102. new g_carrier
  103.  
  104. new g_pos[MAX_PLAYERS + 1][3]
  105. new g_time[MAX_PLAYERS + 1]
  106.  
  107. new g_maxplayers
  108.  
  109. public plugin_init() {
  110.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  111.  
  112. #if defined CVAR_POINTERS
  113.     g_pcvar_spawn = register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  114.     g_pcvar_time = register_cvar(CVAR_TIME, DEFAULT_TIME)
  115. #else
  116.     register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  117.     register_cvar(CVAR_TIME, DEFAULT_TIME)
  118. #endif
  119.  
  120. #if defined BOMB_MAP_CHECK
  121.     // is current map not contain bomb targets?
  122.     if (!engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target"))
  123.         return
  124. #endif
  125.  
  126.     register_event("WeapPickup", "event_got_bomb", "be", "1=6")
  127.     register_event("BarTime", "event_bar_time", "be")
  128.     register_event("TextMsg", "event_bomb_drop", "bc", "2=#Game_bomb_drop")
  129.     register_event("TextMsg", "event_bomb_drop", "a", "2=#Bomb_Planted")
  130.     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
  131.  
  132.     register_logevent("logevent_round_start", 2, "1=Round_Start")
  133.  
  134.     set_task(1.0, "task_afk_check", _, _, _, "b") // plugin's core loop
  135.  
  136.     g_maxplayers = get_maxplayers()
  137. }
  138.  
  139. /* *************************************************** Base **************************************************** */
  140.  
  141. public event_new_round() {
  142.     g_freezetime = true
  143.     g_spawn = true
  144.     g_planting = false
  145.     g_carrier = 0
  146. }
  147.  
  148. public event_got_bomb(id) {
  149.     g_carrier = id
  150. }
  151.  
  152. public event_bar_time(id) {
  153.     if (id == g_carrier) {
  154.         g_planting = bool:read_data(1)
  155.         get_user_origin(id, g_pos[id])
  156.         g_time[id] = 0
  157.     }
  158. }
  159.  
  160. public event_bomb_drop() {
  161.     g_spawn = false
  162.     g_planting = false
  163.     g_carrier = 0
  164. }
  165.  
  166. public logevent_round_start() {
  167.     new id[32], num
  168.     get_players(id, num, "ae", TEAM)
  169.  
  170.     if (!num) // is server empty?
  171.         return
  172.  
  173.     g_freezetime = false
  174.  
  175.     // update afk timers and current positions
  176.     new x
  177.     for (new i = 0; i < num; ++i) {
  178.         x = id[i]
  179.         get_user_origin(x, g_pos[x])
  180.         g_time[x] = 0
  181.     }
  182. }
  183.  
  184. public task_afk_check() {
  185.     if (g_freezetime) // is freezetime right now?
  186.         return
  187.  
  188.     // afk check
  189.     new id[32], num, x, origin[3]
  190.     get_players(id, num, "ae", TEAM)
  191.     for (new i = 0; i < num; ++i) {
  192.         x = id[i]
  193.         get_user_origin(x, origin)
  194.         if (origin[0] != g_pos[x][0] || origin[1] != g_pos[x][1] || (x == g_carrier && g_planting)) {
  195.             g_time[x] = 0
  196.             g_pos[x][0] = origin[0]
  197.             g_pos[x][1] = origin[1]
  198.             if (g_spawn && x == g_carrier)
  199.                 g_spawn = false
  200.         }
  201.         else
  202.             g_time[x]++
  203.     }
  204.  
  205.     // is bomb not currently carried or Ts number less than 2?
  206.     if (!g_carrier || num < 2)
  207.         return
  208.  
  209. #if defined CVAR_POINTERS
  210.     new max_time = get_pcvar_num(g_spawn ? g_pcvar_spawn : g_pcvar_time)
  211. #else
  212.     new max_time = get_cvar_num(g_spawn ? CVAR_SPAWN : CVAR_TIME)
  213. #endif
  214.  
  215.     // is plugin disabled (cvar <= 0) or carrier isn't afk?
  216.     if (max_time <= 0 || g_time[g_carrier] < max_time)
  217.         return
  218.  
  219.     // find who from non-afk Ts is the closest to the afk carrier
  220.     get_user_origin(g_carrier, origin)
  221.     new min_dist = 999999, dist, recipient, origin2[3]
  222.     for (new i = 0; i < num; ++i) {
  223.         x = id[i]
  224.         if (g_time[x] < max_time) {
  225.             get_user_origin(x, origin2)
  226.             dist = get_distance(origin, origin2)
  227.             if (dist < min_dist) {
  228.                 min_dist = dist
  229.                 recipient = x
  230.             }
  231.         }
  232.     }
  233.  
  234.     if (!recipient) // is all Ts afk?
  235.         return
  236.  
  237.     new carrier = g_carrier
  238.     engclient_cmd(carrier, "drop", WEAPON) // drop the backpack
  239.     new c4 = engfunc(EngFunc_FindEntityByString, -1, "classname", WEAPON) // find weapon_c4 entity
  240.     if (!c4)
  241.         return
  242.  
  243.     new backpack = pev(c4, pev_owner) // get backpack entity
  244.     if (backpack <= g_maxplayers)
  245.         return
  246.  
  247.     // my backpack transfer trick (improved)
  248.     set_pev(backpack, pev_flags, pev(backpack, pev_flags) | FL_ONGROUND)
  249.     dllfunc(DLLFunc_Touch, backpack, recipient)
  250.  
  251.     // hud messages stuff below
  252.     set_hudmessage(0, 255, 0, 0.35, 0.8, _, _, MSG_TIME)
  253.     new message[128], c_name[32], r_name[32]
  254.     get_user_name(carrier, c_name, 31)
  255.     get_user_name(recipient, r_name, 31)
  256.     format(message, 127, "A bombat att adtak ^"%s^"^n-nek mert ^"%s^" AFKzik!", r_name, c_name)
  257.     for (new i = 0; i < num; ++i)
  258.         show_hudmessage(id[i], "%s", message)
  259.  
  260.     set_hudmessage(255, 255, 0, 0.42, 0.3, _, _, MSG_TIME, _, _, 3)
  261.     //show_hudmessage(recipient, "Meg kaptad a Bombat!")
  262.    ColorChat(0, GREEN, "Megkaptad a Bombát")
  263. }
  264.  
  265. /* **************************************************** EOF **************************************************** */

_________________
Nem elèg hètvègen a templomba a padot koptatni. Embernek kène maradni!
Nem sokat számít valaki hívő-e vagy sem.
Sokkal fontosabb, hogy jó ember legyen

Ők köszönték meg Csabika20034 nek ezt a hozzászólást: ZiT3K (2021.02.17. 11:08)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.17. 11:58 
Offline
Jómunkásember
Avatar

Csatlakozott: 2016.02.10. 12:46
Hozzászólások: 395
Megköszönt másnak: 52 alkalommal
Megköszönték neki: 139 alkalommal
Csabika20034 írta:
Helló Teszteld

  1. /* AMX Mod X
  2. *   AFK Bomb Transfer
  3. *
  4. * (c) Copyright 2006 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION
  9. *       Plugin allow transfer bomb from AFK terrorist to closest non-AFK teammate.
  10. *       Plugin will have no effect:
  11. *         - at the freezetime
  12. *         - if bomb is planting
  13. *         - on non-bomb maps (comment #define BOMB_MAP_CHECK to suppress)
  14. *
  15. *     MODULES
  16. *       fakemeta
  17. *
  18. *     CVARS
  19. *       afk_bombtransfer_spawn (N: seconds, default: 7) - max. allowed bomb carrier AFK time
  20. *         affects on spawned AFK bomb carrier which never moved after spawn
  21. *
  22. *       afk_bombtransfer_time (N: seconds, default: 15) - max. allowed bomb carrier AFK time
  23. *         affects on any AFK bomb carrier except one which obey previous CVAR
  24. *
  25. *     HUD MESSAGES
  26. *       Terrorist team (green color)
  27. *         Bomb transferred to "NEW_CARRIER_NAME"
  28. *         since "AFK_CARRIER_NAME" is AFK
  29. *
  30. *       New bomb carrier (yellow color)
  31. *         You got the bomb!
  32. *
  33. *       Note: by defult message display time is 7 seconds (define MSG_TIME)
  34. *
  35. *     VERSIONS
  36. *       0.4   backpack transfer method greatly improved
  37. *             added pcvar natives support (backward compatibility saved)
  38. *             few code optimization
  39. *       0.3   now fakemeta instead of engine required (efficiency++ if engine is disabled)
  40. *             "non-bomb map" check can be disabled (//#define BOMB_MAP_CHECK)
  41. *             backpack finding method improved
  42. *             few code optimization
  43. *             added comments to the plugin source code
  44. *       0.2   fixed format issue
  45. *             code optimized
  46. *             description improved
  47. *
  48. *       0.1   first release
  49. */
  50.  
  51. /* *************************************************** Init **************************************************** */
  52.  
  53. #include <amxmodx>
  54. #include <fakemeta>
  55. #include <colorchat>
  56.  
  57. // plugin's main information
  58. #define PLUGIN_NAME "AFK Bomb Transfer"
  59. #define PLUGIN_VERSION "0.4"
  60. #define PLUGIN_AUTHOR "VEN"
  61.  
  62. // comment to avoid autodisabling the plugin on maps which not contain bomb targets
  63. #define BOMB_MAP_CHECK
  64.  
  65. // float value, hud messages display time (in seconds)
  66. #define MSG_TIME 7.0
  67.  
  68. // CVAR name, affects on spawned AFK bomb carrier which never moved after spawn
  69. new CVAR_SPAWN[] = "afk_bombtransfer_spawn"
  70.  
  71. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  72. new DEFAULT_SPAWN[] = "7"
  73.  
  74. // CVAR name, affects on any AFK bomb carrier except one which obey previous CVAR
  75. new CVAR_TIME[] = "afk_bombtransfer_time"
  76.  
  77. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  78. new DEFAULT_TIME[] = "15"
  79.  
  80. // do not set this value less than "maxplayers"
  81. #define MAX_PLAYERS 32
  82.  
  83. // initial AMXX version number supported CVAR pointers in get/set_pcvar_* natives
  84. #define CVAR_POINTERS_AMXX_INIT_VER_NUM 170
  85.  
  86. // determine if get/set_pcvar_* natives can be used
  87. #if defined AMXX_VERSION_NUM && AMXX_VERSION_NUM >= CVAR_POINTERS_AMXX_INIT_VER_NUM
  88.     #define CVAR_POINTERS
  89.     new g_pcvar_spawn
  90.     new g_pcvar_time
  91. #endif
  92.  
  93. new TEAM[] = "TERRORIST"
  94. new WEAPON[] = "weapon_c4"
  95.  
  96. #define FL_ONGROUND (1<<9)
  97.  
  98. new bool:g_freezetime = true
  99. new bool:g_spawn
  100. new bool:g_planting
  101.  
  102. new g_carrier
  103.  
  104. new g_pos[MAX_PLAYERS + 1][3]
  105. new g_time[MAX_PLAYERS + 1]
  106.  
  107. new g_maxplayers
  108.  
  109. public plugin_init() {
  110.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  111.  
  112. #if defined CVAR_POINTERS
  113.     g_pcvar_spawn = register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  114.     g_pcvar_time = register_cvar(CVAR_TIME, DEFAULT_TIME)
  115. #else
  116.     register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  117.     register_cvar(CVAR_TIME, DEFAULT_TIME)
  118. #endif
  119.  
  120. #if defined BOMB_MAP_CHECK
  121.     // is current map not contain bomb targets?
  122.     if (!engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target"))
  123.         return
  124. #endif
  125.  
  126.     register_event("WeapPickup", "event_got_bomb", "be", "1=6")
  127.     register_event("BarTime", "event_bar_time", "be")
  128.     register_event("TextMsg", "event_bomb_drop", "bc", "2=#Game_bomb_drop")
  129.     register_event("TextMsg", "event_bomb_drop", "a", "2=#Bomb_Planted")
  130.     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
  131.  
  132.     register_logevent("logevent_round_start", 2, "1=Round_Start")
  133.  
  134.     set_task(1.0, "task_afk_check", _, _, _, "b") // plugin's core loop
  135.  
  136.     g_maxplayers = get_maxplayers()
  137. }
  138.  
  139. /* *************************************************** Base **************************************************** */
  140.  
  141. public event_new_round() {
  142.     g_freezetime = true
  143.     g_spawn = true
  144.     g_planting = false
  145.     g_carrier = 0
  146. }
  147.  
  148. public event_got_bomb(id) {
  149.     g_carrier = id
  150. }
  151.  
  152. public event_bar_time(id) {
  153.     if (id == g_carrier) {
  154.         g_planting = bool:read_data(1)
  155.         get_user_origin(id, g_pos[id])
  156.         g_time[id] = 0
  157.     }
  158. }
  159.  
  160. public event_bomb_drop() {
  161.     g_spawn = false
  162.     g_planting = false
  163.     g_carrier = 0
  164. }
  165.  
  166. public logevent_round_start() {
  167.     new id[32], num
  168.     get_players(id, num, "ae", TEAM)
  169.  
  170.     if (!num) // is server empty?
  171.         return
  172.  
  173.     g_freezetime = false
  174.  
  175.     // update afk timers and current positions
  176.     new x
  177.     for (new i = 0; i < num; ++i) {
  178.         x = id[i]
  179.         get_user_origin(x, g_pos[x])
  180.         g_time[x] = 0
  181.     }
  182. }
  183.  
  184. public task_afk_check() {
  185.     if (g_freezetime) // is freezetime right now?
  186.         return
  187.  
  188.     // afk check
  189.     new id[32], num, x, origin[3]
  190.     get_players(id, num, "ae", TEAM)
  191.     for (new i = 0; i < num; ++i) {
  192.         x = id[i]
  193.         get_user_origin(x, origin)
  194.         if (origin[0] != g_pos[x][0] || origin[1] != g_pos[x][1] || (x == g_carrier && g_planting)) {
  195.             g_time[x] = 0
  196.             g_pos[x][0] = origin[0]
  197.             g_pos[x][1] = origin[1]
  198.             if (g_spawn && x == g_carrier)
  199.                 g_spawn = false
  200.         }
  201.         else
  202.             g_time[x]++
  203.     }
  204.  
  205.     // is bomb not currently carried or Ts number less than 2?
  206.     if (!g_carrier || num < 2)
  207.         return
  208.  
  209. #if defined CVAR_POINTERS
  210.     new max_time = get_pcvar_num(g_spawn ? g_pcvar_spawn : g_pcvar_time)
  211. #else
  212.     new max_time = get_cvar_num(g_spawn ? CVAR_SPAWN : CVAR_TIME)
  213. #endif
  214.  
  215.     // is plugin disabled (cvar <= 0) or carrier isn't afk?
  216.     if (max_time <= 0 || g_time[g_carrier] < max_time)
  217.         return
  218.  
  219.     // find who from non-afk Ts is the closest to the afk carrier
  220.     get_user_origin(g_carrier, origin)
  221.     new min_dist = 999999, dist, recipient, origin2[3]
  222.     for (new i = 0; i < num; ++i) {
  223.         x = id[i]
  224.         if (g_time[x] < max_time) {
  225.             get_user_origin(x, origin2)
  226.             dist = get_distance(origin, origin2)
  227.             if (dist < min_dist) {
  228.                 min_dist = dist
  229.                 recipient = x
  230.             }
  231.         }
  232.     }
  233.  
  234.     if (!recipient) // is all Ts afk?
  235.         return
  236.  
  237.     new carrier = g_carrier
  238.     engclient_cmd(carrier, "drop", WEAPON) // drop the backpack
  239.     new c4 = engfunc(EngFunc_FindEntityByString, -1, "classname", WEAPON) // find weapon_c4 entity
  240.     if (!c4)
  241.         return
  242.  
  243.     new backpack = pev(c4, pev_owner) // get backpack entity
  244.     if (backpack <= g_maxplayers)
  245.         return
  246.  
  247.     // my backpack transfer trick (improved)
  248.     set_pev(backpack, pev_flags, pev(backpack, pev_flags) | FL_ONGROUND)
  249.     dllfunc(DLLFunc_Touch, backpack, recipient)
  250.  
  251.     // hud messages stuff below
  252.     set_hudmessage(0, 255, 0, 0.35, 0.8, _, _, MSG_TIME)
  253.     new message[128], c_name[32], r_name[32]
  254.     get_user_name(carrier, c_name, 31)
  255.     get_user_name(recipient, r_name, 31)
  256.     format(message, 127, "A bombat att adtak ^"%s^"^n-nek mert ^"%s^" AFKzik!", r_name, c_name)
  257.     for (new i = 0; i < num; ++i)
  258.         show_hudmessage(id[i], "%s", message)
  259.  
  260.     set_hudmessage(255, 255, 0, 0.42, 0.3, _, _, MSG_TIME, _, _, 3)
  261.     //show_hudmessage(recipient, "Meg kaptad a Bombat!")
  262.    ColorChat(0, GREEN, "Megkaptad a Bombát")
  263. }
  264.  
  265. /* **************************************************** EOF **************************************************** */


Ha kikommentelted a show_hudmessage-t, akkor a felette levőt miért nem vetted ki? A set_hudmessage-re értem.. próbáljuk kerülni az ilyeneket, mert feleslegesen van ott és más hibákhoz is vezethet.
Illetve kihagytad a recipient változót a ColorChatnél, így most mindenkinek kiírja, hogy "Megkaptad a Bombát".

  1. ColorChat(0, GREEN, "Megkaptad a Bombát")

--->

  1. ColorChat(recipient, GREEN, "Megkaptad a Bombát")

_________________
We are the walking dead..
Kép

Ők köszönték meg Dooz nek ezt a hozzászólást: ZiT3K (2021.02.17. 12:16)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.17. 12:17 
Offline
Jómunkásember
Avatar

Csatlakozott: 2013.12.15. 19:13
Hozzászólások: 419
Megköszönt másnak: 212 alkalommal
Megköszönték neki: 13 alkalommal
Ezek javításával akkor szeretnék kérni egy SMA-t, köszönöm.

_________________
2021.03.01-re rem. készen lesz az új SNIPER szerverem RENGETEG egyedi dologgal megfűszerezve.
De nem lövök le előre semmit :)


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.17. 13:01 
Offline
Senior Tag
Avatar

Csatlakozott: 2019.11.03. 22:00
Hozzászólások: 282
Megköszönt másnak: 29 alkalommal
Megköszönték neki: 13 alkalommal
  1. /* AMX Mod X
  2. *   AFK Bomb Transfer
  3. *
  4. * (c) Copyright 2006 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION
  9. *       Plugin allow transfer bomb from AFK terrorist to closest non-AFK teammate.
  10. *       Plugin will have no effect:
  11. *         - at the freezetime
  12. *         - if bomb is planting
  13. *         - on non-bomb maps (comment #define BOMB_MAP_CHECK to suppress)
  14. *
  15. *     MODULES
  16. *       fakemeta
  17. *
  18. *     CVARS
  19. *       afk_bombtransfer_spawn (N: seconds, default: 7) - max. allowed bomb carrier AFK time
  20. *         affects on spawned AFK bomb carrier which never moved after spawn
  21. *
  22. *       afk_bombtransfer_time (N: seconds, default: 15) - max. allowed bomb carrier AFK time
  23. *         affects on any AFK bomb carrier except one which obey previous CVAR
  24. *
  25. *     HUD MESSAGES
  26. *       Terrorist team (green color)
  27. *         Bomb transferred to "NEW_CARRIER_NAME"
  28. *         since "AFK_CARRIER_NAME" is AFK
  29. *
  30. *       New bomb carrier (yellow color)
  31. *         You got the bomb!
  32. *
  33. *       Note: by defult message display time is 7 seconds (define MSG_TIME)
  34. *
  35. *     VERSIONS
  36. *       0.4   backpack transfer method greatly improved
  37. *             added pcvar natives support (backward compatibility saved)
  38. *             few code optimization
  39. *       0.3   now fakemeta instead of engine required (efficiency++ if engine is disabled)
  40. *             "non-bomb map" check can be disabled (//#define BOMB_MAP_CHECK)
  41. *             backpack finding method improved
  42. *             few code optimization
  43. *             added comments to the plugin source code
  44. *       0.2   fixed format issue
  45. *             code optimized
  46. *             description improved
  47. *
  48. *       0.1   first release
  49. */
  50.  
  51. /* *************************************************** Init **************************************************** */
  52.  
  53. #include <amxmodx>
  54. #include <fakemeta>
  55. #include <colorchat>
  56.  
  57. // plugin's main information
  58. #define PLUGIN_NAME "AFK Bomb Transfer"
  59. #define PLUGIN_VERSION "0.4"
  60. #define PLUGIN_AUTHOR "VEN"
  61.  
  62. // comment to avoid autodisabling the plugin on maps which not contain bomb targets
  63. #define BOMB_MAP_CHECK
  64.  
  65. // float value, hud messages display time (in seconds)
  66. #define MSG_TIME 7.0
  67.  
  68. // CVAR name, affects on spawned AFK bomb carrier which never moved after spawn
  69. new CVAR_SPAWN[] = "afk_bombtransfer_spawn"
  70.  
  71. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  72. new DEFAULT_SPAWN[] = "7"
  73.  
  74. // CVAR name, affects on any AFK bomb carrier except one which obey previous CVAR
  75. new CVAR_TIME[] = "afk_bombtransfer_time"
  76.  
  77. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  78. new DEFAULT_TIME[] = "15"
  79.  
  80. // do not set this value less than "maxplayers"
  81. #define MAX_PLAYERS 32
  82.  
  83. // initial AMXX version number supported CVAR pointers in get/set_pcvar_* natives
  84. #define CVAR_POINTERS_AMXX_INIT_VER_NUM 170
  85.  
  86. // determine if get/set_pcvar_* natives can be used
  87. #if defined AMXX_VERSION_NUM && AMXX_VERSION_NUM >= CVAR_POINTERS_AMXX_INIT_VER_NUM
  88.     #define CVAR_POINTERS
  89.     new g_pcvar_spawn
  90.     new g_pcvar_time
  91. #endif
  92.  
  93. new TEAM[] = "TERRORIST"
  94. new WEAPON[] = "weapon_c4"
  95.  
  96. #define FL_ONGROUND (1<<9)
  97.  
  98. new bool:g_freezetime = true
  99. new bool:g_spawn
  100. new bool:g_planting
  101.  
  102. new g_carrier
  103.  
  104. new g_pos[MAX_PLAYERS + 1][3]
  105. new g_time[MAX_PLAYERS + 1]
  106.  
  107. new g_maxplayers
  108.  
  109. public plugin_init() {
  110.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  111.  
  112. #if defined CVAR_POINTERS
  113.     g_pcvar_spawn = register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  114.     g_pcvar_time = register_cvar(CVAR_TIME, DEFAULT_TIME)
  115. #else
  116.     register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  117.     register_cvar(CVAR_TIME, DEFAULT_TIME)
  118. #endif
  119.  
  120. #if defined BOMB_MAP_CHECK
  121.     // is current map not contain bomb targets?
  122.     if (!engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target"))
  123.         return
  124. #endif
  125.  
  126.     register_event("WeapPickup", "event_got_bomb", "be", "1=6")
  127.     register_event("BarTime", "event_bar_time", "be")
  128.     register_event("TextMsg", "event_bomb_drop", "bc", "2=#Game_bomb_drop")
  129.     register_event("TextMsg", "event_bomb_drop", "a", "2=#Bomb_Planted")
  130.     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
  131.  
  132.     register_logevent("logevent_round_start", 2, "1=Round_Start")
  133.  
  134.     set_task(1.0, "task_afk_check", _, _, _, "b") // plugin's core loop
  135.  
  136.     g_maxplayers = get_maxplayers()
  137. }
  138.  
  139. /* *************************************************** Base **************************************************** */
  140.  
  141. public event_new_round() {
  142.     g_freezetime = true
  143.     g_spawn = true
  144.     g_planting = false
  145.     g_carrier = 0
  146. }
  147.  
  148. public event_got_bomb(id) {
  149.     g_carrier = id
  150. }
  151.  
  152. public event_bar_time(id) {
  153.     if (id == g_carrier) {
  154.         g_planting = bool:read_data(1)
  155.         get_user_origin(id, g_pos[id])
  156.         g_time[id] = 0
  157.     }
  158. }
  159.  
  160. public event_bomb_drop() {
  161.     g_spawn = false
  162.     g_planting = false
  163.     g_carrier = 0
  164. }
  165.  
  166. public logevent_round_start() {
  167.     new id[32], num
  168.     get_players(id, num, "ae", TEAM)
  169.  
  170.     if (!num) // is server empty?
  171.         return
  172.  
  173.     g_freezetime = false
  174.  
  175.     // update afk timers and current positions
  176.     new x
  177.     for (new i = 0; i < num; ++i) {
  178.         x = id[i]
  179.         get_user_origin(x, g_pos[x])
  180.         g_time[x] = 0
  181.     }
  182. }
  183.  
  184. public task_afk_check() {
  185.     if (g_freezetime) // is freezetime right now?
  186.         return
  187.  
  188.     // afk check
  189.     new id[32], num, x, origin[3]
  190.     get_players(id, num, "ae", TEAM)
  191.     for (new i = 0; i < num; ++i) {
  192.         x = id[i]
  193.         get_user_origin(x, origin)
  194.         if (origin[0] != g_pos[x][0] || origin[1] != g_pos[x][1] || (x == g_carrier && g_planting)) {
  195.             g_time[x] = 0
  196.             g_pos[x][0] = origin[0]
  197.             g_pos[x][1] = origin[1]
  198.             if (g_spawn && x == g_carrier)
  199.                 g_spawn = false
  200.         }
  201.         else
  202.             g_time[x]++
  203.     }
  204.  
  205.     // is bomb not currently carried or Ts number less than 2?
  206.     if (!g_carrier || num < 2)
  207.         return
  208.  
  209. #if defined CVAR_POINTERS
  210.     new max_time = get_pcvar_num(g_spawn ? g_pcvar_spawn : g_pcvar_time)
  211. #else
  212.     new max_time = get_cvar_num(g_spawn ? CVAR_SPAWN : CVAR_TIME)
  213. #endif
  214.  
  215.     // is plugin disabled (cvar <= 0) or carrier isn't afk?
  216.     if (max_time <= 0 || g_time[g_carrier] < max_time)
  217.         return
  218.  
  219.     // find who from non-afk Ts is the closest to the afk carrier
  220.     get_user_origin(g_carrier, origin)
  221.     new min_dist = 999999, dist, recipient, origin2[3]
  222.     for (new i = 0; i < num; ++i) {
  223.         x = id[i]
  224.         if (g_time[x] < max_time) {
  225.             get_user_origin(x, origin2)
  226.             dist = get_distance(origin, origin2)
  227.             if (dist < min_dist) {
  228.                 min_dist = dist
  229.                 recipient = x
  230.             }
  231.         }
  232.     }
  233.  
  234.     if (!recipient) // is all Ts afk?
  235.         return
  236.  
  237.     new carrier = g_carrier
  238.     engclient_cmd(carrier, "drop", WEAPON) // drop the backpack
  239.     new c4 = engfunc(EngFunc_FindEntityByString, -1, "classname", WEAPON) // find weapon_c4 entity
  240.     if (!c4)
  241.         return
  242.  
  243.     new backpack = pev(c4, pev_owner) // get backpack entity
  244.     if (backpack <= g_maxplayers)
  245.         return
  246.  
  247.     // my backpack transfer trick (improved)
  248.     set_pev(backpack, pev_flags, pev(backpack, pev_flags) | FL_ONGROUND)
  249.     dllfunc(DLLFunc_Touch, backpack, recipient)
  250.  
  251.     // hud messages stuff below
  252.     set_hudmessage(0, 255, 0, 0.35, 0.8, _, _, MSG_TIME)
  253.     new message[128], c_name[32], r_name[32]
  254.     get_user_name(carrier, c_name, 31)
  255.     get_user_name(recipient, r_name, 31)
  256.     format(message, 127, "A bombat att adtak ^"%s^"^n-nek mert ^"%s^" AFKzik!", r_name, c_name)
  257.     for (new i = 0; i < num; ++i)
  258.         show_hudmessage(id[i], "%s", message)
  259.  
  260.     set_hudmessage(255, 255, 0, 0.42, 0.3, _, _, MSG_TIME, _, _, 3)
  261.     //show_hudmessage(recipient, "Meg kaptad a Bombat!")
  262.    ColorChat(recipient, GREEN, "Megkaptad a Bombát")
  263. }
  264.  
  265. /* **************************************************** EOF **************************************************** */

_________________
Nem elèg hètvègen a templomba a padot koptatni. Embernek kène maradni!
Nem sokat számít valaki hívő-e vagy sem.
Sokkal fontosabb, hogy jó ember legyen

Ők köszönték meg Csabika20034 nek ezt a hozzászólást: ZiT3K (2021.02.17. 13:03)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.17. 13:04 
Offline
Jómunkásember
Avatar

Csatlakozott: 2013.12.15. 19:13
Hozzászólások: 419
Megköszönt másnak: 212 alkalommal
Megköszönték neki: 13 alkalommal
Később fogom tesztelni, de frissítem majd ezt a hozzászólást.

_________________
2021.03.01-re rem. készen lesz az új SNIPER szerverem RENGETEG egyedi dologgal megfűszerezve.
De nem lövök le előre semmit :)


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.17. 14:01 
Offline
Jómunkásember
Avatar

Csatlakozott: 2016.02.10. 12:46
Hozzászólások: 395
Megköszönt másnak: 52 alkalommal
Megköszönték neki: 139 alkalommal
Csabika20034 írta:
  1. /* AMX Mod X
  2. *   AFK Bomb Transfer
  3. *
  4. * (c) Copyright 2006 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION
  9. *       Plugin allow transfer bomb from AFK terrorist to closest non-AFK teammate.
  10. *       Plugin will have no effect:
  11. *         - at the freezetime
  12. *         - if bomb is planting
  13. *         - on non-bomb maps (comment #define BOMB_MAP_CHECK to suppress)
  14. *
  15. *     MODULES
  16. *       fakemeta
  17. *
  18. *     CVARS
  19. *       afk_bombtransfer_spawn (N: seconds, default: 7) - max. allowed bomb carrier AFK time
  20. *         affects on spawned AFK bomb carrier which never moved after spawn
  21. *
  22. *       afk_bombtransfer_time (N: seconds, default: 15) - max. allowed bomb carrier AFK time
  23. *         affects on any AFK bomb carrier except one which obey previous CVAR
  24. *
  25. *     HUD MESSAGES
  26. *       Terrorist team (green color)
  27. *         Bomb transferred to "NEW_CARRIER_NAME"
  28. *         since "AFK_CARRIER_NAME" is AFK
  29. *
  30. *       New bomb carrier (yellow color)
  31. *         You got the bomb!
  32. *
  33. *       Note: by defult message display time is 7 seconds (define MSG_TIME)
  34. *
  35. *     VERSIONS
  36. *       0.4   backpack transfer method greatly improved
  37. *             added pcvar natives support (backward compatibility saved)
  38. *             few code optimization
  39. *       0.3   now fakemeta instead of engine required (efficiency++ if engine is disabled)
  40. *             "non-bomb map" check can be disabled (//#define BOMB_MAP_CHECK)
  41. *             backpack finding method improved
  42. *             few code optimization
  43. *             added comments to the plugin source code
  44. *       0.2   fixed format issue
  45. *             code optimized
  46. *             description improved
  47. *
  48. *       0.1   first release
  49. */
  50.  
  51. /* *************************************************** Init **************************************************** */
  52.  
  53. #include <amxmodx>
  54. #include <fakemeta>
  55. #include <colorchat>
  56.  
  57. // plugin's main information
  58. #define PLUGIN_NAME "AFK Bomb Transfer"
  59. #define PLUGIN_VERSION "0.4"
  60. #define PLUGIN_AUTHOR "VEN"
  61.  
  62. // comment to avoid autodisabling the plugin on maps which not contain bomb targets
  63. #define BOMB_MAP_CHECK
  64.  
  65. // float value, hud messages display time (in seconds)
  66. #define MSG_TIME 7.0
  67.  
  68. // CVAR name, affects on spawned AFK bomb carrier which never moved after spawn
  69. new CVAR_SPAWN[] = "afk_bombtransfer_spawn"
  70.  
  71. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  72. new DEFAULT_SPAWN[] = "7"
  73.  
  74. // CVAR name, affects on any AFK bomb carrier except one which obey previous CVAR
  75. new CVAR_TIME[] = "afk_bombtransfer_time"
  76.  
  77. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  78. new DEFAULT_TIME[] = "15"
  79.  
  80. // do not set this value less than "maxplayers"
  81. #define MAX_PLAYERS 32
  82.  
  83. // initial AMXX version number supported CVAR pointers in get/set_pcvar_* natives
  84. #define CVAR_POINTERS_AMXX_INIT_VER_NUM 170
  85.  
  86. // determine if get/set_pcvar_* natives can be used
  87. #if defined AMXX_VERSION_NUM && AMXX_VERSION_NUM >= CVAR_POINTERS_AMXX_INIT_VER_NUM
  88.     #define CVAR_POINTERS
  89.     new g_pcvar_spawn
  90.     new g_pcvar_time
  91. #endif
  92.  
  93. new TEAM[] = "TERRORIST"
  94. new WEAPON[] = "weapon_c4"
  95.  
  96. #define FL_ONGROUND (1<<9)
  97.  
  98. new bool:g_freezetime = true
  99. new bool:g_spawn
  100. new bool:g_planting
  101.  
  102. new g_carrier
  103.  
  104. new g_pos[MAX_PLAYERS + 1][3]
  105. new g_time[MAX_PLAYERS + 1]
  106.  
  107. new g_maxplayers
  108.  
  109. public plugin_init() {
  110.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  111.  
  112. #if defined CVAR_POINTERS
  113.     g_pcvar_spawn = register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  114.     g_pcvar_time = register_cvar(CVAR_TIME, DEFAULT_TIME)
  115. #else
  116.     register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  117.     register_cvar(CVAR_TIME, DEFAULT_TIME)
  118. #endif
  119.  
  120. #if defined BOMB_MAP_CHECK
  121.     // is current map not contain bomb targets?
  122.     if (!engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target"))
  123.         return
  124. #endif
  125.  
  126.     register_event("WeapPickup", "event_got_bomb", "be", "1=6")
  127.     register_event("BarTime", "event_bar_time", "be")
  128.     register_event("TextMsg", "event_bomb_drop", "bc", "2=#Game_bomb_drop")
  129.     register_event("TextMsg", "event_bomb_drop", "a", "2=#Bomb_Planted")
  130.     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
  131.  
  132.     register_logevent("logevent_round_start", 2, "1=Round_Start")
  133.  
  134.     set_task(1.0, "task_afk_check", _, _, _, "b") // plugin's core loop
  135.  
  136.     g_maxplayers = get_maxplayers()
  137. }
  138.  
  139. /* *************************************************** Base **************************************************** */
  140.  
  141. public event_new_round() {
  142.     g_freezetime = true
  143.     g_spawn = true
  144.     g_planting = false
  145.     g_carrier = 0
  146. }
  147.  
  148. public event_got_bomb(id) {
  149.     g_carrier = id
  150. }
  151.  
  152. public event_bar_time(id) {
  153.     if (id == g_carrier) {
  154.         g_planting = bool:read_data(1)
  155.         get_user_origin(id, g_pos[id])
  156.         g_time[id] = 0
  157.     }
  158. }
  159.  
  160. public event_bomb_drop() {
  161.     g_spawn = false
  162.     g_planting = false
  163.     g_carrier = 0
  164. }
  165.  
  166. public logevent_round_start() {
  167.     new id[32], num
  168.     get_players(id, num, "ae", TEAM)
  169.  
  170.     if (!num) // is server empty?
  171.         return
  172.  
  173.     g_freezetime = false
  174.  
  175.     // update afk timers and current positions
  176.     new x
  177.     for (new i = 0; i < num; ++i) {
  178.         x = id[i]
  179.         get_user_origin(x, g_pos[x])
  180.         g_time[x] = 0
  181.     }
  182. }
  183.  
  184. public task_afk_check() {
  185.     if (g_freezetime) // is freezetime right now?
  186.         return
  187.  
  188.     // afk check
  189.     new id[32], num, x, origin[3]
  190.     get_players(id, num, "ae", TEAM)
  191.     for (new i = 0; i < num; ++i) {
  192.         x = id[i]
  193.         get_user_origin(x, origin)
  194.         if (origin[0] != g_pos[x][0] || origin[1] != g_pos[x][1] || (x == g_carrier && g_planting)) {
  195.             g_time[x] = 0
  196.             g_pos[x][0] = origin[0]
  197.             g_pos[x][1] = origin[1]
  198.             if (g_spawn && x == g_carrier)
  199.                 g_spawn = false
  200.         }
  201.         else
  202.             g_time[x]++
  203.     }
  204.  
  205.     // is bomb not currently carried or Ts number less than 2?
  206.     if (!g_carrier || num < 2)
  207.         return
  208.  
  209. #if defined CVAR_POINTERS
  210.     new max_time = get_pcvar_num(g_spawn ? g_pcvar_spawn : g_pcvar_time)
  211. #else
  212.     new max_time = get_cvar_num(g_spawn ? CVAR_SPAWN : CVAR_TIME)
  213. #endif
  214.  
  215.     // is plugin disabled (cvar <= 0) or carrier isn't afk?
  216.     if (max_time <= 0 || g_time[g_carrier] < max_time)
  217.         return
  218.  
  219.     // find who from non-afk Ts is the closest to the afk carrier
  220.     get_user_origin(g_carrier, origin)
  221.     new min_dist = 999999, dist, recipient, origin2[3]
  222.     for (new i = 0; i < num; ++i) {
  223.         x = id[i]
  224.         if (g_time[x] < max_time) {
  225.             get_user_origin(x, origin2)
  226.             dist = get_distance(origin, origin2)
  227.             if (dist < min_dist) {
  228.                 min_dist = dist
  229.                 recipient = x
  230.             }
  231.         }
  232.     }
  233.  
  234.     if (!recipient) // is all Ts afk?
  235.         return
  236.  
  237.     new carrier = g_carrier
  238.     engclient_cmd(carrier, "drop", WEAPON) // drop the backpack
  239.     new c4 = engfunc(EngFunc_FindEntityByString, -1, "classname", WEAPON) // find weapon_c4 entity
  240.     if (!c4)
  241.         return
  242.  
  243.     new backpack = pev(c4, pev_owner) // get backpack entity
  244.     if (backpack <= g_maxplayers)
  245.         return
  246.  
  247.     // my backpack transfer trick (improved)
  248.     set_pev(backpack, pev_flags, pev(backpack, pev_flags) | FL_ONGROUND)
  249.     dllfunc(DLLFunc_Touch, backpack, recipient)
  250.  
  251.     // hud messages stuff below
  252.     set_hudmessage(0, 255, 0, 0.35, 0.8, _, _, MSG_TIME)
  253.     new message[128], c_name[32], r_name[32]
  254.     get_user_name(carrier, c_name, 31)
  255.     get_user_name(recipient, r_name, 31)
  256.     format(message, 127, "A bombat att adtak ^"%s^"^n-nek mert ^"%s^" AFKzik!", r_name, c_name)
  257.     for (new i = 0; i < num; ++i)
  258.         show_hudmessage(id[i], "%s", message)
  259.  
  260.     set_hudmessage(255, 255, 0, 0.42, 0.3, _, _, MSG_TIME, _, _, 3)
  261.     //show_hudmessage(recipient, "Meg kaptad a Bombat!")
  262.    ColorChat(recipient, GREEN, "Megkaptad a Bombát")
  263. }
  264.  
  265. /* **************************************************** EOF **************************************************** */

Off Topic
Melyik része ebből nem volt érthető?

"Ha kikommentelted a show_hudmessage-t, akkor a felette levőt miért nem vetted ki? A set_hudmessage-re értem.. próbáljuk kerülni az ilyeneket, mert feleslegesen van ott és más hibákhoz is vezethet"


  1. /* AMX Mod X
  2. *   AFK Bomb Transfer
  3. *
  4. * (c) Copyright 2006 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION
  9. *       Plugin allow transfer bomb from AFK terrorist to closest non-AFK teammate.
  10. *       Plugin will have no effect:
  11. *         - at the freezetime
  12. *         - if bomb is planting
  13. *         - on non-bomb maps (comment #define BOMB_MAP_CHECK to suppress)
  14. *
  15. *     MODULES
  16. *       fakemeta
  17. *
  18. *     CVARS
  19. *       afk_bombtransfer_spawn (N: seconds, default: 7) - max. allowed bomb carrier AFK time
  20. *         affects on spawned AFK bomb carrier which never moved after spawn
  21. *
  22. *       afk_bombtransfer_time (N: seconds, default: 15) - max. allowed bomb carrier AFK time
  23. *         affects on any AFK bomb carrier except one which obey previous CVAR
  24. *
  25. *     HUD MESSAGES
  26. *       Terrorist team (green color)
  27. *         Bomb transferred to "NEW_CARRIER_NAME"
  28. *         since "AFK_CARRIER_NAME" is AFK
  29. *
  30. *       New bomb carrier (yellow color)
  31. *         You got the bomb!
  32. *
  33. *       Note: by defult message display time is 7 seconds (define MSG_TIME)
  34. *
  35. *     VERSIONS
  36. *       0.4   backpack transfer method greatly improved
  37. *             added pcvar natives support (backward compatibility saved)
  38. *             few code optimization
  39. *       0.3   now fakemeta instead of engine required (efficiency++ if engine is disabled)
  40. *             "non-bomb map" check can be disabled (//#define BOMB_MAP_CHECK)
  41. *             backpack finding method improved
  42. *             few code optimization
  43. *             added comments to the plugin source code
  44. *       0.2   fixed format issue
  45. *             code optimized
  46. *             description improved
  47. *
  48. *       0.1   first release
  49. */
  50.  
  51. /* *************************************************** Init **************************************************** */
  52.  
  53. #include <amxmodx>
  54. #include <fakemeta>
  55. #include <colorchat>
  56.  
  57. // plugin's main information
  58. #define PLUGIN_NAME "AFK Bomb Transfer"
  59. #define PLUGIN_VERSION "0.4"
  60. #define PLUGIN_AUTHOR "VEN"
  61.  
  62. // comment to avoid autodisabling the plugin on maps which not contain bomb targets
  63. #define BOMB_MAP_CHECK
  64.  
  65. // float value, hud messages display time (in seconds)
  66. #define MSG_TIME 7.0
  67.  
  68. // CVAR name, affects on spawned AFK bomb carrier which never moved after spawn
  69. new CVAR_SPAWN[] = "afk_bombtransfer_spawn"
  70.  
  71. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  72. new DEFAULT_SPAWN[] = "7"
  73.  
  74. // CVAR name, affects on any AFK bomb carrier except one which obey previous CVAR
  75. new CVAR_TIME[] = "afk_bombtransfer_time"
  76.  
  77. // CVAR value, max. allowed bomb carrier AFK time (in seconds)
  78. new DEFAULT_TIME[] = "15"
  79.  
  80. // do not set this value less than "maxplayers"
  81. #define MAX_PLAYERS 32
  82.  
  83. // initial AMXX version number supported CVAR pointers in get/set_pcvar_* natives
  84. #define CVAR_POINTERS_AMXX_INIT_VER_NUM 170
  85.  
  86. // determine if get/set_pcvar_* natives can be used
  87. #if defined AMXX_VERSION_NUM && AMXX_VERSION_NUM >= CVAR_POINTERS_AMXX_INIT_VER_NUM
  88.     #define CVAR_POINTERS
  89.     new g_pcvar_spawn
  90.     new g_pcvar_time
  91. #endif
  92.  
  93. new TEAM[] = "TERRORIST"
  94. new WEAPON[] = "weapon_c4"
  95.  
  96. #define FL_ONGROUND (1<<9)
  97.  
  98. new bool:g_freezetime = true
  99. new bool:g_spawn
  100. new bool:g_planting
  101.  
  102. new g_carrier
  103.  
  104. new g_pos[MAX_PLAYERS + 1][3]
  105. new g_time[MAX_PLAYERS + 1]
  106.  
  107. new g_maxplayers
  108.  
  109. public plugin_init() {
  110.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  111.  
  112. #if defined CVAR_POINTERS
  113.     g_pcvar_spawn = register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  114.     g_pcvar_time = register_cvar(CVAR_TIME, DEFAULT_TIME)
  115. #else
  116.     register_cvar(CVAR_SPAWN, DEFAULT_SPAWN)
  117.     register_cvar(CVAR_TIME, DEFAULT_TIME)
  118. #endif
  119.  
  120. #if defined BOMB_MAP_CHECK
  121.     // is current map not contain bomb targets?
  122.     if (!engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target"))
  123.         return
  124. #endif
  125.  
  126.     register_event("WeapPickup", "event_got_bomb", "be", "1=6")
  127.     register_event("BarTime", "event_bar_time", "be")
  128.     register_event("TextMsg", "event_bomb_drop", "bc", "2=#Game_bomb_drop")
  129.     register_event("TextMsg", "event_bomb_drop", "a", "2=#Bomb_Planted")
  130.     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
  131.  
  132.     register_logevent("logevent_round_start", 2, "1=Round_Start")
  133.  
  134.     set_task(1.0, "task_afk_check", _, _, _, "b") // plugin's core loop
  135.  
  136.     g_maxplayers = get_maxplayers()
  137. }
  138.  
  139. /* *************************************************** Base **************************************************** */
  140.  
  141. public event_new_round() {
  142.     g_freezetime = true
  143.     g_spawn = true
  144.     g_planting = false
  145.     g_carrier = 0
  146. }
  147.  
  148. public event_got_bomb(id) {
  149.     g_carrier = id
  150. }
  151.  
  152. public event_bar_time(id) {
  153.     if (id == g_carrier) {
  154.         g_planting = bool:read_data(1)
  155.         get_user_origin(id, g_pos[id])
  156.         g_time[id] = 0
  157.     }
  158. }
  159.  
  160. public event_bomb_drop() {
  161.     g_spawn = false
  162.     g_planting = false
  163.     g_carrier = 0
  164. }
  165.  
  166. public logevent_round_start() {
  167.     new id[32], num
  168.     get_players(id, num, "ae", TEAM)
  169.  
  170.     if (!num) // is server empty?
  171.         return
  172.  
  173.     g_freezetime = false
  174.  
  175.     // update afk timers and current positions
  176.     new x
  177.     for (new i = 0; i < num; ++i) {
  178.         x = id[i]
  179.         get_user_origin(x, g_pos[x])
  180.         g_time[x] = 0
  181.     }
  182. }
  183.  
  184. public task_afk_check() {
  185.     if (g_freezetime) // is freezetime right now?
  186.         return
  187.  
  188.     // afk check
  189.     new id[32], num, x, origin[3]
  190.     get_players(id, num, "ae", TEAM)
  191.     for (new i = 0; i < num; ++i) {
  192.         x = id[i]
  193.         get_user_origin(x, origin)
  194.         if (origin[0] != g_pos[x][0] || origin[1] != g_pos[x][1] || (x == g_carrier && g_planting)) {
  195.             g_time[x] = 0
  196.             g_pos[x][0] = origin[0]
  197.             g_pos[x][1] = origin[1]
  198.             if (g_spawn && x == g_carrier)
  199.                 g_spawn = false
  200.         }
  201.         else
  202.             g_time[x]++
  203.     }
  204.  
  205.     // is bomb not currently carried or Ts number less than 2?
  206.     if (!g_carrier || num < 2)
  207.         return
  208.  
  209. #if defined CVAR_POINTERS
  210.     new max_time = get_pcvar_num(g_spawn ? g_pcvar_spawn : g_pcvar_time)
  211. #else
  212.     new max_time = get_cvar_num(g_spawn ? CVAR_SPAWN : CVAR_TIME)
  213. #endif
  214.  
  215.     // is plugin disabled (cvar <= 0) or carrier isn't afk?
  216.     if (max_time <= 0 || g_time[g_carrier] < max_time)
  217.         return
  218.  
  219.     // find who from non-afk Ts is the closest to the afk carrier
  220.     get_user_origin(g_carrier, origin)
  221.     new min_dist = 999999, dist, recipient, origin2[3]
  222.     for (new i = 0; i < num; ++i) {
  223.         x = id[i]
  224.         if (g_time[x] < max_time) {
  225.             get_user_origin(x, origin2)
  226.             dist = get_distance(origin, origin2)
  227.             if (dist < min_dist) {
  228.                 min_dist = dist
  229.                 recipient = x
  230.             }
  231.         }
  232.     }
  233.  
  234.     if (!recipient) // is all Ts afk?
  235.         return
  236.  
  237.     new carrier = g_carrier
  238.     engclient_cmd(carrier, "drop", WEAPON) // drop the backpack
  239.     new c4 = engfunc(EngFunc_FindEntityByString, -1, "classname", WEAPON) // find weapon_c4 entity
  240.     if (!c4)
  241.         return
  242.  
  243.     new backpack = pev(c4, pev_owner) // get backpack entity
  244.     if (backpack <= g_maxplayers)
  245.         return
  246.  
  247.     // my backpack transfer trick (improved)
  248.     set_pev(backpack, pev_flags, pev(backpack, pev_flags) | FL_ONGROUND)
  249.     dllfunc(DLLFunc_Touch, backpack, recipient)
  250.  
  251.     // hud messages stuff below
  252.     set_hudmessage(0, 255, 0, 0.35, 0.8, _, _, MSG_TIME)
  253.     new message[128], c_name[32], r_name[32]
  254.     get_user_name(carrier, c_name, 31)
  255.     get_user_name(recipient, r_name, 31)
  256.     format(message, 127, "A bombat att adtak ^"%s^"^n-nek mert ^"%s^" AFKzik!", r_name, c_name)
  257.     for (new i = 0; i < num; ++i)
  258.         show_hudmessage(id[i], "%s", message)
  259.  
  260.    ColorChat(recipient, GREEN, "Megkaptad a Bombát")
  261. }
  262.  
  263. /* **************************************************** EOF **************************************************** */

_________________
We are the walking dead..
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: NE hudmassage-be, HANEM chatbe írja
HozzászólásElküldve: 2021.02.19. 09:37 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 403
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 123 alkalommal
Off Topic
ha tudsz egy kicsit angolul akkor ajánlanám figyelmedbe a "CS AFK Manager" plugint.
Ebből az 1.8.3 as verziót. Minden üzenet chat-re van állítva és cvarral külön állítható hogy színes vagy sima legyen.
AFK bomba eldobás/átadás csapattársnak, Admin immunitás jogra, spec beálltások stb.
A lang fájlban van alapból magyar fordítás. Egyedül a cvarok megértéséhez kell egy kis angol nyelvtudás
Megjegyzés: 1.8.3 as verzióhoz értelemszerűen 1.8.3-as Compiler(Fordító) kell


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 8 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 18 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole