HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. * Ya, Another Server Redirect Plugin
  3. *
  4. * This redirect plugin is designed solely for those who are changing server IPs. It will
  5. * redirect ALL players to your new server while displaying info in a MOTD. The MOTD will
  6. * trap the player on the MOTD screen, continue to display it, until the redirect occurs.
  7. * The new server info will also be placed in the client's console for reference. The MOTD
  8. * stay code is based on 'MOTD Repeater/Holder' by Ven.
  9. *
  10. * The plugin contains a 'backdoor' that will allow an admin with immunity, AND who's
  11. * player name is noredirect, to enter the server.
  12. *
  13. * The plugin will autofail if...
  14. * No motd.txt file is found
  15. * The redirect_ip CVar is blank
  16. * The redirect_enable CVar is 0
  17. *
  18. * CVars (Place in server.cfg or amxx.cfg file)
  19. * redirect_enable // Plugin enable/disable - Required (Default = 0/disabled)
  20. * redirect_ip // Destination server IP - Required (Default = "")
  21. * redirect_port // Destination server port - Required if other than default (Default = 27015)
  22. * redirect_delay // Delay time (seconds) until redirect - Optional (Default = 10)
  23. *
  24. * This plugin has only been tested on a Windows server with DOD 1.3 and CS 1.6
  25. *
  26. * Version History:
  27. * 1.7 - Fixed issue of not redirecting after another Steam update.
  28. * 1.6 - Fixed issue of not redirecting after Steam update.
  29. * 1.5 - Fix connect issue with Steam update
  30. */
  31.  
  32. #include <amxmodx>
  33. #include <amxmisc>
  34.  
  35. #define PLUGIN "Redirect_All"
  36. #define VERSION "1.7"
  37. #define AUTHOR "Vet(3TT3V)"
  38.  
  39. new g_enabled
  40. new g_IP
  41. new g_port
  42. new g_delay
  43. new g_ipcvar[32]
  44. new g_portcvar
  45.  
  46. public plugin_init()
  47. {
  48. g_enabled = register_cvar("redirect_enable", "1")
  49. g_IP = register_cvar("redirect_ip", "")
  50. g_port = register_cvar("redirect_port", "")
  51. g_delay = register_cvar("redirect_delay", "0.1")
  52.  
  53. register_plugin(PLUGIN, VERSION, AUTHOR)
  54.  
  55. if (!file_exists("motd.txt"))
  56. set_fail_state("motd.txt file not found")
  57.  
  58. if (!get_pcvar_num(g_enabled))
  59. set_fail_state("Plugin disabled by CVar")
  60.  
  61. get_pcvar_string(g_IP, g_ipcvar, 31)
  62. if (equal(g_ipcvar, ""))
  63. set_fail_state("Invalid server IP CVar")
  64.  
  65. g_portcvar = get_pcvar_num(g_port)
  66.  
  67. register_event("InitHUD", "event_InitHUD", "bd")
  68. register_message(get_user_msgid("VGUIMenu"), "show_vgui")
  69.  
  70. log_message("[AMXX] Redirect All - Plugin Initialized")
  71.  
  72. return PLUGIN_CONTINUE
  73. }
  74.  
  75. public event_InitHUD(id)
  76. {
  77. if (!is_user_bot(id) && !is_user_hltv(id) && !is_user_immune(id)) {
  78. set_task(0.1, "task_show_motd", id, "", 0, "b")
  79. console_print(id, "^n****************************")
  80. console_print(id, "* Atiranyitas")
  81. console_print(id, "* %s:%d^n*", g_ipcvar, g_portcvar)
  82. console_print(id, "* Mentsd el az ipt")
  83. console_print(id, "****************************^n")
  84. set_task(Float:get_pcvar_float(g_delay), "task_redirect", 100 + id)
  85. }
  86.  
  87. return PLUGIN_CONTINUE
  88. }
  89.  
  90. public client_disconnect(id)
  91. {
  92. remove_task(id)
  93. remove_task(100 + id)
  94. }
  95.  
  96. public task_show_motd(id)
  97. {
  98. if (is_user_connected(id))
  99. show_motd(id, "motd.txt")
  100. else {
  101. remove_task(id)
  102. remove_task(100 + id)
  103. }
  104. }
  105.  
  106. public task_redirect(tid)
  107. {
  108. new id = tid - 100
  109. new info1[32], info2[32]
  110. if (is_user_connected(id)) {
  111. get_user_name(id, info1, 31)
  112. get_user_authid(id, info2, 31)
  113. log_message("[Redirect] Sent %s <%s> to new server", info1, info2)
  114. client_cmd(id, "^"connect^" %s:%d", g_ipcvar, g_portcvar)
  115. }
  116. }
  117.  
  118. public show_vgui(msgid, dest, id)
  119. {
  120. if (is_user_immune(id))
  121. return PLUGIN_CONTINUE
  122.  
  123. return PLUGIN_HANDLED
  124. }
  125.  
  126. public is_user_immune(id)
  127. {
  128. new uname[32]
  129. get_user_name(id, uname, 31)
  130. if (get_user_flags(id) & ADMIN_IMMUNITY && equal(uname, "noredirect"))
  131. return 1
  132.  
  133. return 0
  134. }
  135.