hlmod.hu
https://hlmod.hu/

admin chat colorsbol csak ékezetes plugint
https://hlmod.hu/viewtopic.php?f=10&t=8714
Oldal: 1 / 1

Szerző:  DEATH [ 2013.05.30. 11:07 ]
Hozzászólás témája:  admin chat colorsbol csak ékezetes plugint

Hello

Ebböl valaki ki tudná venni az admin chat colors ot? Meg hogy ne irjon 2szer chatben ha valaki ir?
Azaz nekem csak az ékezetek kellenének belöle mivel amit találtam tutorialok között ékezetes betüket azok nem dolgoztak.

SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. #define PLUGIN "Admin Chat Colors"
  5. #define VERSION "2.0"
  6. #define AUTHOR "Arion"
  7.  
  8. #define ACCESS_LEVEL ADMIN_CHAT
  9. #define ADMIN_LISTEN ADMIN_BAN
  10.  
  11. new message[192]
  12. new sayText
  13. new teamInfo
  14. new maxPlayers
  15.  
  16. new g_MessageColor
  17. new g_NameColor
  18. new g_AdminListen
  19.  
  20. new strName[191]
  21. new strText[191]
  22. new alive[11]
  23.  
  24. public plugin_init()
  25. {
  26. register_plugin (PLUGIN, VERSION, AUTHOR)
  27.  
  28. g_MessageColor = register_cvar ("amx_color", "2") // Message colors: [1] Default Yellow, [2] Green, [3] White, [4] Blue, [5] Red
  29.  
  30. g_NameColor = register_cvar ("amx_namecolor", "6") // Name colors: [1] Default Yellow, [2] Green, [3] White, [4] Blue, [5] Red, [6] Team-color
  31.  
  32. g_AdminListen = register_cvar ("amx_listen", "1") // Set whether admins see or not all messages (Alive, dead and team-only)
  33.  
  34.  
  35. sayText = get_user_msgid ("SayText")
  36. teamInfo = get_user_msgid ("TeamInfo")
  37. maxPlayers = get_maxplayers()
  38.  
  39.  
  40. register_message (sayText, "avoid_duplicated")
  41.  
  42. register_clcmd ("amx_color", "set_color", ACCESS_LEVEL, "<color>")
  43. register_clcmd ("amx_namecolor", "set_name_color", ACCESS_LEVEL, "<color>")
  44. register_clcmd ("amx_listen", "set_listen", ACCESS_LEVEL, "<1 | 0>")
  45.  
  46. register_clcmd ("say", "hook_say")
  47. register_clcmd ("say_team", "hook_teamsay")
  48. }
  49.  
  50.  
  51. public avoid_duplicated (msgId, msgDest, receiver)
  52. {
  53. return PLUGIN_HANDLED
  54. }
  55.  
  56.  
  57. public hook_say(id)
  58. {
  59. read_args (message, 191)
  60. remove_quotes (message)
  61.  
  62. if (message[0] == '@' || message[0] == '/' || message[0] == '!' || equal (message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  63. // Gungame commands and empty messages
  64. return PLUGIN_CONTINUE
  65.  
  66.  
  67. new name[32]
  68. get_user_name (id, name, 31)
  69.  
  70. new bool:admin = false
  71.  
  72. if (get_user_flags(id) & ACCESS_LEVEL)
  73. admin = true
  74.  
  75.  
  76. new isAlive
  77.  
  78. if (is_user_alive (id))
  79. {
  80. isAlive = 1
  81. alive = "^x01"
  82. }
  83. else
  84. {
  85. isAlive = 0
  86. alive = "^x01*DEAD* "
  87. }
  88.  
  89. static color[10]
  90.  
  91.  
  92.  
  93. if (admin)
  94. {
  95. // Name
  96. switch (get_pcvar_num (g_NameColor))
  97. {
  98. case 1:
  99. format (strName, 191, "%s%s", alive, name)
  100.  
  101. case 2:
  102. format (strName, 191, "%s^x04%s", alive, name)
  103.  
  104. case 3:
  105. {
  106. color = "SPECTATOR"
  107. format (strName, 191, "%s^x03%s", alive, name)
  108. }
  109.  
  110. case 4:
  111. {
  112. color = "CT"
  113. format (strName, 191, "%s^x03%s", alive, name)
  114. }
  115.  
  116. case 5:
  117. {
  118. color = "TERRORIST"
  119. format (strName, 191, "%s^x03%s", alive, name)
  120. }
  121.  
  122. case 6:
  123. {
  124. get_user_team (id, color, 9)
  125.  
  126. format (strName, 191, "%s^x03%s", alive, name)
  127. }
  128. }
  129.  
  130.  
  131. // Message
  132. switch (get_pcvar_num (g_MessageColor))
  133. {
  134. case 1: // Yellow
  135. format (strText, 191, "%s", message)
  136.  
  137. case 2: // Green
  138. format (strText, 191, "^x04%s", message)
  139.  
  140. case 3: // White
  141. {
  142. copy (color, 9, "SPECTATOR")
  143. format (strText, 191, "^x03%s", message)
  144. }
  145.  
  146. case 4: // Blue
  147. {
  148. copy (color, 9, "CT")
  149. format (strText, 191, "^x03%s", message)
  150. }
  151.  
  152. case 5: // Red
  153. {
  154. copy (color, 9, "TERRORIST")
  155. format (strText, 191, "^x03%s", message)
  156. }
  157. }
  158. }
  159.  
  160. else // Player is not admin. Team-color name : Yellow message
  161. {
  162. get_user_team (id, color, 9)
  163.  
  164. format (strName, 191, "%s^x03%s", alive, name)
  165.  
  166. format (strText, 191, "%s", message)
  167. }
  168.  
  169. format (message, 191, "%s^x01 : %s", strName, strText)
  170.  
  171. sendMessage (color, isAlive) // Sends the colored message
  172.  
  173. return PLUGIN_CONTINUE
  174. }
  175.  
  176.  
  177. public hook_teamsay(id)
  178. {
  179. new playerTeam = get_user_team(id)
  180. new playerTeamName[19]
  181.  
  182. switch (playerTeam) // Team names which appear on team-only messages
  183. {
  184. case 1:
  185. copy (playerTeamName, 11, "Terrorists")
  186.  
  187. case 2:
  188. copy (playerTeamName, 18, "Counter-Terrorists")
  189.  
  190. default:
  191. copy (playerTeamName, 9, "Spectator")
  192. }
  193.  
  194. read_args (message, 191)
  195. remove_quotes (message)
  196.  
  197. if (message[0] == '@' || message[0] == '/' || message[0] == '!' || equal (message, "")) // Ignores Admin Hud Messages, Admin Slash commands,
  198. // Gungame commands and empty messages
  199. return PLUGIN_CONTINUE
  200.  
  201.  
  202. new name[32]
  203. get_user_name (id, name, 31)
  204.  
  205. new bool:admin = false
  206.  
  207. if (get_user_flags(id) & ACCESS_LEVEL)
  208. admin = true
  209.  
  210.  
  211. new isAlive
  212.  
  213. if (is_user_alive (id))
  214. {
  215. isAlive = 1
  216. alive = "^x01"
  217. }
  218. else
  219. {
  220. isAlive = 0
  221. alive = "^x01*DEAD* "
  222. }
  223.  
  224. static color[10]
  225.  
  226.  
  227.  
  228. if (admin)
  229. {
  230. // Name
  231. switch (get_pcvar_num (g_NameColor))
  232. {
  233. case 1:
  234. format (strName, 191, "%s(%s) %s", alive, playerTeamName, name)
  235.  
  236. case 2:
  237. format (strName, 191, "%s(%s) ^x04%s", alive, playerTeamName, name)
  238.  
  239. case 3:
  240. {
  241. color = "SPECTATOR"
  242. format (strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  243. }
  244.  
  245. case 4:
  246. {
  247. color = "CT"
  248. format (strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  249. }
  250.  
  251. case 5:
  252. {
  253. color = "TERRORIST"
  254. format (strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  255. }
  256.  
  257. case 6:
  258. {
  259. get_user_team (id, color, 9)
  260.  
  261. format (strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  262. }
  263. }
  264.  
  265.  
  266. // Message
  267. switch (get_pcvar_num (g_MessageColor))
  268. {
  269. case 1: // Yellow
  270. format (strText, 191, "%s", message)
  271.  
  272. case 2: // Green
  273. format (strText, 191, "^x04%s", message)
  274.  
  275. case 3: // White
  276. {
  277. copy (color, 9, "SPECTATOR")
  278. format (strText, 191, "^x03%s", message)
  279. }
  280.  
  281. case 4: // Blue
  282. {
  283. copy (color, 9, "CT")
  284. format (strText, 191, "^x03%s", message)
  285. }
  286.  
  287. case 5: // Red
  288. {
  289. copy (color, 9, "TERRORIST")
  290. format (strText, 191, "^x03%s", message)
  291. }
  292. }
  293. }
  294.  
  295. else // Player is not admin. Team-color name : Yellow message
  296. {
  297. get_user_team (id, color, 9)
  298.  
  299. format (strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name)
  300.  
  301. format (strText, 191, "%s", message)
  302. }
  303.  
  304. format (message, 191, "%s ^x01: %s", strName, strText)
  305.  
  306. sendTeamMessage (color, isAlive, playerTeam) // Sends the colored message
  307.  
  308. return PLUGIN_CONTINUE
  309. }
  310.  
  311.  
  312. public set_color (id, level, cid)
  313. {
  314. if (!cmd_access(id, level, cid, 2))
  315. return PLUGIN_HANDLED
  316.  
  317. new arg[1], newColor
  318. read_argv (1, arg, 1)
  319.  
  320. newColor = str_to_num (arg)
  321.  
  322. if (newColor >= 1 && newColor <= 5)
  323. {
  324. set_cvar_num ("amx_color", newColor)
  325. set_pcvar_num (g_MessageColor, newColor)
  326.  
  327. if (get_pcvar_num (g_NameColor) != 1 &&
  328. ((newColor == 3 && get_pcvar_num (g_NameColor) != 3)
  329. || (newColor == 4 && get_pcvar_num (g_NameColor) != 4)
  330. || (newColor == 5 && get_pcvar_num (g_NameColor) != 5)))
  331. {
  332. set_cvar_num ("amx_namecolor", 2)
  333. set_pcvar_num (g_NameColor, 2)
  334. }
  335. }
  336.  
  337. return PLUGIN_HANDLED
  338. }
  339.  
  340.  
  341. public set_name_color (id, level, cid)
  342. {
  343. if (!cmd_access(id, level, cid, 2))
  344. return PLUGIN_HANDLED
  345.  
  346. new arg[1], newColor
  347. read_argv (1, arg, 1)
  348.  
  349. newColor = str_to_num (arg)
  350.  
  351. if (newColor >= 1 && newColor <= 6)
  352. {
  353. set_cvar_num ("amx_namecolor", newColor)
  354. set_pcvar_num (g_NameColor, newColor)
  355.  
  356. if ((get_pcvar_num (g_MessageColor) != 1
  357. && ((newColor == 3 && get_pcvar_num (g_MessageColor) != 3)
  358. || (newColor == 4 && get_pcvar_num (g_MessageColor) != 4)
  359. || (newColor == 5 && get_pcvar_num (g_MessageColor) != 5)))
  360. || get_pcvar_num (g_NameColor) == 6)
  361. {
  362. set_cvar_num ("amx_color", 2)
  363. set_pcvar_num (g_MessageColor, 2)
  364. }
  365. }
  366.  
  367. return PLUGIN_HANDLED
  368. }
  369.  
  370.  
  371. public set_listen (id, level, cid)
  372. {
  373. if (!cmd_access(id, level, cid, 2))
  374. return PLUGIN_HANDLED
  375.  
  376. new arg[1], newListen
  377. read_argv(1, arg, 1)
  378.  
  379. newListen = str_to_num (arg)
  380.  
  381. set_cvar_num ("amx_listen", newListen)
  382. set_pcvar_num (g_AdminListen, newListen)
  383.  
  384. return PLUGIN_HANDLED
  385. }
  386.  
  387.  
  388. public sendMessage (color[], alive)
  389. {
  390. new teamName[10]
  391.  
  392. for (new player = 1; player < maxPlayers; player++)
  393. {
  394. if (!is_user_connected(player))
  395. continue
  396.  
  397. if (alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  398. {
  399. get_user_team (player, teamName, 9) // Stores user's team name to change back after sending the message
  400.  
  401. changeTeamInfo (player, color) // Changes user's team according to color choosen
  402.  
  403. writeMessage (player, message) // Writes the message on player's chat
  404.  
  405. changeTeamInfo (player, teamName) // Changes user's team back to original
  406. }
  407. }
  408. }
  409.  
  410.  
  411. public sendTeamMessage (color[], alive, playerTeam)
  412. {
  413. new teamName[10]
  414.  
  415. for (new player = 1; player < maxPlayers; player++)
  416. {
  417. if (!is_user_connected(player))
  418. continue
  419.  
  420. if (get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  421. {
  422. if (alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
  423. {
  424. get_user_team (player, teamName, 9) // Stores user's team name to change back after sending the message
  425.  
  426. changeTeamInfo (player, color) // Changes user's team according to color choosen
  427.  
  428. writeMessage (player, message) // Writes the message on player's chat
  429.  
  430. changeTeamInfo (player, teamName) // Changes user's team back to original
  431. }
  432. }
  433. }
  434. }
  435.  
  436.  
  437. public changeTeamInfo (player, team[])
  438. {
  439. message_begin (MSG_ONE, teamInfo, _, player) // Tells to to modify teamInfo (Which is responsable for which time player is)
  440. write_byte (player) // Write byte needed
  441. write_string (team) // Changes player's team
  442. message_end() // Also Needed
  443. }
  444.  
  445.  
  446. public writeMessage (player, message[])
  447. {
  448. message_begin (MSG_ONE, sayText, {0, 0, 0}, player) // Tells to modify sayText (Which is responsable for writing colored messages)
  449. write_byte (player) // Write byte needed
  450. write_string (message) // Effectively write the message, finally, afterall
  451. message_end () // Needed as always
  452. }
  453.  

Szerző:  TysOn [ 2013.05.30. 11:57 ]
Hozzászólás témája:  Re: admin chat colorsbol csak ékezetes plugint

Hmm, hogy lehetne kivenni az admin_chat_colors-ból az admin_chat_colors-t...
2szer azért ir mindent a chatbe mert emelet fent van egy másik plugin ami "bezavar" ennek. (pl. swear_filter, allchat)

Szerző:  Papi [ 2013.06.04. 17:25 ]
Hozzászólás témája:  Re: admin chat colorsbol csak ékezetes plugint

nem..nekem ezekel amit leirtál sosem ir2x....vagy van bent más olyan dolog ami a chatet használja nem allchat-ra gondoltam ..:) hanem pl prefix vagy valami akkor az miat...

Szerző:  crazy` [ 2013.06.04. 19:59 ]
Hozzászólás témája:  Re: admin chat colorsbol csak ékezetes plugint

egyszerű...

amx_listen-t állítsd 0-ra.

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/