HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. This plugin allows players to change their name without having to access the console.
  3.  
  4. This is especially useful in DoD and TFC, because in these games Valve disabled the name field in the multiplayer options with the hint that the Friends name should be altered instead, but this doesn't have an effect.
  5.  
  6. CVAR
  7.  
  8. amx_name_usage - Display usage info? 0 = no, 1 = yes
  9.  
  10. Credits:
  11.  
  12. Original plugin: KyleD
  13. Translations: xPaw, Xalus, MmikiM, Ciio, xD_1991, papyrus_kn, Mandiii
  14. Help & suggestions to get this plugin approved: ConnorMcLeod, fysiks
  15.  
  16. Version history:
  17.  
  18. v1.0 (KyleD)
  19. - Original release
  20. v1.1 (pizzahut)
  21. - Bug fix: Global chat isn't blocked anymore.
  22. - Change: A slash in front isn't necessary anymore, this is especially helpful for players who don't have an English keyboard layout.
  23. v1.2
  24. - Change: Made name change chat visible, so other players can see how it's done.
  25. v1.3
  26. - Players get a message when spawning, if the name is blank they get a name prompt.
  27. v1.4
  28. - Added multi-language support.
  29. v1.5
  30. - Changed trigger "name" to ".name".
  31. v1.6
  32. - Allowing any single character prefix as suggested by fysiks.
  33. v1.6.4
  34. - Bug fixes for single character prefix.
  35. v1.7
  36. Code taken from "multilingual.sma" for the following changes:
  37. - Usage info is displayed 10s after joining instead of when respawning
  38.   and it's displayed only one time instead of two times.
  39. - Added cvar to turn on / off usage info.
  40. Other changes:
  41. - Code optimisation
  42. v1.7.1
  43. - Moved the remove_task function as suggested.
  44. */
  45.  
  46. #include <amxmodx>
  47.  
  48. new g_cvar_usage
  49.  
  50. public plugin_init()
  51. {
  52. register_plugin("ChangeName", "1.7.1", "pizzahut")
  53. register_concmd("say", "handle_say")
  54. register_dictionary("name.txt")
  55. g_cvar_usage = register_cvar("amx_name_usage", "1") // Display usage info? 0 = no, 1 = yes
  56. }
  57.  
  58. public handle_say(id)
  59. {
  60. static message[128]
  61. read_args(message, 127)
  62. remove_quotes(message)
  63.  
  64. // The first character should be '.' or '/'. However because of Half-Life's fixed US keyboard
  65. // layout, any special character is accepted to make it easier for foreign new players.
  66. if( isalnum(message[0]) || (containi(message,"name")!=1) )
  67. return PLUGIN_CONTINUE
  68.  
  69. switch(message[5])
  70. {
  71. // Syntax 1: /name without a parameter
  72. case 0: client_cmd(id, "messagemode name")
  73.  
  74. // Syntax 2: /name <name>
  75. case ' ': client_cmd(id, "name ^"%s^"", message[6])
  76. }
  77. return PLUGIN_CONTINUE
  78. }
  79.  
  80. public client_putinserver(id)
  81. {
  82. if (get_pcvar_num(g_cvar_usage) && !is_user_bot(id))
  83. {
  84. // I decided to put the remove_task function into the "if" branch.
  85. // This means that a previous task may be executed on bots,
  86. // but there is less overhead if the cvar is 0.
  87. remove_task(id)
  88. set_task(10.0, "dispInfo", id)
  89. }
  90. }
  91.  
  92. public dispInfo(id)
  93. {
  94. client_print(id, print_chat, "[AMXX] %L", id, "usage")
  95. }
  96.