hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.11.01. 00:55



Jelenlévő felhasználók

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

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

Regisztrált felhasználók: nincs regisztrált felhasználó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  [5 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Admin írás
HozzászólásElküldve:2013.04.27. 17:04 
Offline
Félisten

Csatlakozott:2012.06.19. 15:12
Hozzászólások:926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
Ebbe bele lehetne írni hogy akinek nincs ban joga ne [.] igy írja ki a nevét hanem [Kisadmin]-t írjon és még hogy az admin nevét zöldel írja ki és az üzenetet zölddel írja.

SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4.  
  5. #define PLUGIN "Admin Chat Colors"
  6. #define VERSION "2.0"
  7. #define AUTHOR "Arion"
  8.  
  9. #define ACCESS_LEVEL ADMIN_IMMUNITY
  10. #define ADMIN_LISTEN ADMIN_LEVEL_C
  11.  
  12. new message[192]
  13. new sayText
  14. new teamInfo
  15. new maxPlayers
  16.  
  17. new g_AdminListen
  18.  
  19. new strName[191]
  20. new alive[11]
  21.  
  22. new const g_szTag[][] = {
  23. "",
  24. "[Tulaj]",
  25. "[Admin]",
  26. "[.]"
  27. }
  28.  
  29. public plugin_init()
  30. {
  31. register_plugin(PLUGIN, VERSION, AUTHOR)
  32.  
  33. g_AdminListen = register_cvar("amx_listen", "1") // Set whether admins see or not all messages(Alive, dead and team-only)
  34.  
  35.  
  36. sayText = get_user_msgid("SayText")
  37. teamInfo = get_user_msgid("TeamInfo")
  38. maxPlayers = get_maxplayers()
  39.  
  40. register_clcmd("say", "hook_say")
  41. register_clcmd("say_team", "hook_teamsay")
  42. }
  43.  
  44. public hook_say(id)
  45. {
  46. read_args(message, 191)
  47. remove_quotes(message)
  48.  
  49. // Gungame commands and empty messages
  50. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  51. return PLUGIN_CONTINUE
  52.  
  53. new name[32]
  54. get_user_name(id, name, 31)
  55.  
  56. new admin = 0, iFlags = get_user_flags(id)
  57.  
  58. if(iFlags & ADMIN_IMMUNITY)
  59. admin = 1
  60. else if(iFlags & ADMIN_BAN)
  61. admin = 2
  62. else if(iFlags & ADMIN_RESERVATION)
  63. admin = 3
  64.  
  65. new isAlive
  66.  
  67. if(is_user_alive(id))
  68. {
  69. isAlive = 1
  70. alive = "^x01"
  71. }
  72. else
  73. {
  74. isAlive = 0
  75. alive = "^x01*DEAD* "
  76. }
  77.  
  78. static color[10]
  79.  
  80. if(admin)
  81. {
  82. get_user_team(id, color, 9)
  83. format(strName, 191, "^x04%s %s^x03%s", g_szTag[admin], alive, name)
  84. format(message, 191, "%s ^x01:^x04 %s", strName, message)
  85. }
  86. else // Player is not admin. Team-color name : Yellow message
  87. {
  88. get_user_team(id, color, 9)
  89. format(strName, 191, "%s^x03%s", alive, name)
  90. format(message, 191, "^%s^x01 : %s", strName, message)
  91. }
  92.  
  93.  
  94. sendMessage(color, isAlive) // Sends the colored message
  95.  
  96. return PLUGIN_HANDLED
  97. }
  98.  
  99.  
  100. public hook_teamsay(id)
  101. {
  102. new playerTeam = get_user_team(id)
  103. new playerTeamName[19]
  104.  
  105. switch(playerTeam) // Team names which appear on team-only messages
  106. {
  107. case 1:
  108. copy(playerTeamName, 11, "Terrorists")
  109.  
  110. case 2:
  111. copy(playerTeamName, 18, "Counter-Terrorists")
  112.  
  113. default:
  114. copy(playerTeamName, 9, "Spectator")
  115. }
  116.  
  117. read_args(message, 191)
  118. remove_quotes(message)
  119.  
  120. // Gungame commands and empty messages
  121. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  122. return PLUGIN_CONTINUE
  123.  
  124. new name[32]
  125. get_user_name(id, name, 31)
  126.  
  127. new admin = 0, iFlags = get_user_flags(id)
  128.  
  129. if(iFlags & ADMIN_IMMUNITY)
  130. admin = 1
  131. else if(iFlags & ADMIN_KICK)
  132. admin = 2
  133. else if(iFlags & ADMIN_RESERVATION)
  134. admin = 3
  135.  
  136. new isAlive
  137.  
  138. if(is_user_alive(id))
  139. {
  140. isAlive = 1
  141. alive = "^x01"
  142. }
  143. else
  144. {
  145. isAlive = 0
  146. alive = "^x01*DEAD* "
  147. }
  148.  
  149. static color[10]
  150.  
  151. if(admin)
  152. {
  153. get_user_team(id, color, 9)
  154. format(strName, 191, "%s(%s)^x04%s ^x03%s", alive, playerTeamName, g_szTag[admin], name)
  155. format(message, 191, "%s ^x01: ^x04%s", strName, message)
  156. }
  157. else // Player is not admin. Team-color name : Yellow message
  158. {
  159. get_user_team(id, color, 9)
  160. format(strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  161. format(message, 191, "%s ^x01: %s", strName, message)
  162. }
  163.  
  164.  
  165. sendTeamMessage(color, isAlive, playerTeam) // Sends the colored message
  166.  
  167. return PLUGIN_HANDLED
  168. }
  169.  
  170. public sendMessage(color[], alive)
  171. {
  172. new teamName[10]
  173.  
  174. for(new player = 1; player < maxPlayers; player++)
  175. {
  176. if(!is_user_connected(player))
  177. continue
  178.  
  179. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  180. {
  181. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  182. changeTeamInfo(player, color) // Changes user's team according to color choosen
  183. writeMessage(player, message) // Writes the message on player's chat
  184. changeTeamInfo(player, teamName) // Changes user's team back to original
  185. }
  186. }
  187. }
  188.  
  189.  
  190. public sendTeamMessage(color[], alive, playerTeam)
  191. {
  192. new teamName[10]
  193.  
  194. for(new player = 1; player < maxPlayers; player++)
  195. {
  196. if(!is_user_connected(player))
  197. continue
  198.  
  199. if(get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  200. {
  201. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  202. {
  203. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  204. changeTeamInfo(player, color) // Changes user's team according to color choosen
  205. writeMessage(player, message) // Writes the message on player's chat
  206. changeTeamInfo(player, teamName) // Changes user's team back to original
  207. }
  208. }
  209. }
  210. }
  211.  
  212.  
  213. public changeTeamInfo(player, team[])
  214. {
  215. message_begin(MSG_ONE, teamInfo, _, player) // Tells to to modify teamInfo(Which is responsable for which time player is)
  216. write_byte(player) // Write byte needed
  217. write_string(team) // Changes player's team
  218. message_end() // Also Needed
  219. }
  220.  
  221.  
  222. public writeMessage(player, message[])
  223. {
  224. message_begin(MSG_ONE, sayText, {0, 0, 0}, player) // Tells to modify sayText(Which is responsable for writing colored messages)
  225. write_byte(player) // Write byte needed
  226. write_string(message) // Effectively write the message, finally, afterall
  227. message_end() // Needed as always
  228. }

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Admin írás
HozzászólásElküldve:2013.04.27. 17:25 
Offline
Jómunkásember
Avatar

Csatlakozott:2013.03.07. 18:39
Hozzászólások:352
Megköszönt másnak: 3 alkalommal
Megköszönték neki: 38 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4.  
  5. #define PLUGIN "Admin Chat Colors"
  6. #define VERSION "2.0"
  7. #define AUTHOR "Arion"
  8.  
  9. #define ACCESS_LEVEL ADMIN_IMMUNITY
  10. #define ADMIN_LISTEN ADMIN_LEVEL_C
  11.  
  12. new message[192]
  13. new sayText
  14. new teamInfo
  15. new maxPlayers
  16.  
  17. new g_AdminListen
  18.  
  19. new strName[191]
  20. new alive[11]
  21.  
  22. new const g_szTag[][] = {
  23. "",
  24. "[Tulaj]",
  25. "[Admin]",
  26. "[Kisadmin]"
  27. }
  28.  
  29. public plugin_init()
  30. {
  31. register_plugin(PLUGIN, VERSION, AUTHOR)
  32.  
  33. g_AdminListen = register_cvar("amx_listen", "1") // Set whether admins see or not all messages(Alive, dead and team-only)
  34.  
  35.  
  36. sayText = get_user_msgid("SayText")
  37. teamInfo = get_user_msgid("TeamInfo")
  38. maxPlayers = get_maxplayers()
  39.  
  40. register_clcmd("say", "hook_say")
  41. register_clcmd("say_team", "hook_teamsay")
  42. }
  43.  
  44. public hook_say(id)
  45. {
  46. read_args(message, 191)
  47. remove_quotes(message)
  48.  
  49. // Gungame commands and empty messages
  50. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  51. return PLUGIN_CONTINUE
  52.  
  53. new name[32]
  54. get_user_name(id, name, 31)
  55.  
  56. new admin = 0, iFlags = get_user_flags(id)
  57.  
  58. if(iFlags & ADMIN_IMMUNITY)
  59. admin = 1
  60. else if(iFlags & ADMIN_BAN)
  61. admin = 2
  62. else if(iFlags & ADMIN_RESERVATION)
  63. admin = 3
  64.  
  65. new isAlive
  66.  
  67. if(is_user_alive(id))
  68. {
  69. isAlive = 1
  70. alive = "^x01"
  71. }
  72. else
  73. {
  74. isAlive = 0
  75. alive = "^x01*DEAD* "
  76. }
  77.  
  78. static color[10]
  79.  
  80. if(admin)
  81. {
  82. get_user_team(id, color, 9)
  83. format(strName, 191, "^x04%s %s^x03%s", g_szTag[admin], alive, name)
  84. format(message, 191, "%s ^x01:^x04 %s", strName, message)
  85. }
  86. else // Player is not admin. Team-color name : Yellow message
  87. {
  88. get_user_team(id, color, 9)
  89. format(strName, 191, "%s^x03%s", alive, name)
  90. format(message, 191, "^%s^x01 : %s", strName, message)
  91. }
  92.  
  93.  
  94. sendMessage(color, isAlive) // Sends the colored message
  95.  
  96. return PLUGIN_HANDLED
  97. }
  98.  
  99.  
  100. public hook_teamsay(id)
  101. {
  102. new playerTeam = get_user_team(id)
  103. new playerTeamName[19]
  104.  
  105. switch(playerTeam) // Team names which appear on team-only messages
  106. {
  107. case 1:
  108. copy(playerTeamName, 11, "Terrorists")
  109.  
  110. case 2:
  111. copy(playerTeamName, 18, "Counter-Terrorists")
  112.  
  113. default:
  114. copy(playerTeamName, 9, "Spectator")
  115. }
  116.  
  117. read_args(message, 191)
  118. remove_quotes(message)
  119.  
  120. // Gungame commands and empty messages
  121. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  122. return PLUGIN_CONTINUE
  123.  
  124. new name[32]
  125. get_user_name(id, name, 31)
  126.  
  127. new admin = 0, iFlags = get_user_flags(id)
  128.  
  129. if(iFlags & ADMIN_IMMUNITY)
  130. admin = 1
  131. else if(iFlags & ADMIN_KICK)
  132. admin = 2
  133. else if(iFlags & ADMIN_RESERVATION)
  134. admin = 3
  135.  
  136. new isAlive
  137.  
  138. if(is_user_alive(id))
  139. {
  140. isAlive = 1
  141. alive = "^x01"
  142. }
  143. else
  144. {
  145. isAlive = 0
  146. alive = "^x01*DEAD* "
  147. }
  148.  
  149. static color[10]
  150.  
  151. if(admin)
  152. {
  153. get_user_team(id, color, 9)
  154. format(strName, 191, "%s(%s)^x04%s ^x04%s", alive, playerTeamName, g_szTag[admin], name)
  155. format(message, 191, "%s ^x01: ^x04%s", strName, message)
  156. }
  157. else // Player is not admin. Team-color name : Yellow message
  158. {
  159. get_user_team(id, color, 9)
  160. format(strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  161. format(message, 191, "%s ^x01: %s", strName, message)
  162. }
  163.  
  164.  
  165. sendTeamMessage(color, isAlive, playerTeam) // Sends the colored message
  166.  
  167. return PLUGIN_HANDLED
  168. }
  169.  
  170. public sendMessage(color[], alive)
  171. {
  172. new teamName[10]
  173.  
  174. for(new player = 1; player < maxPlayers; player++)
  175. {
  176. if(!is_user_connected(player))
  177. continue
  178.  
  179. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  180. {
  181. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  182. changeTeamInfo(player, color) // Changes user's team according to color choosen
  183. writeMessage(player, message) // Writes the message on player's chat
  184. changeTeamInfo(player, teamName) // Changes user's team back to original
  185. }
  186. }
  187. }
  188.  
  189.  
  190. public sendTeamMessage(color[], alive, playerTeam)
  191. {
  192. new teamName[10]
  193.  
  194. for(new player = 1; player < maxPlayers; player++)
  195. {
  196. if(!is_user_connected(player))
  197. continue
  198.  
  199. if(get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  200. {
  201. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  202. {
  203. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  204. changeTeamInfo(player, color) // Changes user's team according to color choosen
  205. writeMessage(player, message) // Writes the message on player's chat
  206. changeTeamInfo(player, teamName) // Changes user's team back to original
  207. }
  208. }
  209. }
  210. }
  211.  
  212.  
  213. public changeTeamInfo(player, team[])
  214. {
  215. message_begin(MSG_ONE, teamInfo, _, player) // Tells to to modify teamInfo(Which is responsable for which time player is)
  216. write_byte(player) // Write byte needed
  217. write_string(team) // Changes player's team
  218. message_end() // Also Needed
  219. }
  220.  
  221.  
  222. public writeMessage(player, message[])
  223. {
  224. message_begin(MSG_ONE, sayText, {0, 0, 0}, player) // Tells to modify sayText(Which is responsable for writing colored messages)
  225. write_byte(player) // Write byte needed
  226. write_string(message) // Effectively write the message, finally, afterall
  227. message_end() // Needed as always
  228. }

Teszt nemvolt.

Ők köszönték meg tomy3231 nek ezt a hozzászólást: Tomos (2013.04.27. 22: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: Admin írás
HozzászólásElküldve:2013.04.27. 17:28 
Offline
Tud valamit

Csatlakozott:2013.01.21. 10:10
Hozzászólások:138
Megköszönt másnak: 20 alkalommal
Megköszönték neki: 6 alkalommal
Tomos írta:
Ebbe bele lehetne írni hogy akinek nincs ban joga ne [.] igy írja ki a nevét hanem [Kisadmin]-t írjon és még hogy az admin nevét zöldel írja ki és az üzenetet zölddel írja.

SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4.  
  5. #define PLUGIN "Admin Chat Colors"
  6. #define VERSION "2.0"
  7. #define AUTHOR "Arion"
  8.  
  9. #define ACCESS_LEVEL ADMIN_IMMUNITY
  10. #define ADMIN_LISTEN ADMIN_LEVEL_C
  11.  
  12. new message[192]
  13. new sayText
  14. new teamInfo
  15. new maxPlayers
  16.  
  17. new g_AdminListen
  18.  
  19. new strName[191]
  20. new alive[11]
  21.  
  22. new const g_szTag[][] = {
  23. "",
  24. "[Tulaj]",
  25. "[Admin]",
  26. "[.]"
  27. }
  28.  
  29. public plugin_init()
  30. {
  31. register_plugin(PLUGIN, VERSION, AUTHOR)
  32.  
  33. g_AdminListen = register_cvar("amx_listen", "1") // Set whether admins see or not all messages(Alive, dead and team-only)
  34.  
  35.  
  36. sayText = get_user_msgid("SayText")
  37. teamInfo = get_user_msgid("TeamInfo")
  38. maxPlayers = get_maxplayers()
  39.  
  40. register_clcmd("say", "hook_say")
  41. register_clcmd("say_team", "hook_teamsay")
  42. }
  43.  
  44. public hook_say(id)
  45. {
  46. read_args(message, 191)
  47. remove_quotes(message)
  48.  
  49. // Gungame commands and empty messages
  50. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  51. return PLUGIN_CONTINUE
  52.  
  53. new name[32]
  54. get_user_name(id, name, 31)
  55.  
  56. new admin = 0, iFlags = get_user_flags(id)
  57.  
  58. if(iFlags & ADMIN_IMMUNITY)
  59. admin = 1
  60. else if(iFlags & ADMIN_BAN)
  61. admin = 2
  62. else if(iFlags & ADMIN_RESERVATION)
  63. admin = 3
  64.  
  65. new isAlive
  66.  
  67. if(is_user_alive(id))
  68. {
  69. isAlive = 1
  70. alive = "^x01"
  71. }
  72. else
  73. {
  74. isAlive = 0
  75. alive = "^x01*DEAD* "
  76. }
  77.  
  78. static color[10]
  79.  
  80. if(admin)
  81. {
  82. get_user_team(id, color, 9)
  83. format(strName, 191, "^x04%s %s^x03%s", g_szTag[admin], alive, name)
  84. format(message, 191, "%s ^x01:^x04 %s", strName, message)
  85. }
  86. else // Player is not admin. Team-color name : Yellow message
  87. {
  88. get_user_team(id, color, 9)
  89. format(strName, 191, "%s^x03%s", alive, name)
  90. format(message, 191, "^%s^x01 : %s", strName, message)
  91. }
  92.  
  93.  
  94. sendMessage(color, isAlive) // Sends the colored message
  95.  
  96. return PLUGIN_HANDLED
  97. }
  98.  
  99.  
  100. public hook_teamsay(id)
  101. {
  102. new playerTeam = get_user_team(id)
  103. new playerTeamName[19]
  104.  
  105. switch(playerTeam) // Team names which appear on team-only messages
  106. {
  107. case 1:
  108. copy(playerTeamName, 11, "Terrorists")
  109.  
  110. case 2:
  111. copy(playerTeamName, 18, "Counter-Terrorists")
  112.  
  113. default:
  114. copy(playerTeamName, 9, "Spectator")
  115. }
  116.  
  117. read_args(message, 191)
  118. remove_quotes(message)
  119.  
  120. // Gungame commands and empty messages
  121. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  122. return PLUGIN_CONTINUE
  123.  
  124. new name[32]
  125. get_user_name(id, name, 31)
  126.  
  127. new admin = 0, iFlags = get_user_flags(id)
  128.  
  129. if(iFlags & ADMIN_IMMUNITY)
  130. admin = 1
  131. else if(iFlags & ADMIN_KICK)
  132. admin = 2
  133. else if(iFlags & ADMIN_RESERVATION)
  134. admin = 3
  135.  
  136. new isAlive
  137.  
  138. if(is_user_alive(id))
  139. {
  140. isAlive = 1
  141. alive = "^x01"
  142. }
  143. else
  144. {
  145. isAlive = 0
  146. alive = "^x01*DEAD* "
  147. }
  148.  
  149. static color[10]
  150.  
  151. if(admin)
  152. {
  153. get_user_team(id, color, 9)
  154. format(strName, 191, "%s(%s)^x04%s ^x03%s", alive, playerTeamName, g_szTag[admin], name)
  155. format(message, 191, "%s ^x01: ^x04%s", strName, message)
  156. }
  157. else // Player is not admin. Team-color name : Yellow message
  158. {
  159. get_user_team(id, color, 9)
  160. format(strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  161. format(message, 191, "%s ^x01: %s", strName, message)
  162. }
  163.  
  164.  
  165. sendTeamMessage(color, isAlive, playerTeam) // Sends the colored message
  166.  
  167. return PLUGIN_HANDLED
  168. }
  169.  
  170. public sendMessage(color[], alive)
  171. {
  172. new teamName[10]
  173.  
  174. for(new player = 1; player < maxPlayers; player++)
  175. {
  176. if(!is_user_connected(player))
  177. continue
  178.  
  179. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  180. {
  181. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  182. changeTeamInfo(player, color) // Changes user's team according to color choosen
  183. writeMessage(player, message) // Writes the message on player's chat
  184. changeTeamInfo(player, teamName) // Changes user's team back to original
  185. }
  186. }
  187. }
  188.  
  189.  
  190. public sendTeamMessage(color[], alive, playerTeam)
  191. {
  192. new teamName[10]
  193.  
  194. for(new player = 1; player < maxPlayers; player++)
  195. {
  196. if(!is_user_connected(player))
  197. continue
  198.  
  199. if(get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  200. {
  201. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  202. {
  203. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  204. changeTeamInfo(player, color) // Changes user's team according to color choosen
  205. writeMessage(player, message) // Writes the message on player's chat
  206. changeTeamInfo(player, teamName) // Changes user's team back to original
  207. }
  208. }
  209. }
  210. }
  211.  
  212.  
  213. public changeTeamInfo(player, team[])
  214. {
  215. message_begin(MSG_ONE, teamInfo, _, player) // Tells to to modify teamInfo(Which is responsable for which time player is)
  216. write_byte(player) // Write byte needed
  217. write_string(team) // Changes player's team
  218. message_end() // Also Needed
  219. }
  220.  
  221.  
  222. public writeMessage(player, message[])
  223. {
  224. message_begin(MSG_ONE, sayText, {0, 0, 0}, player) // Tells to modify sayText(Which is responsable for writing colored messages)
  225. write_byte(player) // Write byte needed
  226. write_string(message) // Effectively write the message, finally, afterall
  227. message_end() // Needed as always
  228. }

Helló! erre van egy egyszerűbb plugin:

SMA Forráskód: [ Mindet kijelol ]
  1. new g_bad_prefix, g_listen, g_listen_flag, g_custom_current, g_custom_current_flag, g_custom_others, g_custom_others_flag, g_say_characters, g_prefix_characters;
  2. new pre_ips_count = 0, pre_names_count = 0, pre_flags_count = 0, bad_prefix_count = 0, i, temp_cvar[2];
  3. new configs_dir[64], file[128], text[128], prefix[32], type[2], acc_type[32], length, line = 0, error[256];
  4. new g_saytxt, g_maxplayers, g_nvault, g_team;
  5. new g_typed[192], g_message[192], g_name[32], typed_prefix[33];
  6. new pre_ips_collect[MAX_PREFIXES][33], ips_collect[MAX_PREFIXES][32], pre_names_collect[MAX_PREFIXES][33], names_collect[MAX_PREFIXES][33], pre_flags_collect[MAX_PREFIXES][33], flags_collect[MAX_PREFIXES][2], bad_prefixes_collect[MAX_BAD_PREFIXES][33], client_prefix[33][33];
  7.  
  8. new const forbidden_say_symbols[] = {
  9. "/",
  10. "!",
  11. "%",
  12. "$"
  13. }
  14.  
  15. new const forbidden_prefixes_symbols[] = {
  16. "/",
  17. "\",
  18. "%",
  19. "$",
  20. ".",
  21. ":",
  22. "?",
  23. "!",
  24. "@",
  25. "#",
  26. "%"
  27. }
  28.  
  29. new const separator[] = "************************************************"
  30. new const in_prefix[] = "[AdminPrefixes]"
  31.  
  32. public plugin_init()
  33. {
  34. register_plugin("Admin Prefixes", "2.2", "m0skVi4a ;]")
  35.  
  36. g_bad_prefix = register_cvar("ap_bad_prefixes", "1")
  37. g_listen = register_cvar("ap_listen", "1")
  38. g_listen_flag = register_cvar("ap_listen_flag", "a")
  39. g_custom_current = register_cvar("ap_custom_current", "1")
  40. g_custom_current_flag = register_cvar("ap_custom_current_flag", "b")
  41. g_custom_others = register_cvar("ap_custom_others", "1")
  42. g_custom_others_flag = register_cvar("ap_custom_others_flag", "c")
  43. g_say_characters = register_cvar("ap_say_characters", "1")
  44. g_prefix_characters = register_cvar("ap_prefix_characters", "1")
  45.  
  46. g_saytxt = get_user_msgid ("SayText")
  47. g_maxplayers = get_maxplayers()
  48. g_nvault = nvault_open("CustomAdminPrefixes")
  49.  
  50. register_concmd("ap_reload_prefixes", "LoadPrefixes")
  51. register_concmd("ap_reload_badprefixes", "LoadBadPrefixes")
  52. register_concmd("ap_put", "SetPrefix")
  53. register_concmd("ap_put_player", "SetPlayerPrefix")
  54. register_clcmd("say", "HookSay")
  55. register_clcmd("say_team", "HookSayTeam")
  56.  
  57. register_dictionary("admin_prefixes.txt")
  58.  
  59. get_configsdir(configs_dir, charsmax(configs_dir))
  60.  
  61. LoadPrefixes(0)
  62. LoadBadPrefixes(0)
  63. }
  64.  
  65. public LoadPrefixes(id)
  66. {
  67. if(!(get_user_flags(id) & FLAG_LOAD))
  68. {
  69. console_print(id, "%L", LANG_SERVER, "PREFIX_PERMISSION", in_prefix)
  70. return PLUGIN_HANDLED
  71. }
  72.  
  73. line = 0, pre_flags_count = 0, pre_ips_count = 0, pre_names_count = 0;
  74. formatex(file, charsmax(file), "%s/ap_prefixes.ini", configs_dir)
  75.  
  76. if(!file_exists(file))
  77. {
  78. formatex(error, charsmax(error), "%L", LANG_SERVER, "PREFIX_NOT_FOUND", in_prefix, file)
  79. set_fail_state(error)
  80. }
  81.  
  82. server_print(separator)
  83.  
  84. while(read_file(file, line++ , text, charsmax(text), length) && pre_flags_count <= MAX_PREFIXES)
  85. {
  86. if(!text[0] || text[0] == '^n' || text[0] == ';')
  87. continue
  88.  
  89. parse(text, type, charsmax(type), prefix, charsmax(prefix), acc_type, charsmax(acc_type))
  90. trim(prefix)
  91.  
  92. if(!type[0] || !prefix[0] || !acc_type[0])
  93. continue
  94.  
  95. replace_all(prefix, charsmax(prefix), "!g", "^x04")
  96. replace_all(prefix, charsmax(prefix), "!t", "^x03")
  97. replace_all(prefix, charsmax(prefix), "!n", "^x01")
  98.  
  99. switch(type[0])
  100. {
  101. case 'i':
  102. {
  103. pre_ips_count++
  104. pre_ips_collect[pre_ips_count] = prefix
  105. ips_collect[pre_ips_count] = acc_type
  106. server_print("%L", LANG_SERVER, "PREFIX_LOAD_IP", in_prefix, prefix, acc_type)
  107. }
  108. case 'n':
  109. {
  110. pre_names_count++
  111. pre_names_collect[pre_names_count] = prefix
  112. names_collect[pre_names_count] = acc_type
  113. server_print("%L", LANG_SERVER, "PREFIX_LOAD_NAME", in_prefix, prefix, acc_type)
  114. }
  115. case 'f':
  116. {
  117. pre_flags_count++
  118. pre_flags_collect[pre_flags_count] = prefix
  119. flags_collect[pre_flags_count][0] = acc_type[0]
  120. server_print("%L", LANG_SERVER, "PREFIX_LOAD_FLAG", in_prefix, prefix, acc_type[0])
  121. }
  122. default:
  123. {
  124. continue
  125. }
  126. }
  127. }
  128.  
  129. if(pre_flags_count <= 0 && pre_ips_count <= 0 && pre_names_count <= 0)
  130. {
  131. server_print("%L", LANG_SERVER, "PREFIX_NO", in_prefix)
  132. }
  133.  
  134. get_user_name(id, g_name, charsmax(g_name))
  135. server_print("%L", LANG_SERVER, "PREFIX_LOADED_BY", in_prefix, g_name)
  136. console_print(id, "%L", LANG_SERVER, "PREFIX_LOADED", in_prefix)
  137.  
  138. server_print(separator)
  139.  
  140. for(new i = 1; i <= g_maxplayers; i++)
  141. {
  142. client_prefix[id] = ""
  143. CheckNvaultPrefix(i)
  144. }
  145.  
  146. return PLUGIN_HANDLED
  147. }
  148.  
  149. public LoadBadPrefixes(id)
  150. {
  151. if(!get_pcvar_num(g_bad_prefix))
  152. {
  153. console_print(id, "%L", LANG_SERVER, "BADP_OFF", in_prefix)
  154. return PLUGIN_HANDLED
  155. }
  156.  
  157. if(!(get_user_flags(id) & FLAG_LOAD))
  158. {
  159. console_print(id, "%L", LANG_SERVER, "BADP_PERMISSION", in_prefix)
  160. return PLUGIN_HANDLED
  161. }
  162.  
  163. line = 0, bad_prefix_count = 0;
  164.  
  165. formatex(file, charsmax(file), "%s/ap_bad_prefixes.ini", configs_dir)
  166.  
  167. if(!file_exists(file))
  168. {
  169. console_print(id, "%L", LANG_SERVER, "BADP_NOT_FOUND", in_prefix, file)
  170. return PLUGIN_HANDLED
  171. }
  172.  
  173.  
  174. server_print(separator)
  175.  
  176. while(read_file(file, line++ , text, charsmax(text), length) && bad_prefix_count <= MAX_BAD_PREFIXES)
  177. {
  178. if(!text[0] || text[0] == '^n' || text[0] == ';')
  179. continue
  180.  
  181. parse(text, prefix, charsmax(prefix))
  182.  
  183. if(!prefix[0])
  184. continue
  185.  
  186. bad_prefix_count++
  187. bad_prefixes_collect[bad_prefix_count] = prefix
  188. server_print("%L", LANG_SERVER, "BADP_LOAD", in_prefix, prefix)
  189. }
  190.  
  191. if(bad_prefix_count <= 0)
  192. {
  193. server_print("%L", LANG_SERVER, "BADP_LOAD", in_prefix)
  194. }
  195.  
  196. get_user_name(id, g_name, charsmax(g_name))
  197. server_print("%L", LANG_SERVER, "BADP_LOADED_BY", in_prefix, g_name)
  198. console_print(id, "%L", LANG_SERVER, "BADP_LOADED", in_prefix)
  199.  
  200. server_print(separator)
  201.  
  202. for(new i = 1; i <= g_maxplayers; i++)
  203. {
  204. CheckNvaultPrefix(i)
  205. }
  206.  
  207. return PLUGIN_HANDLED
  208. }
  209.  
  210. public client_putinserver(id)
  211. {
  212. client_prefix[id] = ""
  213. CheckNvaultPrefix(id)
  214. }
  215.  
  216. public HookSay(id)
  217. {
  218. read_args(g_typed, charsmax(g_typed))
  219. remove_quotes(g_typed)
  220.  
  221. if(equal(g_typed, "") || !is_user_connected(id))
  222. return PLUGIN_HANDLED_MAIN
  223.  
  224. if((client_prefix[id][0] && get_pcvar_num(g_say_characters) == 1) || (!client_prefix[id][0] && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3)
  225. {
  226. if(check_say_characters(g_typed))
  227. return PLUGIN_HANDLED_MAIN
  228. }
  229.  
  230. get_user_name(id, g_name, charsmax(g_name))
  231.  
  232. g_team = get_user_team(id)
  233.  
  234. new const team_info[2][][] = {
  235. {"*SPEC* ", "*DEAD* ", "*DEAD* ", "*SPEC* "},
  236. {"", "", "", ""}
  237. }
  238.  
  239. if(client_prefix[id][0])
  240. {
  241. formatex(g_message, charsmax(g_message), "^1%s^4%s^3 %s :^4 %s", team_info[is_user_alive(id)][g_team], client_prefix[id], g_name, g_typed)
  242. }
  243. else
  244. {
  245. formatex(g_message, charsmax(g_message), "^1%s^3%s :^1 %s", team_info[is_user_alive(id)][g_team], g_name, g_typed)
  246. }
  247.  
  248. get_pcvar_string(g_listen_flag, temp_cvar, charsmax(temp_cvar))
  249.  
  250. for(new i = 1; i <= g_maxplayers; i++)
  251. {
  252. if(!is_user_connected(i))
  253. continue
  254.  
  255. if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar))
  256. {
  257. send_message(g_message, id, i)
  258. }
  259. }
  260.  
  261. return PLUGIN_HANDLED_MAIN
  262. }
  263.  
  264. public HookSayTeam(id)
  265. {
  266. read_args(g_typed, charsmax(g_typed))
  267. remove_quotes(g_typed)
  268.  
  269. if(equal(g_typed, "") || !is_user_connected(id))
  270. return PLUGIN_HANDLED_MAIN
  271.  
  272. if((client_prefix[id][0] && get_pcvar_num(g_say_characters) == 1) || (!client_prefix[id][0] && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3)
  273. {
  274. if(check_say_characters(g_typed))
  275. return PLUGIN_HANDLED_MAIN
  276. }
  277.  
  278. get_user_name(id, g_name, charsmax(g_name))
  279.  
  280. g_team = get_user_team(id)
  281.  
  282. new const team_info[2][][] = {
  283. {"(Spectator) ", "*DEAD*(Terrorist) ", "*DEAD*(Counter-Terrorist) ", "(Spectator) "},
  284. {"(Spectator) ", "(Terrorist) ", "(Counter-Terrorist) ", "(Spectator) "}
  285. }
  286.  
  287. if(client_prefix[id][0])
  288. {
  289. formatex(g_message, charsmax(g_message), "^1%s^4%s^3 %s :^4 %s", team_info[is_user_alive(id)][g_team], client_prefix[id], g_name, g_typed)
  290. }
  291. else
  292. {
  293. formatex(g_message, charsmax(g_message), "^1%s^3%s :^1 %s", team_info[is_user_alive(id)][g_team], g_name, g_typed)
  294. }
  295.  
  296. get_pcvar_string(g_listen_flag, temp_cvar, charsmax(temp_cvar))
  297.  
  298. for(new i = 1; i <= g_maxplayers; i++)
  299. {
  300. if(!is_user_connected(i))
  301. continue
  302.  
  303. if(get_user_team(id) == get_user_team(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar))
  304. {
  305. if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar))
  306. {
  307. send_message(g_message, id, i)
  308. }
  309. }
  310. }
  311.  
  312. return PLUGIN_HANDLED_MAIN
  313. }
  314.  
  315. public SetPrefix(id)
  316. {
  317. if(!get_pcvar_num(g_custom_current) || !get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar)))
  318. {
  319. console_print(id, "%L", LANG_SERVER, "CUSTOM_OFF", in_prefix)
  320. return PLUGIN_HANDLED
  321. }
  322.  
  323. if(!(get_user_flags(id) & read_flags(temp_cvar)))
  324. {
  325. console_print(id, "%L", LANG_SERVER, "CUSTOM_PERMISSION", in_prefix)
  326. return PLUGIN_HANDLED
  327. }
  328.  
  329. read_args(typed_prefix, charsmax(typed_prefix))
  330. remove_quotes(typed_prefix)
  331. trim(typed_prefix)
  332.  
  333. if(get_pcvar_num(g_bad_prefix) && is_bad_prefix(typed_prefix))
  334. {
  335. console_print(id, "%L", LANG_SERVER, "CUSTOM_FORBIDDEN", in_prefix, typed_prefix)
  336. return PLUGIN_HANDLED
  337. }
  338.  
  339. if(get_pcvar_num(g_prefix_characters) && check_prefix_characters(typed_prefix))
  340. {
  341. console_print(id, "%L", LANG_SERVER, "CUSTOM_SYMBOL", in_prefix, typed_prefix, forbidden_prefixes_symbols[i])
  342. return PLUGIN_HANDLED
  343. }
  344.  
  345. get_user_name(id, g_name, charsmax(g_name))
  346.  
  347. if(equal(typed_prefix, ""))
  348. {
  349. nvault_remove(g_nvault, g_name)
  350. console_print(id, "%L", LANG_SERVER, "CUSTOM_REMOVE", in_prefix)
  351. server_print("%L", LANG_SERVER, "CUSTOM_REMOVE_INFO", in_prefix, g_name)
  352. PutPrefix(id)
  353.  
  354. return PLUGIN_HANDLED
  355. }
  356.  
  357. nvault_set(g_nvault, g_name, typed_prefix)
  358.  
  359. client_prefix[id] = typed_prefix
  360.  
  361. console_print(id, "%L", LANG_SERVER, "CUSTOM_CHANGE", in_prefix, typed_prefix)
  362. server_print("%L", LANG_SERVER, "CUSTOM_CHANGE_INFO", in_prefix, g_name, typed_prefix)
  363.  
  364. return PLUGIN_HANDLED
  365. }
  366.  
  367. public SetPlayerPrefix(id)
  368. {
  369. if(!get_pcvar_num(g_custom_current) || !get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar)) || !get_pcvar_num(g_custom_others) || !get_pcvar_string(g_custom_others_flag, temp_cvar, charsmax(temp_cvar)))
  370. {
  371. console_print(id, "%L", LANG_SERVER, "CO_OFF", in_prefix)
  372. return PLUGIN_HANDLED
  373. }
  374.  
  375. if(!(get_user_flags(id) & read_flags(temp_cvar)))
  376. {
  377. console_print(id, "%L", LANG_SERVER, "CO_FORBIDDEN", in_prefix)
  378. return PLUGIN_HANDLED
  379. }
  380.  
  381. new name_tag[64], typed_name[32];
  382.  
  383. read_args(name_tag, charsmax(name_tag))
  384. remove_quotes(name_tag)
  385. parse(name_tag, typed_name, charsmax(typed_name), typed_prefix, charsmax(typed_prefix))
  386. trim(typed_prefix)
  387.  
  388. if(get_pcvar_num(g_bad_prefix) && is_bad_prefix(typed_prefix))
  389. {
  390. console_print(id, "%L", LANG_SERVER, "CUSTOM_FORBIDDEN", in_prefix, typed_prefix)
  391. return PLUGIN_HANDLED
  392. }
  393.  
  394. if(get_pcvar_num(g_prefix_characters) && check_prefix_characters(typed_prefix))
  395. {
  396. console_print(id, "%L", LANG_SERVER, "CUSTOM_SYMBOL", in_prefix, typed_prefix, forbidden_prefixes_symbols[i])
  397. return PLUGIN_HANDLED
  398. }
  399.  
  400. get_user_name(id, g_name, charsmax(g_name))
  401.  
  402. new target = cmd_target(id, typed_name, 1)
  403.  
  404. if(!target)
  405. return PLUGIN_HANDLED
  406.  
  407. if(equal(typed_prefix, ""))
  408. {
  409. nvault_remove(g_nvault, typed_name)
  410. console_print(id, "%L", LANG_SERVER, "CO_REMOVE", in_prefix, typed_name)
  411. server_print("%L", LANG_SERVER, "CO_REMOVE_INFO", in_prefix, g_name, typed_name)
  412. PutPrefix(target)
  413.  
  414. return PLUGIN_HANDLED
  415. }
  416.  
  417. nvault_set(g_nvault, typed_name, typed_prefix)
  418.  
  419. client_prefix[id] = typed_prefix
  420.  
  421. console_print(id, "%L", LANG_SERVER, "CO_CHANGE", in_prefix, typed_name, typed_prefix)
  422. server_print("%L", LANG_SERVER, "CO_CHANGE_INFO", in_prefix, g_name, typed_name, typed_prefix)
  423.  
  424. return PLUGIN_HANDLED
  425. }
  426.  
  427. public client_infochanged(id)
  428. {
  429. if(!is_user_connected(id))
  430. return PLUGIN_CONTINUE
  431.  
  432. new g_old_name[32];
  433.  
  434. get_user_info(id, "name", g_name, charsmax(g_name))
  435. get_user_name(id, g_old_name, charsmax(g_old_name))
  436.  
  437. if(!equal(g_name, g_old_name))
  438. {
  439. client_prefix[id] = ""
  440. set_task(0.5, "CheckNvaultPrefix", id)
  441. return PLUGIN_HANDLED
  442. }
  443.  
  444. return PLUGIN_CONTINUE
  445. }
  446.  
  447. public CheckNvaultPrefix(const id)
  448. {
  449. new nvault_prefix[33];
  450. get_user_name(id, g_name, charsmax(g_name))
  451. get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar))
  452.  
  453. new data = nvault_get(g_nvault, g_name, nvault_prefix, charsmax(nvault_prefix))
  454.  
  455. if(data && get_pcvar_num(g_custom_current) && get_user_flags(id) & read_flags(temp_cvar))
  456. {
  457. if((get_pcvar_num(g_bad_prefix) && is_bad_prefix(nvault_prefix)) || (get_pcvar_num(g_prefix_characters) && check_prefix_characters(nvault_prefix)))
  458. {
  459. PutPrefix(id)
  460. return PLUGIN_HANDLED
  461. }
  462. client_prefix[id] = nvault_prefix
  463. return PLUGIN_HANDLED
  464. }
  465. else
  466. {
  467. PutPrefix(id)
  468. return PLUGIN_HANDLED
  469. }
  470. return PLUGIN_HANDLED
  471. }
  472.  
  473. stock PutPrefix(const id)
  474. {
  475. new temp_ip[16];
  476.  
  477. get_user_ip(id, temp_ip, charsmax(temp_ip), 1)
  478.  
  479. for(new i = 0; i <= pre_ips_count; i++)
  480. {
  481. if(equal(temp_ip, ips_collect[i]))
  482. {
  483. client_prefix[id] = pre_ips_collect[i]
  484.  
  485. return PLUGIN_HANDLED
  486. }
  487. }
  488.  
  489. get_user_name(id, g_name, charsmax(g_name))
  490.  
  491. for(new i = 0; i <= pre_names_count; i++)
  492. {
  493. if(equal(g_name, names_collect[i]))
  494. {
  495. client_prefix[id] = pre_names_collect[i]
  496.  
  497. return PLUGIN_HANDLED
  498. }
  499. }
  500.  
  501. for(new i = 0; i <= pre_flags_count; i++)
  502. {
  503. if(get_user_flags(id) & read_flags(flags_collect[i]))
  504. {
  505. client_prefix[id] = pre_flags_collect[i]
  506.  
  507. return PLUGIN_HANDLED
  508. }
  509. }
  510. return PLUGIN_HANDLED
  511. }
  512.  
  513. stock send_message(const message[], const id, const i)
  514. {
  515. message_begin(MSG_ONE, g_saytxt, {0, 0, 0}, i)
  516. write_byte(id)
  517. write_string(message)
  518. message_end()
  519. }
  520.  
  521. bool:check_say_characters(const check_message[])
  522. {
  523. for(new i = 0; i < charsmax(forbidden_say_symbols); i++)
  524. {
  525. if(check_message[0] == forbidden_say_symbols[i])
  526. {
  527. return true
  528. }
  529. }
  530. return false
  531. }
  532.  
  533. bool:check_prefix_characters(const check_prefix[])
  534. {
  535. for(i = 0; i < charsmax(forbidden_prefixes_symbols); i++)
  536. {
  537. if(containi(check_prefix, forbidden_prefixes_symbols[i]) != -1)
  538. {
  539. return true
  540. }
  541. }
  542. return false
  543. }
  544.  
  545. bool:is_bad_prefix(const check_prefix[])
  546. {
  547. for(new i = 0; i <= bad_prefix_count; i++)
  548. {
  549. if(equali(check_prefix, bad_prefixes_collect[i]))
  550. {
  551. return true
  552. }
  553. }
  554. return false
  555. }


Leírás:
Előtag adás(ap_prefixes.ini-be kell írni):
"i" "[IP ELOTAG]" "192.168.1.100" - IP-re adás
"n" "[NEV ELOTAG]" "Nandee" - Névre adás
"f" "[JOG ELOTAG]" "n" - példa: n jogra adás
általánosan:
<mód i=ip n=név f=jog> <előtag> <ip/név/jog>

A WHITE CHAT -et NE tedd be, mert akkor nem tudsz majd zölden írni!

Telepítés a szokásos módon, ZIP-ben könyvtárok szerint van rendezve.
A ZIP-et itt tudod letölteni: Admin Prefixes!

__________

Megköszönni nem szégyen, ezért tedd azt! :D

_________________
See you next time! :)

Ha hasznosnak találtad a hozzászólásomat, köszönd meg a Kép lenyomásával..!! :)


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Admin írás
HozzászólásElküldve:2013.04.27. 17:30 
Offline
Jómunkásember
Avatar

Csatlakozott:2013.03.07. 18:39
Hozzászólások:352
Megköszönt másnak: 3 alkalommal
Megköszönték neki: 38 alkalommal
UlTiMaT3 írta:
Tomos írta:
Ebbe bele lehetne írni hogy akinek nincs ban joga ne [.] igy írja ki a nevét hanem [Kisadmin]-t írjon és még hogy az admin nevét zöldel írja ki és az üzenetet zölddel írja.

SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4.  
  5. #define PLUGIN "Admin Chat Colors"
  6. #define VERSION "2.0"
  7. #define AUTHOR "Arion"
  8.  
  9. #define ACCESS_LEVEL ADMIN_IMMUNITY
  10. #define ADMIN_LISTEN ADMIN_LEVEL_C
  11.  
  12. new message[192]
  13. new sayText
  14. new teamInfo
  15. new maxPlayers
  16.  
  17. new g_AdminListen
  18.  
  19. new strName[191]
  20. new alive[11]
  21.  
  22. new const g_szTag[][] = {
  23. "",
  24. "[Tulaj]",
  25. "[Admin]",
  26. "[.]"
  27. }
  28.  
  29. public plugin_init()
  30. {
  31. register_plugin(PLUGIN, VERSION, AUTHOR)
  32.  
  33. g_AdminListen = register_cvar("amx_listen", "1") // Set whether admins see or not all messages(Alive, dead and team-only)
  34.  
  35.  
  36. sayText = get_user_msgid("SayText")
  37. teamInfo = get_user_msgid("TeamInfo")
  38. maxPlayers = get_maxplayers()
  39.  
  40. register_clcmd("say", "hook_say")
  41. register_clcmd("say_team", "hook_teamsay")
  42. }
  43.  
  44. public hook_say(id)
  45. {
  46. read_args(message, 191)
  47. remove_quotes(message)
  48.  
  49. // Gungame commands and empty messages
  50. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  51. return PLUGIN_CONTINUE
  52.  
  53. new name[32]
  54. get_user_name(id, name, 31)
  55.  
  56. new admin = 0, iFlags = get_user_flags(id)
  57.  
  58. if(iFlags & ADMIN_IMMUNITY)
  59. admin = 1
  60. else if(iFlags & ADMIN_BAN)
  61. admin = 2
  62. else if(iFlags & ADMIN_RESERVATION)
  63. admin = 3
  64.  
  65. new isAlive
  66.  
  67. if(is_user_alive(id))
  68. {
  69. isAlive = 1
  70. alive = "^x01"
  71. }
  72. else
  73. {
  74. isAlive = 0
  75. alive = "^x01*DEAD* "
  76. }
  77.  
  78. static color[10]
  79.  
  80. if(admin)
  81. {
  82. get_user_team(id, color, 9)
  83. format(strName, 191, "^x04%s %s^x03%s", g_szTag[admin], alive, name)
  84. format(message, 191, "%s ^x01:^x04 %s", strName, message)
  85. }
  86. else // Player is not admin. Team-color name : Yellow message
  87. {
  88. get_user_team(id, color, 9)
  89. format(strName, 191, "%s^x03%s", alive, name)
  90. format(message, 191, "^%s^x01 : %s", strName, message)
  91. }
  92.  
  93.  
  94. sendMessage(color, isAlive) // Sends the colored message
  95.  
  96. return PLUGIN_HANDLED
  97. }
  98.  
  99.  
  100. public hook_teamsay(id)
  101. {
  102. new playerTeam = get_user_team(id)
  103. new playerTeamName[19]
  104.  
  105. switch(playerTeam) // Team names which appear on team-only messages
  106. {
  107. case 1:
  108. copy(playerTeamName, 11, "Terrorists")
  109.  
  110. case 2:
  111. copy(playerTeamName, 18, "Counter-Terrorists")
  112.  
  113. default:
  114. copy(playerTeamName, 9, "Spectator")
  115. }
  116.  
  117. read_args(message, 191)
  118. remove_quotes(message)
  119.  
  120. // Gungame commands and empty messages
  121. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  122. return PLUGIN_CONTINUE
  123.  
  124. new name[32]
  125. get_user_name(id, name, 31)
  126.  
  127. new admin = 0, iFlags = get_user_flags(id)
  128.  
  129. if(iFlags & ADMIN_IMMUNITY)
  130. admin = 1
  131. else if(iFlags & ADMIN_KICK)
  132. admin = 2
  133. else if(iFlags & ADMIN_RESERVATION)
  134. admin = 3
  135.  
  136. new isAlive
  137.  
  138. if(is_user_alive(id))
  139. {
  140. isAlive = 1
  141. alive = "^x01"
  142. }
  143. else
  144. {
  145. isAlive = 0
  146. alive = "^x01*DEAD* "
  147. }
  148.  
  149. static color[10]
  150.  
  151. if(admin)
  152. {
  153. get_user_team(id, color, 9)
  154. format(strName, 191, "%s(%s)^x04%s ^x03%s", alive, playerTeamName, g_szTag[admin], name)
  155. format(message, 191, "%s ^x01: ^x04%s", strName, message)
  156. }
  157. else // Player is not admin. Team-color name : Yellow message
  158. {
  159. get_user_team(id, color, 9)
  160. format(strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  161. format(message, 191, "%s ^x01: %s", strName, message)
  162. }
  163.  
  164.  
  165. sendTeamMessage(color, isAlive, playerTeam) // Sends the colored message
  166.  
  167. return PLUGIN_HANDLED
  168. }
  169.  
  170. public sendMessage(color[], alive)
  171. {
  172. new teamName[10]
  173.  
  174. for(new player = 1; player < maxPlayers; player++)
  175. {
  176. if(!is_user_connected(player))
  177. continue
  178.  
  179. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  180. {
  181. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  182. changeTeamInfo(player, color) // Changes user's team according to color choosen
  183. writeMessage(player, message) // Writes the message on player's chat
  184. changeTeamInfo(player, teamName) // Changes user's team back to original
  185. }
  186. }
  187. }
  188.  
  189.  
  190. public sendTeamMessage(color[], alive, playerTeam)
  191. {
  192. new teamName[10]
  193.  
  194. for(new player = 1; player < maxPlayers; player++)
  195. {
  196. if(!is_user_connected(player))
  197. continue
  198.  
  199. if(get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  200. {
  201. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  202. {
  203. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  204. changeTeamInfo(player, color) // Changes user's team according to color choosen
  205. writeMessage(player, message) // Writes the message on player's chat
  206. changeTeamInfo(player, teamName) // Changes user's team back to original
  207. }
  208. }
  209. }
  210. }
  211.  
  212.  
  213. public changeTeamInfo(player, team[])
  214. {
  215. message_begin(MSG_ONE, teamInfo, _, player) // Tells to to modify teamInfo(Which is responsable for which time player is)
  216. write_byte(player) // Write byte needed
  217. write_string(team) // Changes player's team
  218. message_end() // Also Needed
  219. }
  220.  
  221.  
  222. public writeMessage(player, message[])
  223. {
  224. message_begin(MSG_ONE, sayText, {0, 0, 0}, player) // Tells to modify sayText(Which is responsable for writing colored messages)
  225. write_byte(player) // Write byte needed
  226. write_string(message) // Effectively write the message, finally, afterall
  227. message_end() // Needed as always
  228. }

Helló! erre van egy egyszerűbb plugin:

SMA Forráskód: [ Mindet kijelol ]
  1. new g_bad_prefix, g_listen, g_listen_flag, g_custom_current, g_custom_current_flag, g_custom_others, g_custom_others_flag, g_say_characters, g_prefix_characters;
  2. new pre_ips_count = 0, pre_names_count = 0, pre_flags_count = 0, bad_prefix_count = 0, i, temp_cvar[2];
  3. new configs_dir[64], file[128], text[128], prefix[32], type[2], acc_type[32], length, line = 0, error[256];
  4. new g_saytxt, g_maxplayers, g_nvault, g_team;
  5. new g_typed[192], g_message[192], g_name[32], typed_prefix[33];
  6. new pre_ips_collect[MAX_PREFIXES][33], ips_collect[MAX_PREFIXES][32], pre_names_collect[MAX_PREFIXES][33], names_collect[MAX_PREFIXES][33], pre_flags_collect[MAX_PREFIXES][33], flags_collect[MAX_PREFIXES][2], bad_prefixes_collect[MAX_BAD_PREFIXES][33], client_prefix[33][33];
  7.  
  8. new const forbidden_say_symbols[] = {
  9. "/",
  10. "!",
  11. "%",
  12. "$"
  13. }
  14.  
  15. new const forbidden_prefixes_symbols[] = {
  16. "/",
  17. "\",
  18. "%",
  19. "$",
  20. ".",
  21. ":",
  22. "?",
  23. "!",
  24. "@",
  25. "#",
  26. "%"
  27. }
  28.  
  29. new const separator[] = "************************************************"
  30. new const in_prefix[] = "[AdminPrefixes]"
  31.  
  32. public plugin_init()
  33. {
  34. register_plugin("Admin Prefixes", "2.2", "m0skVi4a ;]")
  35.  
  36. g_bad_prefix = register_cvar("ap_bad_prefixes", "1")
  37. g_listen = register_cvar("ap_listen", "1")
  38. g_listen_flag = register_cvar("ap_listen_flag", "a")
  39. g_custom_current = register_cvar("ap_custom_current", "1")
  40. g_custom_current_flag = register_cvar("ap_custom_current_flag", "b")
  41. g_custom_others = register_cvar("ap_custom_others", "1")
  42. g_custom_others_flag = register_cvar("ap_custom_others_flag", "c")
  43. g_say_characters = register_cvar("ap_say_characters", "1")
  44. g_prefix_characters = register_cvar("ap_prefix_characters", "1")
  45.  
  46. g_saytxt = get_user_msgid ("SayText")
  47. g_maxplayers = get_maxplayers()
  48. g_nvault = nvault_open("CustomAdminPrefixes")
  49.  
  50. register_concmd("ap_reload_prefixes", "LoadPrefixes")
  51. register_concmd("ap_reload_badprefixes", "LoadBadPrefixes")
  52. register_concmd("ap_put", "SetPrefix")
  53. register_concmd("ap_put_player", "SetPlayerPrefix")
  54. register_clcmd("say", "HookSay")
  55. register_clcmd("say_team", "HookSayTeam")
  56.  
  57. register_dictionary("admin_prefixes.txt")
  58.  
  59. get_configsdir(configs_dir, charsmax(configs_dir))
  60.  
  61. LoadPrefixes(0)
  62. LoadBadPrefixes(0)
  63. }
  64.  
  65. public LoadPrefixes(id)
  66. {
  67. if(!(get_user_flags(id) & FLAG_LOAD))
  68. {
  69. console_print(id, "%L", LANG_SERVER, "PREFIX_PERMISSION", in_prefix)
  70. return PLUGIN_HANDLED
  71. }
  72.  
  73. line = 0, pre_flags_count = 0, pre_ips_count = 0, pre_names_count = 0;
  74. formatex(file, charsmax(file), "%s/ap_prefixes.ini", configs_dir)
  75.  
  76. if(!file_exists(file))
  77. {
  78. formatex(error, charsmax(error), "%L", LANG_SERVER, "PREFIX_NOT_FOUND", in_prefix, file)
  79. set_fail_state(error)
  80. }
  81.  
  82. server_print(separator)
  83.  
  84. while(read_file(file, line++ , text, charsmax(text), length) && pre_flags_count <= MAX_PREFIXES)
  85. {
  86. if(!text[0] || text[0] == '^n' || text[0] == ';')
  87. continue
  88.  
  89. parse(text, type, charsmax(type), prefix, charsmax(prefix), acc_type, charsmax(acc_type))
  90. trim(prefix)
  91.  
  92. if(!type[0] || !prefix[0] || !acc_type[0])
  93. continue
  94.  
  95. replace_all(prefix, charsmax(prefix), "!g", "^x04")
  96. replace_all(prefix, charsmax(prefix), "!t", "^x03")
  97. replace_all(prefix, charsmax(prefix), "!n", "^x01")
  98.  
  99. switch(type[0])
  100. {
  101. case 'i':
  102. {
  103. pre_ips_count++
  104. pre_ips_collect[pre_ips_count] = prefix
  105. ips_collect[pre_ips_count] = acc_type
  106. server_print("%L", LANG_SERVER, "PREFIX_LOAD_IP", in_prefix, prefix, acc_type)
  107. }
  108. case 'n':
  109. {
  110. pre_names_count++
  111. pre_names_collect[pre_names_count] = prefix
  112. names_collect[pre_names_count] = acc_type
  113. server_print("%L", LANG_SERVER, "PREFIX_LOAD_NAME", in_prefix, prefix, acc_type)
  114. }
  115. case 'f':
  116. {
  117. pre_flags_count++
  118. pre_flags_collect[pre_flags_count] = prefix
  119. flags_collect[pre_flags_count][0] = acc_type[0]
  120. server_print("%L", LANG_SERVER, "PREFIX_LOAD_FLAG", in_prefix, prefix, acc_type[0])
  121. }
  122. default:
  123. {
  124. continue
  125. }
  126. }
  127. }
  128.  
  129. if(pre_flags_count <= 0 && pre_ips_count <= 0 && pre_names_count <= 0)
  130. {
  131. server_print("%L", LANG_SERVER, "PREFIX_NO", in_prefix)
  132. }
  133.  
  134. get_user_name(id, g_name, charsmax(g_name))
  135. server_print("%L", LANG_SERVER, "PREFIX_LOADED_BY", in_prefix, g_name)
  136. console_print(id, "%L", LANG_SERVER, "PREFIX_LOADED", in_prefix)
  137.  
  138. server_print(separator)
  139.  
  140. for(new i = 1; i <= g_maxplayers; i++)
  141. {
  142. client_prefix[id] = ""
  143. CheckNvaultPrefix(i)
  144. }
  145.  
  146. return PLUGIN_HANDLED
  147. }
  148.  
  149. public LoadBadPrefixes(id)
  150. {
  151. if(!get_pcvar_num(g_bad_prefix))
  152. {
  153. console_print(id, "%L", LANG_SERVER, "BADP_OFF", in_prefix)
  154. return PLUGIN_HANDLED
  155. }
  156.  
  157. if(!(get_user_flags(id) & FLAG_LOAD))
  158. {
  159. console_print(id, "%L", LANG_SERVER, "BADP_PERMISSION", in_prefix)
  160. return PLUGIN_HANDLED
  161. }
  162.  
  163. line = 0, bad_prefix_count = 0;
  164.  
  165. formatex(file, charsmax(file), "%s/ap_bad_prefixes.ini", configs_dir)
  166.  
  167. if(!file_exists(file))
  168. {
  169. console_print(id, "%L", LANG_SERVER, "BADP_NOT_FOUND", in_prefix, file)
  170. return PLUGIN_HANDLED
  171. }
  172.  
  173.  
  174. server_print(separator)
  175.  
  176. while(read_file(file, line++ , text, charsmax(text), length) && bad_prefix_count <= MAX_BAD_PREFIXES)
  177. {
  178. if(!text[0] || text[0] == '^n' || text[0] == ';')
  179. continue
  180.  
  181. parse(text, prefix, charsmax(prefix))
  182.  
  183. if(!prefix[0])
  184. continue
  185.  
  186. bad_prefix_count++
  187. bad_prefixes_collect[bad_prefix_count] = prefix
  188. server_print("%L", LANG_SERVER, "BADP_LOAD", in_prefix, prefix)
  189. }
  190.  
  191. if(bad_prefix_count <= 0)
  192. {
  193. server_print("%L", LANG_SERVER, "BADP_LOAD", in_prefix)
  194. }
  195.  
  196. get_user_name(id, g_name, charsmax(g_name))
  197. server_print("%L", LANG_SERVER, "BADP_LOADED_BY", in_prefix, g_name)
  198. console_print(id, "%L", LANG_SERVER, "BADP_LOADED", in_prefix)
  199.  
  200. server_print(separator)
  201.  
  202. for(new i = 1; i <= g_maxplayers; i++)
  203. {
  204. CheckNvaultPrefix(i)
  205. }
  206.  
  207. return PLUGIN_HANDLED
  208. }
  209.  
  210. public client_putinserver(id)
  211. {
  212. client_prefix[id] = ""
  213. CheckNvaultPrefix(id)
  214. }
  215.  
  216. public HookSay(id)
  217. {
  218. read_args(g_typed, charsmax(g_typed))
  219. remove_quotes(g_typed)
  220.  
  221. if(equal(g_typed, "") || !is_user_connected(id))
  222. return PLUGIN_HANDLED_MAIN
  223.  
  224. if((client_prefix[id][0] && get_pcvar_num(g_say_characters) == 1) || (!client_prefix[id][0] && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3)
  225. {
  226. if(check_say_characters(g_typed))
  227. return PLUGIN_HANDLED_MAIN
  228. }
  229.  
  230. get_user_name(id, g_name, charsmax(g_name))
  231.  
  232. g_team = get_user_team(id)
  233.  
  234. new const team_info[2][][] = {
  235. {"*SPEC* ", "*DEAD* ", "*DEAD* ", "*SPEC* "},
  236. {"", "", "", ""}
  237. }
  238.  
  239. if(client_prefix[id][0])
  240. {
  241. formatex(g_message, charsmax(g_message), "^1%s^4%s^3 %s :^4 %s", team_info[is_user_alive(id)][g_team], client_prefix[id], g_name, g_typed)
  242. }
  243. else
  244. {
  245. formatex(g_message, charsmax(g_message), "^1%s^3%s :^1 %s", team_info[is_user_alive(id)][g_team], g_name, g_typed)
  246. }
  247.  
  248. get_pcvar_string(g_listen_flag, temp_cvar, charsmax(temp_cvar))
  249.  
  250. for(new i = 1; i <= g_maxplayers; i++)
  251. {
  252. if(!is_user_connected(i))
  253. continue
  254.  
  255. if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar))
  256. {
  257. send_message(g_message, id, i)
  258. }
  259. }
  260.  
  261. return PLUGIN_HANDLED_MAIN
  262. }
  263.  
  264. public HookSayTeam(id)
  265. {
  266. read_args(g_typed, charsmax(g_typed))
  267. remove_quotes(g_typed)
  268.  
  269. if(equal(g_typed, "") || !is_user_connected(id))
  270. return PLUGIN_HANDLED_MAIN
  271.  
  272. if((client_prefix[id][0] && get_pcvar_num(g_say_characters) == 1) || (!client_prefix[id][0] && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3)
  273. {
  274. if(check_say_characters(g_typed))
  275. return PLUGIN_HANDLED_MAIN
  276. }
  277.  
  278. get_user_name(id, g_name, charsmax(g_name))
  279.  
  280. g_team = get_user_team(id)
  281.  
  282. new const team_info[2][][] = {
  283. {"(Spectator) ", "*DEAD*(Terrorist) ", "*DEAD*(Counter-Terrorist) ", "(Spectator) "},
  284. {"(Spectator) ", "(Terrorist) ", "(Counter-Terrorist) ", "(Spectator) "}
  285. }
  286.  
  287. if(client_prefix[id][0])
  288. {
  289. formatex(g_message, charsmax(g_message), "^1%s^4%s^3 %s :^4 %s", team_info[is_user_alive(id)][g_team], client_prefix[id], g_name, g_typed)
  290. }
  291. else
  292. {
  293. formatex(g_message, charsmax(g_message), "^1%s^3%s :^1 %s", team_info[is_user_alive(id)][g_team], g_name, g_typed)
  294. }
  295.  
  296. get_pcvar_string(g_listen_flag, temp_cvar, charsmax(temp_cvar))
  297.  
  298. for(new i = 1; i <= g_maxplayers; i++)
  299. {
  300. if(!is_user_connected(i))
  301. continue
  302.  
  303. if(get_user_team(id) == get_user_team(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar))
  304. {
  305. if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar))
  306. {
  307. send_message(g_message, id, i)
  308. }
  309. }
  310. }
  311.  
  312. return PLUGIN_HANDLED_MAIN
  313. }
  314.  
  315. public SetPrefix(id)
  316. {
  317. if(!get_pcvar_num(g_custom_current) || !get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar)))
  318. {
  319. console_print(id, "%L", LANG_SERVER, "CUSTOM_OFF", in_prefix)
  320. return PLUGIN_HANDLED
  321. }
  322.  
  323. if(!(get_user_flags(id) & read_flags(temp_cvar)))
  324. {
  325. console_print(id, "%L", LANG_SERVER, "CUSTOM_PERMISSION", in_prefix)
  326. return PLUGIN_HANDLED
  327. }
  328.  
  329. read_args(typed_prefix, charsmax(typed_prefix))
  330. remove_quotes(typed_prefix)
  331. trim(typed_prefix)
  332.  
  333. if(get_pcvar_num(g_bad_prefix) && is_bad_prefix(typed_prefix))
  334. {
  335. console_print(id, "%L", LANG_SERVER, "CUSTOM_FORBIDDEN", in_prefix, typed_prefix)
  336. return PLUGIN_HANDLED
  337. }
  338.  
  339. if(get_pcvar_num(g_prefix_characters) && check_prefix_characters(typed_prefix))
  340. {
  341. console_print(id, "%L", LANG_SERVER, "CUSTOM_SYMBOL", in_prefix, typed_prefix, forbidden_prefixes_symbols[i])
  342. return PLUGIN_HANDLED
  343. }
  344.  
  345. get_user_name(id, g_name, charsmax(g_name))
  346.  
  347. if(equal(typed_prefix, ""))
  348. {
  349. nvault_remove(g_nvault, g_name)
  350. console_print(id, "%L", LANG_SERVER, "CUSTOM_REMOVE", in_prefix)
  351. server_print("%L", LANG_SERVER, "CUSTOM_REMOVE_INFO", in_prefix, g_name)
  352. PutPrefix(id)
  353.  
  354. return PLUGIN_HANDLED
  355. }
  356.  
  357. nvault_set(g_nvault, g_name, typed_prefix)
  358.  
  359. client_prefix[id] = typed_prefix
  360.  
  361. console_print(id, "%L", LANG_SERVER, "CUSTOM_CHANGE", in_prefix, typed_prefix)
  362. server_print("%L", LANG_SERVER, "CUSTOM_CHANGE_INFO", in_prefix, g_name, typed_prefix)
  363.  
  364. return PLUGIN_HANDLED
  365. }
  366.  
  367. public SetPlayerPrefix(id)
  368. {
  369. if(!get_pcvar_num(g_custom_current) || !get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar)) || !get_pcvar_num(g_custom_others) || !get_pcvar_string(g_custom_others_flag, temp_cvar, charsmax(temp_cvar)))
  370. {
  371. console_print(id, "%L", LANG_SERVER, "CO_OFF", in_prefix)
  372. return PLUGIN_HANDLED
  373. }
  374.  
  375. if(!(get_user_flags(id) & read_flags(temp_cvar)))
  376. {
  377. console_print(id, "%L", LANG_SERVER, "CO_FORBIDDEN", in_prefix)
  378. return PLUGIN_HANDLED
  379. }
  380.  
  381. new name_tag[64], typed_name[32];
  382.  
  383. read_args(name_tag, charsmax(name_tag))
  384. remove_quotes(name_tag)
  385. parse(name_tag, typed_name, charsmax(typed_name), typed_prefix, charsmax(typed_prefix))
  386. trim(typed_prefix)
  387.  
  388. if(get_pcvar_num(g_bad_prefix) && is_bad_prefix(typed_prefix))
  389. {
  390. console_print(id, "%L", LANG_SERVER, "CUSTOM_FORBIDDEN", in_prefix, typed_prefix)
  391. return PLUGIN_HANDLED
  392. }
  393.  
  394. if(get_pcvar_num(g_prefix_characters) && check_prefix_characters(typed_prefix))
  395. {
  396. console_print(id, "%L", LANG_SERVER, "CUSTOM_SYMBOL", in_prefix, typed_prefix, forbidden_prefixes_symbols[i])
  397. return PLUGIN_HANDLED
  398. }
  399.  
  400. get_user_name(id, g_name, charsmax(g_name))
  401.  
  402. new target = cmd_target(id, typed_name, 1)
  403.  
  404. if(!target)
  405. return PLUGIN_HANDLED
  406.  
  407. if(equal(typed_prefix, ""))
  408. {
  409. nvault_remove(g_nvault, typed_name)
  410. console_print(id, "%L", LANG_SERVER, "CO_REMOVE", in_prefix, typed_name)
  411. server_print("%L", LANG_SERVER, "CO_REMOVE_INFO", in_prefix, g_name, typed_name)
  412. PutPrefix(target)
  413.  
  414. return PLUGIN_HANDLED
  415. }
  416.  
  417. nvault_set(g_nvault, typed_name, typed_prefix)
  418.  
  419. client_prefix[id] = typed_prefix
  420.  
  421. console_print(id, "%L", LANG_SERVER, "CO_CHANGE", in_prefix, typed_name, typed_prefix)
  422. server_print("%L", LANG_SERVER, "CO_CHANGE_INFO", in_prefix, g_name, typed_name, typed_prefix)
  423.  
  424. return PLUGIN_HANDLED
  425. }
  426.  
  427. public client_infochanged(id)
  428. {
  429. if(!is_user_connected(id))
  430. return PLUGIN_CONTINUE
  431.  
  432. new g_old_name[32];
  433.  
  434. get_user_info(id, "name", g_name, charsmax(g_name))
  435. get_user_name(id, g_old_name, charsmax(g_old_name))
  436.  
  437. if(!equal(g_name, g_old_name))
  438. {
  439. client_prefix[id] = ""
  440. set_task(0.5, "CheckNvaultPrefix", id)
  441. return PLUGIN_HANDLED
  442. }
  443.  
  444. return PLUGIN_CONTINUE
  445. }
  446.  
  447. public CheckNvaultPrefix(const id)
  448. {
  449. new nvault_prefix[33];
  450. get_user_name(id, g_name, charsmax(g_name))
  451. get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar))
  452.  
  453. new data = nvault_get(g_nvault, g_name, nvault_prefix, charsmax(nvault_prefix))
  454.  
  455. if(data && get_pcvar_num(g_custom_current) && get_user_flags(id) & read_flags(temp_cvar))
  456. {
  457. if((get_pcvar_num(g_bad_prefix) && is_bad_prefix(nvault_prefix)) || (get_pcvar_num(g_prefix_characters) && check_prefix_characters(nvault_prefix)))
  458. {
  459. PutPrefix(id)
  460. return PLUGIN_HANDLED
  461. }
  462. client_prefix[id] = nvault_prefix
  463. return PLUGIN_HANDLED
  464. }
  465. else
  466. {
  467. PutPrefix(id)
  468. return PLUGIN_HANDLED
  469. }
  470. return PLUGIN_HANDLED
  471. }
  472.  
  473. stock PutPrefix(const id)
  474. {
  475. new temp_ip[16];
  476.  
  477. get_user_ip(id, temp_ip, charsmax(temp_ip), 1)
  478.  
  479. for(new i = 0; i <= pre_ips_count; i++)
  480. {
  481. if(equal(temp_ip, ips_collect[i]))
  482. {
  483. client_prefix[id] = pre_ips_collect[i]
  484.  
  485. return PLUGIN_HANDLED
  486. }
  487. }
  488.  
  489. get_user_name(id, g_name, charsmax(g_name))
  490.  
  491. for(new i = 0; i <= pre_names_count; i++)
  492. {
  493. if(equal(g_name, names_collect[i]))
  494. {
  495. client_prefix[id] = pre_names_collect[i]
  496.  
  497. return PLUGIN_HANDLED
  498. }
  499. }
  500.  
  501. for(new i = 0; i <= pre_flags_count; i++)
  502. {
  503. if(get_user_flags(id) & read_flags(flags_collect[i]))
  504. {
  505. client_prefix[id] = pre_flags_collect[i]
  506.  
  507. return PLUGIN_HANDLED
  508. }
  509. }
  510. return PLUGIN_HANDLED
  511. }
  512.  
  513. stock send_message(const message[], const id, const i)
  514. {
  515. message_begin(MSG_ONE, g_saytxt, {0, 0, 0}, i)
  516. write_byte(id)
  517. write_string(message)
  518. message_end()
  519. }
  520.  
  521. bool:check_say_characters(const check_message[])
  522. {
  523. for(new i = 0; i < charsmax(forbidden_say_symbols); i++)
  524. {
  525. if(check_message[0] == forbidden_say_symbols[i])
  526. {
  527. return true
  528. }
  529. }
  530. return false
  531. }
  532.  
  533. bool:check_prefix_characters(const check_prefix[])
  534. {
  535. for(i = 0; i < charsmax(forbidden_prefixes_symbols); i++)
  536. {
  537. if(containi(check_prefix, forbidden_prefixes_symbols[i]) != -1)
  538. {
  539. return true
  540. }
  541. }
  542. return false
  543. }
  544.  
  545. bool:is_bad_prefix(const check_prefix[])
  546. {
  547. for(new i = 0; i <= bad_prefix_count; i++)
  548. {
  549. if(equali(check_prefix, bad_prefixes_collect[i]))
  550. {
  551. return true
  552. }
  553. }
  554. return false
  555. }


Leírás:
Előtag adás(ap_prefixes.ini-be kell írni):
"i" "[IP ELOTAG]" "192.168.1.100" - IP-re adás
"n" "[NEV ELOTAG]" "Nandee" - Névre adás
"f" "[JOG ELOTAG]" "n" - példa: n jogra adás
általánosan:
<mód i=ip n=név f=jog> <előtag> <ip/név/jog>

A WHITE CHAT -et NE tedd be, mert akkor nem tudsz majd zölden írni!

Telepítés a szokásos módon, ZIP-ben könyvtárok szerint van rendezve.
A ZIP-et itt tudod letölteni: Admin Prefixes!

__________

Megköszönni nem szégyen, ezért tedd azt! :D

Ő nem ezt kérte.
Szerintem mielőtt írsz, olvasd el 100x.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Admin írás
HozzászólásElküldve:2013.04.27. 17:32 
Offline
Tud valamit

Csatlakozott:2013.01.21. 10:10
Hozzászólások:138
Megköszönt másnak: 20 alkalommal
Megköszönték neki: 6 alkalommal
tomy3231 írta:
SMA Forráskód: [ Mindet kijelol ]
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4.  
  5. #define PLUGIN "Admin Chat Colors"
  6. #define VERSION "2.0"
  7. #define AUTHOR "Arion"
  8.  
  9. #define ACCESS_LEVEL ADMIN_IMMUNITY
  10. #define ADMIN_LISTEN ADMIN_LEVEL_C
  11.  
  12. new message[192]
  13. new sayText
  14. new teamInfo
  15. new maxPlayers
  16.  
  17. new g_AdminListen
  18.  
  19. new strName[191]
  20. new alive[11]
  21.  
  22. new const g_szTag[][] = {
  23. "",
  24. "[Tulaj]",
  25. "[Admin]",
  26. "[Kisadmin]"
  27. }
  28.  
  29. public plugin_init()
  30. {
  31. register_plugin(PLUGIN, VERSION, AUTHOR)
  32.  
  33. g_AdminListen = register_cvar("amx_listen", "1") // Set whether admins see or not all messages(Alive, dead and team-only)
  34.  
  35.  
  36. sayText = get_user_msgid("SayText")
  37. teamInfo = get_user_msgid("TeamInfo")
  38. maxPlayers = get_maxplayers()
  39.  
  40. register_clcmd("say", "hook_say")
  41. register_clcmd("say_team", "hook_teamsay")
  42. }
  43.  
  44. public hook_say(id)
  45. {
  46. read_args(message, 191)
  47. remove_quotes(message)
  48.  
  49. // Gungame commands and empty messages
  50. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  51. return PLUGIN_CONTINUE
  52.  
  53. new name[32]
  54. get_user_name(id, name, 31)
  55.  
  56. new admin = 0, iFlags = get_user_flags(id)
  57.  
  58. if(iFlags & ADMIN_IMMUNITY)
  59. admin = 1
  60. else if(iFlags & ADMIN_BAN)
  61. admin = 2
  62. else if(iFlags & ADMIN_RESERVATION)
  63. admin = 3
  64.  
  65. new isAlive
  66.  
  67. if(is_user_alive(id))
  68. {
  69. isAlive = 1
  70. alive = "^x01"
  71. }
  72. else
  73. {
  74. isAlive = 0
  75. alive = "^x01*DEAD* "
  76. }
  77.  
  78. static color[10]
  79.  
  80. if(admin)
  81. {
  82. get_user_team(id, color, 9)
  83. format(strName, 191, "^x04%s %s^x03%s", g_szTag[admin], alive, name)
  84. format(message, 191, "%s ^x01:^x04 %s", strName, message)
  85. }
  86. else // Player is not admin. Team-color name : Yellow message
  87. {
  88. get_user_team(id, color, 9)
  89. format(strName, 191, "%s^x03%s", alive, name)
  90. format(message, 191, "^%s^x01 : %s", strName, message)
  91. }
  92.  
  93.  
  94. sendMessage(color, isAlive) // Sends the colored message
  95.  
  96. return PLUGIN_HANDLED
  97. }
  98.  
  99.  
  100. public hook_teamsay(id)
  101. {
  102. new playerTeam = get_user_team(id)
  103. new playerTeamName[19]
  104.  
  105. switch(playerTeam) // Team names which appear on team-only messages
  106. {
  107. case 1:
  108. copy(playerTeamName, 11, "Terrorists")
  109.  
  110. case 2:
  111. copy(playerTeamName, 18, "Counter-Terrorists")
  112.  
  113. default:
  114. copy(playerTeamName, 9, "Spectator")
  115. }
  116.  
  117. read_args(message, 191)
  118. remove_quotes(message)
  119.  
  120. // Gungame commands and empty messages
  121. if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  122. return PLUGIN_CONTINUE
  123.  
  124. new name[32]
  125. get_user_name(id, name, 31)
  126.  
  127. new admin = 0, iFlags = get_user_flags(id)
  128.  
  129. if(iFlags & ADMIN_IMMUNITY)
  130. admin = 1
  131. else if(iFlags & ADMIN_KICK)
  132. admin = 2
  133. else if(iFlags & ADMIN_RESERVATION)
  134. admin = 3
  135.  
  136. new isAlive
  137.  
  138. if(is_user_alive(id))
  139. {
  140. isAlive = 1
  141. alive = "^x01"
  142. }
  143. else
  144. {
  145. isAlive = 0
  146. alive = "^x01*DEAD* "
  147. }
  148.  
  149. static color[10]
  150.  
  151. if(admin)
  152. {
  153. get_user_team(id, color, 9)
  154. format(strName, 191, "%s(%s)^x04%s ^x04%s", alive, playerTeamName, g_szTag[admin], name)
  155. format(message, 191, "%s ^x01: ^x04%s", strName, message)
  156. }
  157. else // Player is not admin. Team-color name : Yellow message
  158. {
  159. get_user_team(id, color, 9)
  160. format(strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  161. format(message, 191, "%s ^x01: %s", strName, message)
  162. }
  163.  
  164.  
  165. sendTeamMessage(color, isAlive, playerTeam) // Sends the colored message
  166.  
  167. return PLUGIN_HANDLED
  168. }
  169.  
  170. public sendMessage(color[], alive)
  171. {
  172. new teamName[10]
  173.  
  174. for(new player = 1; player < maxPlayers; player++)
  175. {
  176. if(!is_user_connected(player))
  177. continue
  178.  
  179. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  180. {
  181. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  182. changeTeamInfo(player, color) // Changes user's team according to color choosen
  183. writeMessage(player, message) // Writes the message on player's chat
  184. changeTeamInfo(player, teamName) // Changes user's team back to original
  185. }
  186. }
  187. }
  188.  
  189.  
  190. public sendTeamMessage(color[], alive, playerTeam)
  191. {
  192. new teamName[10]
  193.  
  194. for(new player = 1; player < maxPlayers; player++)
  195. {
  196. if(!is_user_connected(player))
  197. continue
  198.  
  199. if(get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  200. {
  201. if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  202. {
  203. get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message
  204. changeTeamInfo(player, color) // Changes user's team according to color choosen
  205. writeMessage(player, message) // Writes the message on player's chat
  206. changeTeamInfo(player, teamName) // Changes user's team back to original
  207. }
  208. }
  209. }
  210. }
  211.  
  212.  
  213. public changeTeamInfo(player, team[])
  214. {
  215. message_begin(MSG_ONE, teamInfo, _, player) // Tells to to modify teamInfo(Which is responsable for which time player is)
  216. write_byte(player) // Write byte needed
  217. write_string(team) // Changes player's team
  218. message_end() // Also Needed
  219. }
  220.  
  221.  
  222. public writeMessage(player, message[])
  223. {
  224. message_begin(MSG_ONE, sayText, {0, 0, 0}, player) // Tells to modify sayText(Which is responsable for writing colored messages)
  225. write_byte(player) // Write byte needed
  226. write_string(message) // Effectively write the message, finally, afterall
  227. message_end() // Needed as always
  228. }

Teszt nemvolt.


Akinek van immunityje, az már tulaj? :D és akinek meg nincs, az ADMIN? :D
UI.: a plugin mőködik!

_________________
See you next time! :)

Ha hasznosnak találtad a hozzászólásomat, köszönd meg a Kép lenyomásával..!! :)


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  [5 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 14 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