hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.06.15. 22:38



Jelenlévő felhasználók

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

A legtöbb felhasználó (2761 fő) 2025.01.09. 20:06-kor tartózkodott itt.

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

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



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

Regisztráció

Kereső


Új téma nyitása Hozzászólás a témához  [3 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Miért kétszereződik a chat?
HozzászólásElküldve:2015.01.06. 17:11 
Offline
Senior Tag
Avatar

Csatlakozott:2013.03.10. 11:42
Hozzászólások:240
Megköszönt másnak: 52 alkalommal
Megköszönték neki: 9 alkalommal
Sziasztok!
A chatem kétszereződik ha berakom az általam összeírt plugint.
Átnézné valaki mi a hiba benne?

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

_________________
NEW IP:
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Miért kétszereződik a chat?
HozzászólásElküldve:2015.01.06. 17:36 
Offline
Őskövület
Avatar

Csatlakozott:2012.02.27. 09:42
Hozzászólások:2588
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 418 alkalommal
van bennt még 1 olyan plugin ami hookolja a say-t kapcsold ki és tádám.

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Miért kétszereződik a chat?
HozzászólásElküldve:2015.01.06. 17:48 
Offline
Senior Tag
Avatar

Csatlakozott:2013.03.10. 11:42
Hozzászólások:240
Megköszönt másnak: 52 alkalommal
Megköszönték neki: 9 alkalommal
de másik hook_say es pluginnal nem kétszereződik és azt kiszedtem természetesen és a helyére raktam ezt. :c

megoldottam:)

_________________
NEW IP:
Kép


A hozzászólást 1 alkalommal szerkesztették, utoljára theglorious 2015.01.07. 17:30-kor.
Dupla poszt!


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


Ki van itt

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