HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. Copyleft © 2014, Kidev @ www.kidev.fr
  3.  
  4. "iChat" is free software;
  5. you can redistribute it and/or modify it under the terms of the
  6. GNU General Public License as published by the Free Software Foundation.
  7.  
  8. This plugin is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12.  
  13. You should have received a copy of the GNU General Public License
  14. along with "iChat"; if not, write to the
  15. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. Boston, MA 02111-1307, USA.
  17. */
  18.  
  19. #include < amxmodx >
  20. #include < amxmisc >
  21. #include < hamsandwich >
  22. #include < fakemeta >
  23.  
  24. #pragma semicolon 1
  25.  
  26. #define ICHAT_VERSION "2.3.3"
  27. #define ICHAT_HOST "forums.alliedmods.net"
  28. #define ICHAT_THREAD "showthread.php?t=173113"
  29.  
  30. #define USE_TEAM_FIX
  31.  
  32. #define ICHAT_MAX_PLAYERS 32
  33. #define ICHAT_MAX_SAID_LEN 128
  34. #define ICHAT_MAX_MSG_LEN 496
  35. #define TASK_NOTIFY 5987
  36. #define NOTIFY_TASK_TIME 15.0
  37. #define FORMAT_MAX_SIZE 264
  38. #define FORMAT_SMALL_MAX_SIZE 36
  39. #define MAX_CUSTOM_TAGS 2
  40. #define MAX_CUSTOM_TAGS_SIZE 24
  41. #define TEAM_AA_1 0
  42. #define TEAM_AA_2 3
  43.  
  44. #define ICHAT_RETURN PLUGIN_HANDLED
  45.  
  46. #if defined USE_TEAM_FIX
  47. #define TeamInfo_PlayerID 1
  48. #define XO_PLAYER 5
  49. #define m_iTeam 114
  50. #define m_iDeaths 444
  51. new gMsgScoreInfo;
  52. #endif
  53.  
  54. enum _:formats
  55. {
  56. formatAllDefAlive = 0,
  57. formatAllAdminAlive,
  58. formatAllVIPAlive,
  59. formatTeamDefAlive,
  60. formatTeamAdminAlive,
  61. formatTeamVIPAlive,
  62. formatAllDefDead,
  63. formatAllAdminDead,
  64. formatAllVIPDead,
  65. formatTeamDefDead,
  66. formatTeamAdminDead,
  67. formatTeamVIPDead,
  68. formatMeMessage,
  69. formatMeCommand,
  70. formatClearCommand,
  71. formatMax
  72. };
  73.  
  74. enum _:formatTypes { formatDefAlive = 0, formatDefDead, formatTeamAlive, formatTeamDead, formatTypesMax };
  75. enum _:messageType { messageToAll = 0, messageToTeam };
  76. enum _:formatMode { USER = 0, ADMIN, VIP, CUSTOM };
  77. enum _:teamTags { NONE = 0, T, CT, SPEC };
  78. enum _:deadOrAlive { DEAD = 0, ALIVE };
  79. enum _:usersFlags { FLAG_RELOAD = 0, FLAG_SPY, FLAG_ADMIN, FLAG_VIP, FLAG_CHAT, FLAG_SEE_CHAT };
  80.  
  81. new gszChatFormats[ formatMax ][ FORMAT_MAX_SIZE ];
  82. new gszFormatTeamTags[ SPEC + 1 ][ ALIVE + 1 ][ FORMAT_SMALL_MAX_SIZE ];
  83. new gszAccesFlags[ FLAG_SEE_CHAT + 1 ][ 26 ];
  84. new gszCustomTags[ ICHAT_MAX_PLAYERS + 1 ][ MAX_CUSTOM_TAGS ][ MAX_CUSTOM_TAGS_SIZE ];
  85. new gszAuthid[ ICHAT_MAX_PLAYERS + 1 ][ 35 ];
  86.  
  87. new Trie:gtCustomFormats[ formatTypesMax ];
  88. new Trie:gtCustomFormatEnabled[ formatTypesMax ];
  89.  
  90. new giRemoveOnSlash;
  91. new giUserNotify;
  92. new giAdminsSpy;
  93. new giUseCustomColor;
  94. new giRemoveNameChanged;
  95. new giRed;
  96. new giGreen;
  97. new giBlue;
  98. new giPunishment;
  99. new giAllTalk;
  100. new giUseCustomTags;
  101. new giUseCustomFormats;
  102. new giForceSimplePrint;
  103. new giMustBeUpdated;
  104. new giAllowStop;
  105. new giAdminOverrides;
  106. new Float:gFlPrintRadiusAll;
  107. new Float:gFlPrintRadiusTeam;
  108.  
  109. new giCheckArray[ 3 ][ ICHAT_MAX_PLAYERS + 1 ];
  110.  
  111. #define SetUserFirstSpawn(%1) giCheckArray[0][%1]=1
  112. #define ClearUserFirstSpawn(%1) giCheckArray[0][%1]=0
  113. #define IsFirstSpawn(%1) giCheckArray[0][%1]
  114.  
  115. #define EnableUserChat(%1) giCheckArray[1][%1]=1
  116. #define DisableUserChat(%1) giCheckArray[1][%1]=0
  117. #define IsUserChatEnabled(%1) giCheckArray[1][%1]
  118.  
  119. #define SetUserVip(%1) giCheckArray[2][%1]=1
  120. #define ClearUserVip(%1) giCheckArray[2][%1]=0
  121. #define IsUserVip(%1) giCheckArray[2][%1]
  122.  
  123. new giLocation;
  124. new gszLocation[ ICHAT_MAX_PLAYERS + 1 ][ FORMAT_SMALL_MAX_SIZE ];
  125.  
  126. new gMsgSayText;
  127. new gMsgTeamInfo;
  128.  
  129. new giPluginIndex;
  130.  
  131. public plugin_init( )
  132. {
  133. giPluginIndex = register_plugin( "iChat", ICHAT_VERSION, "Kidev" );
  134.  
  135. iChatCheckErrors( );
  136.  
  137. register_dictionary( "iChat.txt" );
  138. register_dictionary( "common.txt" );
  139.  
  140. gMsgSayText = get_user_msgid( "SayText" );
  141. gMsgTeamInfo = get_user_msgid( "TeamInfo" );
  142.  
  143. #if defined USE_TEAM_FIX
  144. gMsgScoreInfo = get_user_msgid( "ScoreInfo" );
  145. #endif
  146.  
  147. register_message( gMsgSayText, "messageSayText" );
  148.  
  149. RegisterHam( Ham_Spawn, "player", "hamPlayerSpawnPost", 1 );
  150.  
  151. register_concmd( "amx_reload_ichat", "iChatReloadConfig" );
  152.  
  153. register_clcmd( "say", "iChatHookSay", 0 );
  154. register_clcmd( "say_team", "iChatHookSay", 1 );
  155.  
  156. new szModShortName[ 7 ];
  157. if ( get_modname( szModShortName, charsmax( szModShortName ) ) == 5
  158. && equal( szModShortName, "czero" ) )
  159. {
  160. register_event( "Location", "eventLocation", "be" );
  161. }
  162.  
  163. register_event( "TeamInfo", "eventTeamInfoAll", "a" );
  164.  
  165. new iSutppCvar = register_cvar( "ichat_version", ICHAT_VERSION, FCVAR_SERVER | FCVAR_EXTDLL | FCVAR_SPONLY );
  166. set_pcvar_string( iSutppCvar, ICHAT_VERSION );
  167.  
  168. new iFormatType;
  169. for ( iFormatType = 0; iFormatType < formatTypesMax; iFormatType++ )
  170. {
  171. gtCustomFormats[ iFormatType ] = TrieCreate( );
  172. gtCustomFormatEnabled[ iFormatType ] = TrieCreate( );
  173. }
  174. iChatConfig( );
  175. }
  176.  
  177. public plugin_unpause( )
  178. {
  179. iChatPause( 1, "ad", "Hiba: Valaki megprobalta leallitani az iChatet. iChat leallt.", "" );
  180. }
  181.  
  182. public iChatPause( iForcePause, const szFlags[ ], const szError[ ], const szWarning[ ] )
  183. {
  184. if ( giAllowStop || iForcePause )
  185. {
  186. log_amx( szError );
  187. pause( szFlags );
  188. }
  189. else
  190. {
  191. log_amx( szWarning );
  192. }
  193. }
  194.  
  195. public iChatCheckErrors( )
  196. {
  197. new iPluginsNum;
  198. if ( ( giPluginIndex + 1 ) < ( iPluginsNum = get_pluginsnum( ) ) )
  199. {
  200. log_amx( "The following plugins are called after iChat. You have to fix this." );
  201. new i, szFileName[ 15 ], szStatus[ 15 ];
  202. for ( i = ( giPluginIndex + 1 ); i < iPluginsNum; i++ )
  203. {
  204. if ( get_plugin( i, szFileName, charsmax( szFileName ), _, _, _, _, _, _, szStatus, charsmax( szStatus ) ) >= 0 )
  205. {
  206. log_amx( "[%d] %s is %s", ( i + 1 ), szFileName, szStatus );
  207. }
  208. else break;
  209. }
  210. iChatPause( 0, "ad", "HIBA: iChat nem az utolso a plugins.ini-ben. iChat leallt.", "FIGYELEM: Az iChat nem az utolso plugin a plugins.ini-ben." );
  211. }
  212. if ( is_plugin_loaded( "Admin Chat Colors" ) != -1 )
  213. {
  214. log_amx( "FIGYELEM: iChat ezt a plugint talalta 'Admin Chat Colors' ami eppen fut. A plugin leallitva." );
  215. pause( "acd", "Admin Chat Colors" );
  216. }
  217. }
  218.  
  219. public iChatCheckUpdates( ) // Being worked on
  220. {
  221. new iOutdated = 0;
  222. if ( iOutdated )
  223. {
  224. log_amx( "FIGYELEM: Az iChat egy regebbi verziojat hasznalod. Toltsd le a frissitest itt http://%s/%s", ICHAT_HOST, ICHAT_THREAD );
  225. giMustBeUpdated = 1;
  226. }
  227. }
  228.  
  229. public plugin_natives( )
  230. {
  231. register_library( "iChat" );
  232. register_native( "iChatSendCustomData", "iChatSendCustomData" );
  233. register_native( "iChatVipAction", "iChatVipAction" );
  234. }
  235.  
  236. public iChatReloadConfig( id )
  237. {
  238. if ( !has_flag( id, gszAccesFlags[ FLAG_RELOAD ] ) && gszAccesFlags[ FLAG_RELOAD ][ 0 ] )
  239. {
  240. client_print( id, print_console, "%L", id, "NO_ACC_COM" );
  241. return PLUGIN_HANDLED;
  242. }
  243. iChatConfig( );
  244. client_print( id, print_console, "[iChat] %L", id, "ICHAT_RELOADED" );
  245. return PLUGIN_CONTINUE;
  246. }
  247.  
  248. public iChatConfig( )
  249. {
  250. new szCfgFile[ 128 ];
  251. get_configsdir( szCfgFile, charsmax( szCfgFile ) );
  252. formatex( szCfgFile, charsmax( szCfgFile ), "%s/ichat.cfg", szCfgFile );
  253.  
  254. new iCfgFileHandle = fopen( szCfgFile, "rt" );
  255. if ( !iCfgFileHandle )
  256. {
  257. set_fail_state( "No configuration file" );
  258. return;
  259. }
  260.  
  261. new szLineData[ 364 ], szLineKey[ 96 ], szLineValue[ 264 ];
  262. while ( !feof( iCfgFileHandle ) )
  263. {
  264. fgets( iCfgFileHandle, szLineData, charsmax( szLineData ) );
  265. trim( szLineData );
  266.  
  267. if ( szLineData[ 0 ] == ';' || szLineData[ 0 ] == '#' || ( szLineData[ 0 ] == '/' && szLineData[ 1 ] == '/' ) || !szLineData[ 0 ] )
  268. {
  269. continue;
  270. }
  271.  
  272. parse( szLineData, szLineKey, charsmax( szLineKey ), szLineValue, charsmax( szLineValue ) );
  273.  
  274. switch ( szLineKey[ 0 ] )
  275. {
  276. case 'F':
  277. {
  278. switch ( szLineKey[ 7 ] )
  279. {
  280. case 'D':
  281. {
  282. switch ( szLineKey[ 11 ] )
  283. {
  284. case 'A':
  285. {
  286. if ( equal( szLineKey, "FORMAT_DEF_ALIVE" ) )
  287. {
  288. copy( gszChatFormats[ formatAllDefAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
  289. }
  290. }
  291. case 'D':
  292. {
  293. if ( equal( szLineKey, "FORMAT_DEF_DEAD" ) )
  294. {
  295. copy( gszChatFormats[ formatAllDefDead ], charsmax( gszChatFormats[ ] ), szLineValue );
  296. }
  297. }
  298. }
  299. }
  300. case 'A':
  301. {
  302. switch ( szLineKey[ 13 ] )
  303. {
  304. case 'A':
  305. {
  306. if ( equal( szLineKey, "FORMAT_ADMIN_ALIVE" ) )
  307. {
  308. copy( gszChatFormats[ formatAllAdminAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
  309. }
  310. }
  311. case 'D':
  312. {
  313. if ( equal( szLineKey, "FORMAT_ADMIN_DEAD" ) )
  314. {
  315. copy( gszChatFormats[ formatAllAdminDead ], charsmax( gszChatFormats[ ] ), szLineValue );
  316. }
  317. }
  318. }
  319. }
  320. case 'V':
  321. {
  322. switch ( szLineKey[ 11 ] )
  323. {
  324. case 'A':
  325. {
  326. if ( equal( szLineKey, "FORMAT_VIP_ALIVE" ) )
  327. {
  328. copy( gszChatFormats[ formatAllVIPAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
  329. }
  330. }
  331. case 'D':
  332. {
  333. if ( equal( szLineKey, "FORMAT_VIP_DEAD" ) )
  334. {
  335. copy( gszChatFormats[ formatAllVIPDead ], charsmax( gszChatFormats[ ] ), szLineValue );
  336. }
  337. }
  338. }
  339. }
  340. case 'T':
  341. {
  342. switch ( szLineKey[ 12 ] )
  343. {
  344. case 'D':
  345. {
  346. switch ( szLineKey[ 16 ] )
  347. {
  348. case 'A':
  349. {
  350. if ( equal( szLineKey, "FORMAT_TEAM_DEF_ALIVE" ) )
  351. {
  352. copy( gszChatFormats[ formatTeamDefAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
  353. }
  354. }
  355. case 'D':
  356. {
  357. if ( equal( szLineKey, "FORMAT_TEAM_DEF_DEAD" ) )
  358. {
  359. copy( gszChatFormats[ formatTeamDefDead ], charsmax( gszChatFormats[ ] ), szLineValue );
  360. }
  361. }
  362. }
  363. }
  364. case 'A':
  365. {
  366. switch ( szLineKey[ 18 ] )
  367. {
  368. case 'A':
  369. {
  370. if ( equal( szLineKey, "FORMAT_TEAM_ADMIN_ALIVE" ) )
  371. {
  372. copy( gszChatFormats[ formatTeamAdminAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
  373. }
  374. }
  375. case 'D':
  376. {
  377. if ( equal( szLineKey, "FORMAT_TEAM_ADMIN_DEAD" ) )
  378. {
  379. copy( gszChatFormats[ formatTeamAdminDead ], charsmax( gszChatFormats[ ] ), szLineValue );
  380. }
  381. }
  382. }
  383. }
  384. case 'V':
  385. {
  386. switch ( szLineKey[ 16 ] )
  387. {
  388. case 'A':
  389. {
  390. if ( equal( szLineKey, "FORMAT_TEAM_VIP_ALIVE" ) )
  391. {
  392. copy( gszChatFormats[ formatTeamVIPAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
  393. }
  394. }
  395. case 'D':
  396. {
  397. if ( equal( szLineKey, "FORMAT_TEAM_VIP_DEAD" ) )
  398. {
  399. copy( gszChatFormats[ formatTeamVIPDead ], charsmax( gszChatFormats[ ] ), szLineValue );
  400. }
  401. }
  402. }
  403. }
  404. }
  405. }
  406. case 'M':
  407. {
  408. switch ( szLineKey[ 10 ] )
  409. {
  410. case 'M':
  411. {
  412. if ( equal( szLineKey, "FORMAT_ME_MESSAGE" ) )
  413. {
  414. copy( gszChatFormats[ formatMeMessage ], charsmax( gszChatFormats[ ] ), szLineValue );
  415. }
  416. }
  417. case 'C':
  418. {
  419. if ( equal( szLineKey, "FORMAT_ME_COMMAND" ) )
  420. {
  421. copy( gszChatFormats[ formatMeCommand ], charsmax( gszChatFormats[ ] ), szLineValue );
  422. add( gszChatFormats[ formatMeCommand ], charsmax( gszChatFormats[ ] ), " " );
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. case 'C':
  430. {
  431. switch ( szLineKey[ 5 ] )
  432. {
  433. case 'C':
  434. {
  435. switch ( szLineKey[ 11 ] )
  436. {
  437. case 'R':
  438. {
  439. if ( equal( szLineKey, "CHAT_CLCMD_REMOVE" ) )
  440. {
  441. giRemoveOnSlash = str_to_num( szLineValue );
  442. }
  443. }
  444. case 'C':
  445. {
  446. if ( equal( szLineKey, "CHAT_CLCMD_CLEAR" ) )
  447. {
  448. copy( gszChatFormats[ formatClearCommand ], charsmax( gszChatFormats[ ] ), szLineValue );
  449. }
  450. }
  451. case 'U':
  452. {
  453. if ( equal( szLineKey, "CHAT_CHECK_UPDATES" ) )
  454. {
  455. if ( str_to_num( szLineValue ) == 1 )
  456. {
  457. giMustBeUpdated = 0;
  458. iChatCheckUpdates( );
  459. }
  460. }
  461. }
  462. case 'O':
  463. {
  464. if ( equal( szLineKey, "CHAT_CAN_STOP_ITSELF" ) )
  465. {
  466. giAllowStop = str_to_num( szLineValue );
  467. }
  468. }
  469. }
  470. }
  471. case 'F':
  472. {
  473. switch ( szLineKey[ 10 ] )
  474. {
  475. case 'R':
  476. {
  477. if ( equal( szLineKey, "CHAT_FLAG_RELOAD" ) )
  478. {
  479. if ( equal( szLineValue, "ALL" ) )
  480. {
  481. gszAccesFlags[ FLAG_RELOAD ][ 0 ] = 0;
  482. }
  483. else
  484. {
  485. copy( gszAccesFlags[ FLAG_RELOAD ], charsmax( gszAccesFlags[ ] ), szLineValue );
  486. }
  487. }
  488. }
  489. case 'S':
  490. {
  491. switch ( szLineKey[ 11 ] )
  492. {
  493. case 'P':
  494. {
  495. if ( equal( szLineKey, "CHAT_FLAG_SPY" ) )
  496. {
  497. if ( equal( szLineValue, "ALL" ) )
  498. {
  499. gszAccesFlags[ FLAG_SPY ][ 0 ] = 0;
  500. }
  501. else
  502. {
  503. copy( gszAccesFlags[ FLAG_SPY ], charsmax( gszAccesFlags[ ] ), szLineValue );
  504. }
  505. }
  506. }
  507. case 'E':
  508. {
  509. if ( equal( szLineKey, "CHAT_FLAG_SEE_CHAT" ) )
  510. {
  511. if ( equal( szLineValue, "ALL" ) )
  512. {
  513. gszAccesFlags[ FLAG_SEE_CHAT ][ 0 ] = 0;
  514. }
  515. else
  516. {
  517. copy( gszAccesFlags[ FLAG_SEE_CHAT ], charsmax( gszAccesFlags[ ] ), szLineValue );
  518. }
  519. }
  520. }
  521. }
  522. }
  523. case 'A':
  524. {
  525. if ( equal( szLineKey, "CHAT_FLAG_ADMIN" ) )
  526. {
  527. if ( equal( szLineValue, "ALL" ) )
  528. {
  529. gszAccesFlags[ FLAG_ADMIN ][ 0 ] = 0;
  530. }
  531. else
  532. {
  533. copy( gszAccesFlags[ FLAG_ADMIN ], charsmax( gszAccesFlags[ ] ), szLineValue );
  534. }
  535. }
  536. }
  537. case 'V':
  538. {
  539. if ( equal( szLineKey, "CHAT_FLAG_VIP" ) )
  540. {
  541. if ( equal( szLineValue, "ALL" ) )
  542. {
  543. gszAccesFlags[ FLAG_VIP ][ 0 ] = 0;
  544. }
  545. else
  546. {
  547. copy( gszAccesFlags[ FLAG_VIP ], charsmax( gszAccesFlags[ ] ), szLineValue );
  548. }
  549. }
  550. }
  551. case 'C':
  552. {
  553. if ( equal( szLineKey, "CHAT_FLAG_CHAT" ) )
  554. {
  555. if ( equal( szLineValue, "ALL" ) )
  556. {
  557. gszAccesFlags[ FLAG_CHAT ][ 0 ] = 0;
  558. }
  559. else
  560. {
  561. copy( gszAccesFlags[ FLAG_CHAT ], charsmax( gszAccesFlags[ ] ), szLineValue );
  562. }
  563. }
  564. }
  565. case 'L':
  566. {
  567. if ( equal( szLineKey, "CHAT_NO_COLORS" ) )
  568. {
  569. giForceSimplePrint = str_to_num( szLineValue );
  570. }
  571. }
  572. }
  573. }
  574. case 'A':
  575. {
  576. switch ( szLineKey[ 11 ] )
  577. {
  578. case 'S':
  579. {
  580. if ( equal( szLineKey, "CHAT_ADMIN_SPY" ) )
  581. {
  582. giAdminsSpy = str_to_num( szLineValue );
  583. }
  584. }
  585. case 'L':
  586. {
  587. if ( equal( szLineKey, "CHAT_ALL_TALK" ) )
  588. {
  589. giAllTalk = str_to_num( szLineValue );
  590. }
  591. }
  592. case 'O':
  593. {
  594. if ( equal( szLineKey, "CHAT_ADMIN_OVERRIDES" ) )
  595. {
  596. giAdminOverrides = str_to_num( szLineValue );
  597. }
  598. }
  599. }
  600. }
  601. case 'D':
  602. {
  603. if ( equal( szLineKey, "CHAT_DEFAULT_COLOR" ) )
  604. {
  605. new iColor = str_to_num( szLineValue );
  606. if ( iColor < 0 || iColor > 255255255 )
  607. {
  608. giUseCustomColor = 0;
  609. }
  610. else
  611. {
  612. giUseCustomColor = 1;
  613. giRed = iColor / 1000000;
  614. iColor %= 1000000;
  615. giGreen = iColor / 1000;
  616. giBlue = iColor % 1000;
  617. }
  618. }
  619. }
  620. case 'P':
  621. {
  622. if ( equal( szLineKey, "CHAT_PUNISHMENT" ) )
  623. {
  624. giPunishment = str_to_num( szLineValue );
  625. if ( giPunishment > 1 || giPunishment < 0 )
  626. {
  627. giPunishment = 1;
  628. }
  629. }
  630. }
  631. case 'N':
  632. {
  633. if ( equal( szLineKey, "CHAT_NOTIFY" ) )
  634. {
  635. giUserNotify = str_to_num( szLineValue );
  636. }
  637. }
  638. case 'R':
  639. {
  640. switch ( szLineKey[ 12 ] )
  641. {
  642. case 'A':
  643. {
  644. if ( equal( szLineKey, "CHAT_RADIUS_ALL" ) )
  645. {
  646. gFlPrintRadiusAll = str_to_float( szLineValue );
  647. }
  648. }
  649. case 'T':
  650. {
  651. if ( equal( szLineKey, "CHAT_RADIUS_TEAM" ) )
  652. {
  653. gFlPrintRadiusTeam = str_to_float( szLineValue );
  654. }
  655. }
  656. case 'C':
  657. {
  658. if ( equal( szLineKey, "CHAT_REMOVE_CHANGE_NAME" ) )
  659. {
  660. giRemoveNameChanged = str_to_num( szLineValue );
  661. }
  662. }
  663. }
  664. }
  665. case 'T':
  666. {
  667. switch ( szLineKey[ 14 ] )
  668. {
  669. case '1':
  670. {
  671. switch ( szLineKey[ 16 ] )
  672. {
  673. case 'A':
  674. {
  675. if ( equal( szLineKey, "CHAT_TEAM_TAG_1_A" ) )
  676. {
  677. copy( gszFormatTeamTags[ T ][ ALIVE ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
  678. }
  679. }
  680. case 'D':
  681. {
  682. if ( equal( szLineKey, "CHAT_TEAM_TAG_1_D" ) )
  683. {
  684. copy( gszFormatTeamTags[ T ][ DEAD ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
  685. }
  686. }
  687. }
  688. }
  689. case '2':
  690. {
  691. switch ( szLineKey[ 16 ] )
  692. {
  693. case 'A':
  694. {
  695. if ( equal( szLineKey, "CHAT_TEAM_TAG_2_A" ) )
  696. {
  697. copy( gszFormatTeamTags[ CT ][ ALIVE ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
  698. }
  699. }
  700. case 'D':
  701. {
  702. if ( equal( szLineKey, "CHAT_TEAM_TAG_2_D" ) )
  703. {
  704. copy( gszFormatTeamTags[ CT ][ DEAD ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
  705. }
  706. }
  707. }
  708. }
  709. case '3':
  710. {
  711. if ( equal( szLineKey, "CHAT_TEAM_TAG_3" ) )
  712. {
  713. copy( gszFormatTeamTags[ SPEC ][ DEAD ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
  714. }
  715. }
  716. }
  717. }
  718. case 'U':
  719. {
  720. switch ( szLineKey[ 16 ] )
  721. {
  722. case 'T':
  723. {
  724. if ( equal( szLineKey, "CHAT_USE_CUSTOM_TAGS" ) )
  725. {
  726. giUseCustomTags = str_to_num( szLineValue );
  727. }
  728. }
  729. case 'F':
  730. {
  731. if ( equal( szLineKey, "CHAT_USE_CUSTOM_FORMATS" ) )
  732. {
  733. giUseCustomFormats = str_to_num( szLineValue );
  734. }
  735. }
  736. }
  737. }
  738. }
  739. }
  740. }
  741. }
  742. fclose( iCfgFileHandle );
  743. if ( giUseCustomFormats )
  744. {
  745. iChatCustomFormats( );
  746. }
  747. }
  748.  
  749. public iChatCustomFormats( )
  750. {
  751. new szIniFile[ 128 ];
  752. get_configsdir( szIniFile, charsmax( szIniFile ) );
  753. formatex( szIniFile, charsmax( szIniFile ), "%s/ichat_custom_formats.ini", szIniFile );
  754.  
  755. new iIniFileHandle = fopen( szIniFile, "rt" );
  756. if ( !iIniFileHandle )
  757. {
  758. set_fail_state( "No custom formats file" );
  759. return;
  760. }
  761.  
  762. new szLineData[ 456 ], szLineKey[ 96 ], szLineKeyValue[ 96 ], szLineValue[ 264 ], iFormatType;
  763. for ( iFormatType = 0; iFormatType < formatTypesMax; iFormatType++ )
  764. {
  765. TrieClear( gtCustomFormats[ iFormatType ] );
  766. TrieClear( gtCustomFormatEnabled[ iFormatType ] );
  767. }
  768. while ( !feof( iIniFileHandle ) )
  769. {
  770. fgets( iIniFileHandle, szLineData, charsmax( szLineData ) );
  771. trim( szLineData );
  772.  
  773. if ( szLineData[ 0 ] == ';' || szLineData[ 0 ] == '#' || ( szLineData[ 0 ] == '/' && szLineData[ 1 ] == '/' ) || !szLineData[ 0 ] )
  774. {
  775. continue;
  776. }
  777.  
  778. parse( szLineData, szLineKey, charsmax( szLineKey ), szLineKeyValue, charsmax( szLineKeyValue ), szLineValue, charsmax( szLineValue ) );
  779.  
  780. if ( ( iFormatType = iChatGetFormatFromString( szLineKeyValue ) ) < 0 )
  781. {
  782. continue;
  783. }
  784.  
  785. if ( ( equal( szLineKey, "STEAM_", 6 ) || equal( szLineKey, "BOT" ) ) && szLineValue[ 0 ] )
  786. {
  787. TrieSetString( gtCustomFormats[ iFormatType ], szLineKey, szLineValue );
  788. TrieSetCell( gtCustomFormatEnabled[ iFormatType ], szLineKey, 1 );
  789. }
  790. }
  791. fclose( iIniFileHandle );
  792. }
  793.  
  794. public iChatGetFormatFromString( const szKey[ ] )
  795. {
  796. switch ( szKey[ 5 ] )
  797. {
  798. case 'L': return formatDefAlive;
  799. case 'E': return formatDefDead;
  800. case 'A': return formatTeamAlive;
  801. case 'D': return formatTeamDead;
  802. }
  803. return -1;
  804. }
  805.  
  806. public iChatHookSay( id, iTeamMessage )
  807. {
  808. return iChatGenerateMessage( id, iTeamMessage );
  809. }
  810.  
  811. public iChatGenerateMessage( id, iTeamMessage )
  812. {
  813. if ( !is_user_connected( id ) || ( !has_flag( id, gszAccesFlags[ FLAG_CHAT ] ) && gszAccesFlags[ FLAG_CHAT ][ 0 ] ) )
  814. {
  815. return ICHAT_RETURN;
  816. }
  817.  
  818. new szSaid[ ICHAT_MAX_SAID_LEN ], iSaidLen;
  819. iSaidLen = charsmax( szSaid );
  820. read_args( szSaid, charsmax( szSaid ) );
  821. remove_quotes( szSaid );
  822. trim( szSaid );
  823.  
  824. if ( iChatIsChatValid( szSaid ) )
  825. {
  826. iChatSendToHLSW( id, szSaid, iTeamMessage );
  827. }
  828.  
  829. if ( !contain( szSaid, gszChatFormats[ formatMeCommand ] ) )
  830. {
  831. iChatMeCommand( id, szSaid, iSaidLen );
  832. return ICHAT_RETURN;
  833. }
  834. if ( !contain( szSaid, gszChatFormats[ formatClearCommand ] ) )
  835. {
  836. iChatChangeChatStatus( id, IsUserChatEnabled( id ) );
  837. return ICHAT_RETURN;
  838. }
  839.  
  840. if ( ( !szSaid[ 0 ] )
  841. || ( ( giRemoveOnSlash && ( szSaid[ 0 ] == '/' || szSaid[ 0 ] == '@' || szSaid[ 0 ] == '!' ) ) || ( szSaid[ 0 ] == ' ' ) )
  842. || ( !IsUserChatEnabled( id ) ) )
  843. {
  844. return ICHAT_RETURN;
  845. }
  846.  
  847. new iAlive = is_user_alive( id );
  848.  
  849. new szMessage[ ICHAT_MAX_MSG_LEN ], szColor[ 16 ], szTeam[ 16 ];
  850. get_user_team( id, szTeam, charsmax( szTeam ) );
  851.  
  852. iChatFormatMessage( id, iAlive, iTeamMessage, 0, szMessage, charsmax( szMessage ), szColor, charsmax( szColor ) );
  853.  
  854. if ( giForceSimplePrint > 0 )
  855. {
  856. client_print( 0, print_chat, szMessage );
  857. return ICHAT_RETURN;
  858. }
  859.  
  860. new iGenCheck = ( giAllTalk && !iTeamMessage );
  861.  
  862. iChatChangeTeamInfo( id, szColor, iGenCheck );
  863.  
  864. if ( iGenCheck )
  865. {
  866. iChatMessageAll( id, szMessage, szSaid );
  867. }
  868. else
  869. {
  870. iChatMessageRest( id, iAlive, iTeamMessage, szMessage, szSaid );
  871. }
  872. iChatChangeTeamInfo( id, szTeam, iGenCheck );
  873. return ICHAT_RETURN;
  874. }
  875.  
  876. public iChatMeCommand( id, szSaid[ ], iSaidLen )
  877. {
  878. new szMessage[ ICHAT_MAX_MSG_LEN ], szColor[ 16 ], szTeam[ 16 ];
  879. get_user_team( id, szTeam, charsmax( szTeam ) );
  880. replace_all( szSaid, iSaidLen, gszChatFormats[ formatMeCommand ], " " );
  881. trim( szSaid );
  882.  
  883. iChatFormatMessage( id, ALIVE, 0, 1, szMessage, charsmax( szMessage ), szColor, charsmax( szColor ) );
  884. if ( giForceSimplePrint > 0 )
  885. {
  886. client_print( 0, print_chat, szMessage );
  887. }
  888. else
  889. {
  890. iChatChangeTeamInfo( id, szColor, 1 );
  891. iChatMessageAll( id, szMessage, szSaid );
  892. iChatChangeTeamInfo( id, szTeam, 1 );
  893. }
  894. }
  895.  
  896. public iChatChangeChatStatus( id, iEnabled )
  897. {
  898. if ( iEnabled )
  899. {
  900. if ( giForceSimplePrint > 0 )
  901. {
  902. client_print( id, print_chat, "[iChat] %L", id, "ICHAT_CHAT_DISABLED_NOC" );
  903. }
  904. else
  905. {
  906. iChatSimplePrint( id, "!g[iChat]!d %L", id, "ICHAT_CHAT_DISABLED" );
  907. }
  908. DisableUserChat( id );
  909. }
  910. else
  911. {
  912. EnableUserChat( id );
  913. if ( giForceSimplePrint > 0 )
  914. {
  915. client_print( id, print_chat, "[iChat] %L", id, "ICHAT_CHAT_ENABLED_NOC" );
  916. }
  917. else
  918. {
  919. iChatSimplePrint( id, "!g[iChat]!d %L", id, "ICHAT_CHAT_ENABLED" );
  920. }
  921. }
  922. }
  923.  
  924. public iChatFormatMessage( id, iAlive, iSayTeam, iMeCmd, szMessage[ ], iMessageLen, szColor[ ], iColorLen )
  925. {
  926. new szLife[ 16 ], iLife, iTeam;
  927. iLife = get_user_health( id );
  928. num_to_str( iLife, szLife, charsmax( szLife ) );
  929. iTeam = get_user_team( id );
  930. if ( iTeam < NONE || iTeam > SPEC )
  931. {
  932. iTeam = 0;
  933. }
  934.  
  935. if ( iMeCmd )
  936. {
  937. copy( szMessage, iMessageLen, gszChatFormats[ formatMeMessage ] );
  938. }
  939. else
  940. {
  941. new iFormatType = ( iSayTeam ? ( ( iAlive || iTeam == TEAM_AA_1 || iTeam == TEAM_AA_2 ) ? formatTeamAlive : formatTeamDead ) : ( ( iAlive || iTeam == TEAM_AA_1 || iTeam == TEAM_AA_2 ) ? formatDefAlive : formatDefDead ) );
  942.  
  943. new iHasCustom = 0;
  944. if ( giUseCustomFormats )
  945. {
  946. if ( TrieKeyExists( gtCustomFormatEnabled[ iFormatType ], gszAuthid[ id ] ) )
  947. {
  948. TrieGetCell( gtCustomFormatEnabled[ iFormatType ], gszAuthid[ id ], iHasCustom );
  949. }
  950. }
  951. new iModeFormat = USER;
  952. new iCrusher = ( giAdminOverrides ? ADMIN : VIP );
  953. new iCrushed = ( giAdminOverrides ? VIP : ADMIN );
  954. if ( iHasCustom )
  955. {
  956. iModeFormat = CUSTOM;
  957. }
  958. else if ( has_flag( id, gszAccesFlags[ ( iCrusher + 1 ) ] ) || !gszAccesFlags[ ( iCrusher + 1 ) ][ 0 ] )
  959. {
  960. iModeFormat = iCrusher;
  961. }
  962. else if ( has_flag( id, gszAccesFlags[ ( iCrushed + 1 ) ] ) || IsUserVip( id ) || !gszAccesFlags[ ( iCrushed + 1 ) ][ 0 ] )
  963. {
  964. iModeFormat = iCrushed;
  965. }
  966.  
  967. switch ( iModeFormat )
  968. {
  969. case USER:
  970. {
  971. switch ( iFormatType )
  972. {
  973. case formatTeamAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamDefAlive ] );
  974. case formatTeamDead: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamDefDead ] );
  975. case formatDefAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatAllDefAlive ] );
  976. case formatDefDead: copy( szMessage, iMessageLen, gszChatFormats[ formatAllDefDead ] );
  977. }
  978. }
  979. case ADMIN:
  980. {
  981. switch ( iFormatType )
  982. {
  983. case formatTeamAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamAdminAlive ] );
  984. case formatTeamDead: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamAdminDead ] );
  985. case formatDefAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatAllAdminAlive ] );
  986. case formatDefDead: copy( szMessage, iMessageLen, gszChatFormats[ formatAllAdminDead ] );
  987. }
  988. }
  989. case VIP:
  990. {
  991. switch ( iFormatType )
  992. {
  993. case formatTeamAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamVIPAlive ] );
  994. case formatTeamDead: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamVIPDead ] );
  995. case formatDefAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatAllVIPAlive ] );
  996. case formatDefDead: copy( szMessage, iMessageLen, gszChatFormats[ formatAllVIPDead ] );
  997. }
  998. }
  999. case CUSTOM:
  1000. {
  1001. TrieGetString( gtCustomFormats[ iFormatType ], gszAuthid[ id ], szMessage, iMessageLen );
  1002. }
  1003. }
  1004. }
  1005.  
  1006. new szFormatTemp[ 64 ], iCustomTagsCount;
  1007.  
  1008. replace_all( szMessage, iMessageLen, "%TEAMTAG%", gszFormatTeamTags[ iTeam ][ iAlive ] );
  1009.  
  1010. if ( giUseCustomTags )
  1011. {
  1012. for ( iCustomTagsCount = 0; iCustomTagsCount < MAX_CUSTOM_TAGS; iCustomTagsCount++ )
  1013. {
  1014. formatex( szFormatTemp, charsmax( szFormatTemp ), "#CUSTOM%i#", iCustomTagsCount );
  1015. replace_all( szMessage, iMessageLen, szFormatTemp, gszCustomTags[ id ][ iCustomTagsCount ] );
  1016. }
  1017. }
  1018.  
  1019. if ( giForceSimplePrint <= 0 )
  1020. {
  1021. replace_all( szMessage, iMessageLen, "<default>", "^1" );
  1022. replace_all( szMessage, iMessageLen, "<green>", "^4" );
  1023.  
  1024. if ( contain( szMessage, "<red>" ) != -1 )
  1025. {
  1026. copy( szColor, iColorLen, "TERRORIST" );
  1027. }
  1028. else if ( contain( szMessage, "<blue>" ) != -1 )
  1029. {
  1030. copy( szColor, iColorLen, "CT" );
  1031. }
  1032. else if ( contain( szMessage, "<grey>" ) != -1 )
  1033. {
  1034. copy( szColor, iColorLen, "SPECTATOR" );
  1035. }
  1036. else
  1037. {
  1038. get_user_team( id, szFormatTemp, iColorLen );
  1039. copy( szColor, iColorLen, szFormatTemp );
  1040. }
  1041.  
  1042. replace_all( szMessage, iMessageLen, "<team>", "^3" );
  1043. replace_all( szMessage, iMessageLen, "<red>", "^3" );
  1044. replace_all( szMessage, iMessageLen, "<blue>", "^3" );
  1045. replace_all( szMessage, iMessageLen, "<grey>", "^3" );
  1046. }
  1047.  
  1048. replace_all( szMessage, iMessageLen, "%STEAMID%", gszAuthid[ id ] );
  1049. replace_all( szMessage, iMessageLen, "%LIFE%", szLife );
  1050. replace_all( szMessage, iMessageLen, "%POS%", giLocation ? gszLocation[ id ] : "" );
  1051.  
  1052. new szLangOpt[ 16 ];
  1053. formatex( szLangOpt, charsmax( szLangOpt ), "ICHAT_TEAM%i", iTeam );
  1054. formatex( szFormatTemp, charsmax( szFormatTemp ), "%L", LANG_SERVER, szLangOpt );
  1055. replace_all( szMessage, iMessageLen, "%TEAM%", szFormatTemp );
  1056.  
  1057. replace_all( szMessage, iMessageLen, "%NAME%", "%s1" );
  1058. replace_all( szMessage, iMessageLen, "%MESSAGE%", "%s2" );
  1059. }
  1060.  
  1061. public iChatMessageAll( id, const szMessage[ ], const szSaid[ ] ) // szMessage is safe, generated by OP or plugin. szSaid is unsafe, generated by client
  1062. {
  1063. message_begin( MSG_BROADCAST, gMsgSayText, .player = id );
  1064. write_byte( id );
  1065. write_string( szMessage );
  1066. write_string( "" );
  1067. write_string( szSaid );
  1068. message_end( );
  1069. }
  1070.  
  1071. public iChatMessageRest( id, iAlive, iTeamMessage, const szMessage[ ], const szSaid[ ] )
  1072. {
  1073. new iTeam = get_user_team( id );
  1074. new iPlayers[ ICHAT_MAX_PLAYERS ], iNum, tid, iPlayerCounter, iTempAlive, iTempTeam, iTeamCheck, iRadiusCheck, iCanSeeCheck, iSupercedeCheck;
  1075. get_players( iPlayers, iNum );
  1076. for ( iPlayerCounter = 0; iPlayerCounter < iNum; iPlayerCounter++ )
  1077. {
  1078. tid = iPlayers[ iPlayerCounter ];
  1079. if ( !( iSupercedeCheck = ( id == tid ) ) )
  1080. {
  1081. iTempAlive = is_user_alive( tid );
  1082. if ( iTeamMessage )
  1083. {
  1084. iTempTeam = get_user_team( tid );
  1085. }
  1086.  
  1087. iTeamCheck = ( !iTeamMessage || ( iTeam == iTempTeam ) );
  1088. iRadiusCheck = iChatIsInRadius( id, tid, iTeamMessage, iAlive, iTempAlive );
  1089. iCanSeeCheck = ( ( has_flag( tid, gszAccesFlags[ FLAG_SEE_CHAT ] ) || !gszAccesFlags[ FLAG_SEE_CHAT ][ 0 ] ) && IsUserChatEnabled( tid ) );
  1090. }
  1091.  
  1092. if ( ( iSupercedeCheck )
  1093. || ( ( ( ( giAllTalk || ( iAlive && iTempAlive ) ) || ( !iAlive && !iTempAlive ) ) && iTeamCheck && iRadiusCheck && iCanSeeCheck )
  1094. || ( giAdminsSpy && ( has_flag( tid, gszAccesFlags[ FLAG_SPY ] ) || !gszAccesFlags[ FLAG_SPY ][ 0 ] ) )
  1095. || ( is_user_hltv( tid ) ) ) )
  1096. {
  1097. message_begin( MSG_ONE, gMsgSayText, .player = tid );
  1098. write_byte( id );
  1099. write_string( szMessage );
  1100. write_string( "" );
  1101. write_string( szSaid );
  1102. message_end( );
  1103. }
  1104. }
  1105. }
  1106.  
  1107. public iChatIsInRadius( iSender, iReceiver, iTeamMessage, iSenderAlive, iReceiverAlive )
  1108. {
  1109. new Float:flSenderOrigin[ 3 ], Float:flRecieverOrigin[ 3 ], Float:flDistance, Float:flMaxRadius;
  1110. pev( iSender, pev_origin, flSenderOrigin );
  1111. pev( iReceiver, pev_origin, flRecieverOrigin );
  1112. flDistance = get_distance_f( flSenderOrigin, flRecieverOrigin );
  1113.  
  1114. if ( iTeamMessage )
  1115. {
  1116. flMaxRadius = gFlPrintRadiusTeam;
  1117. }
  1118. else
  1119. {
  1120. flMaxRadius = gFlPrintRadiusAll;
  1121. }
  1122.  
  1123. if ( flDistance <= flMaxRadius || flMaxRadius <= 0 || !iSenderAlive || !iReceiverAlive )
  1124. {
  1125. return 1;
  1126. }
  1127. return 0;
  1128. }
  1129.  
  1130. public eventLocation( id )
  1131. {
  1132. giLocation = 1;
  1133. if ( read_data( 1 ) == id )
  1134. {
  1135. read_data( 2, gszLocation[ id ], charsmax( gszLocation[ ] ) );
  1136. }
  1137. }
  1138.  
  1139. public client_putinserver( id )
  1140. {
  1141. if ( giUserNotify )
  1142. {
  1143. set_task( NOTIFY_TASK_TIME, "iChatNotify", id + TASK_NOTIFY );
  1144. }
  1145. get_user_authid( id, gszAuthid[ id ], charsmax( gszAuthid[ ] ) );
  1146. SetUserFirstSpawn( id );
  1147. EnableUserChat( id );
  1148. }
  1149.  
  1150. public plugin_end( )
  1151. {
  1152. new iFormatType;
  1153. for ( iFormatType = 0; iFormatType < formatTypesMax; iFormatType++ )
  1154. {
  1155. TrieDestroy( gtCustomFormats[ iFormatType ] );
  1156. TrieDestroy( gtCustomFormatEnabled[ iFormatType ] );
  1157. }
  1158. }
  1159.  
  1160. public hamPlayerSpawnPost( id )
  1161. {
  1162. if ( giUseCustomColor && is_user_connected( id ) && !is_user_bot( id ) && IsFirstSpawn( id ) )
  1163. {
  1164. iChatAskChangeCvar( id );
  1165. }
  1166. ClearUserFirstSpawn( id );
  1167. }
  1168.  
  1169. public iChatAskChangeCvar( id )
  1170. {
  1171. new szMenuFormat[ 164 ], iLen = charsmax( szMenuFormat );
  1172. formatex( szMenuFormat, iLen, "%L", id, "ICHAT_MENU_TITLE", giRed, giGreen, giBlue );
  1173. new iAskMenu = menu_create( szMenuFormat, "iChatAskMenuHandler" );
  1174. new szMenuAction[ 16 ];
  1175. formatex( szMenuAction, charsmax( szMenuAction ), "ICHAT_MENU_ACTION%i", giPunishment );
  1176. formatex( szMenuFormat, iLen, "%L %L", id, "ICHAT_MENU_NO", id, szMenuAction );
  1177. menu_additem( iAskMenu, szMenuFormat );
  1178. formatex( szMenuFormat, iLen, "%L", id, "ICHAT_MENU_YES" );
  1179. menu_additem( iAskMenu, szMenuFormat );
  1180.  
  1181. menu_setprop( iAskMenu, MPROP_EXIT, MEXIT_NEVER );
  1182. menu_display( id, iAskMenu );
  1183. }
  1184.  
  1185. public iChatAskMenuHandler( id, iMenu, iItem )
  1186. {
  1187. if ( iItem == 1 )
  1188. {
  1189. client_cmd( id, "con_color ^"%i %i %i^"", giRed, giGreen, giBlue );
  1190. }
  1191. else if ( giPunishment )
  1192. {
  1193. server_cmd( "kick #%d ^"%L^"", get_user_userid( id ), id, "ICHAT_KICK_REASON" );
  1194. }
  1195. menu_destroy( iMenu );
  1196. }
  1197.  
  1198. public iChatIsChatValid( const szChat[ ] )
  1199. {
  1200. new cChar, iCharCounter;
  1201. while ( ( cChar = szChat[ iCharCounter++ ] ) != EOS )
  1202. {
  1203. if ( cChar != ' ' )
  1204. {
  1205. return 1;
  1206. }
  1207. }
  1208. return 0;
  1209. }
  1210.  
  1211. public iChatSendToHLSW( id, const szSaid[ ], iTeamMessage )
  1212. {
  1213. new szName[ 32 ], szTeam[ 10 ];
  1214. get_user_name( id, szName, charsmax( szName ) );
  1215. get_user_team( id, szTeam, charsmax( szTeam ) );
  1216. if( szTeam[ 0 ] == 'U' )
  1217. {
  1218. szTeam[ 0 ] = EOS;
  1219. }
  1220. log_message( "^"%s<%d><%s><%s>^" %s ^"%s^"%s", szName, get_user_userid( id ), gszAuthid[ id ], szTeam, ( iTeamMessage ? "say_team" : "say" ), szSaid, is_user_alive( id ) ? "" : " (dead)" );
  1221. }
  1222.  
  1223. public iChatChangeTeamInfo( id, const szColor[ ], iToAll )
  1224. {
  1225. message_begin( ( iToAll ? MSG_BROADCAST : MSG_ONE_UNRELIABLE ), gMsgTeamInfo, .player = id );
  1226. write_byte( id );
  1227. write_string( szColor );
  1228. message_end( );
  1229. }
  1230.  
  1231. public messageSayText( iMsgId, iMsgDest, iMsgEntity )
  1232. {
  1233. if ( giRemoveNameChanged )
  1234. {
  1235. new szMessage[ 196 ];
  1236. get_msg_arg_string( 2, szMessage, charsmax( szMessage ) );
  1237. if ( equal( szMessage, "#Cstrike_Name_Change" ) )
  1238. {
  1239. return PLUGIN_HANDLED;
  1240. }
  1241. }
  1242. return PLUGIN_CONTINUE;
  1243. }
  1244.  
  1245. public iChatNotify( id )
  1246. {
  1247. id -= TASK_NOTIFY;
  1248. if ( giForceSimplePrint > 0 )
  1249. {
  1250. client_print( id, print_chat, "[iChat] Ez a szerver iChatet hasznal, fejlesztoje Kidev. Letoltesi link a konzolban." );
  1251. }
  1252. else
  1253. {
  1254. iChatSimplePrint( id, "!g[iChat]!d a szerver iChatet hasznal !tiChat!d fejlesztoje !tKidev!d. Letoltesi link a konzolban." );
  1255. }
  1256. if ( giMustBeUpdated && ( has_flag( id, gszAccesFlags[ FLAG_RELOAD ] ) || !gszAccesFlags[ FLAG_RELOAD ][ 0 ] ) )
  1257. {
  1258. client_print( id, print_chat, "[iChat] FIGYELEM! iChat elavult! Ajanlott frissiteni!" );
  1259. }
  1260. client_print( id, print_console, "[iChat] Toltsd le az 'iChat'-et 'https://forums.alliedmods.net/showthread.php?t=173113'." );
  1261. client_print( id, print_console, "[iChat] Vagy githubon 'https://github.com/Kidev/iChat'" );
  1262. }
  1263.  
  1264. public iChatSimplePrint( id, const szMessage[ ], any:... ) // Do not use if clients are able to modify anything in the string passed !
  1265. {
  1266. new szBuffer[ 512 ];
  1267. vformat( szBuffer, charsmax( szBuffer ), szMessage, 3 );
  1268. replace_all( szBuffer, charsmax( szBuffer ), "!d", "^1" );
  1269. replace_all( szBuffer, charsmax( szBuffer ), "!t", "^3" );
  1270. replace_all( szBuffer, charsmax( szBuffer ), "!g", "^4" );
  1271.  
  1272. message_begin( MSG_ONE, gMsgSayText, .player = id );
  1273. write_byte( id );
  1274. write_string( szBuffer );
  1275. write_string( "" );
  1276. write_string( "" );
  1277. message_end( );
  1278. }
  1279.  
  1280. #if defined USE_TEAM_FIX
  1281. public eventTeamInfoAll( )
  1282. {
  1283. new id = read_data( TeamInfo_PlayerID );
  1284. if ( !is_user_alive( id ) && is_user_connected( id ) )
  1285. {
  1286. new iTeam = get_pdata_int( id, m_iTeam, XO_PLAYER );
  1287. if ( iTeam != get_user_team( id ) )
  1288. {
  1289. emessage_begin( MSG_BROADCAST, gMsgScoreInfo );
  1290. ewrite_byte( id );
  1291. ewrite_short( get_user_frags( id ) );
  1292. ewrite_short( get_pdata_int( id, m_iDeaths, XO_PLAYER ) );
  1293. ewrite_short( 0 );
  1294. ewrite_short( iTeam );
  1295. emessage_end( );
  1296. }
  1297. }
  1298. }
  1299. #endif
  1300.  
  1301. public iChatSendCustomData( iPlugin, iParams )
  1302. {
  1303. new iTagIndex = get_param( 2 );
  1304. new szData[ MAX_CUSTOM_TAGS_SIZE ];
  1305. get_string( 3, szData, charsmax( szData ) );
  1306. copy( gszCustomTags[ get_param( 1 ) ][ ( ( iTagIndex < 0 || iTagIndex >= MAX_CUSTOM_TAGS ) ? 0 : iTagIndex ) ], charsmax( gszCustomTags[ ][ ] ), szData );
  1307. }
  1308.  
  1309. public iChatVipAction( iPlugin, iParams )
  1310. {
  1311. new id = get_param( 1 );
  1312. switch ( get_param( 2 ) )
  1313. {
  1314. case 0: return IsUserVip( id );
  1315. case 1: return SetUserVip( id );
  1316. case 2: return ClearUserVip( id );
  1317. }
  1318. return -1;
  1319. }
  1320.