HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include < amxmodx >
  2. #include < amxmisc >
  3. #include < fakemeta >
  4. #include < engine >
  5. #include < sqlx >
  6.  
  7. //#define USE_ICHAT
  8.  
  9. #if defined USE_ICHAT
  10. #include < ichat >
  11. #endif
  12.  
  13. #pragma semicolon 1
  14.  
  15. #define MinOnlineTime 18000
  16. #define SubPoint 200
  17. #define MaxRang 19
  18.  
  19. new const g_sPrefix[ ] = "Prefix";
  20.  
  21. new const g_sTable[ ] = "rang_system_new";
  22. new const g_sSQL_INFOS[ ][ ] =
  23. {
  24. "Host", // HOST
  25. "Username", // USERNAME
  26. "Password", // PASSWORD
  27. "DB" // DATABASE
  28. };
  29. new Handle: g_iSqlTuple;
  30.  
  31. enum _:ePlayerInfos { iOnlineTime, iOnlineTimeW, iKills, iDeaths, iPoints, iFCTime, sPrefix[ 16 ] };
  32. enum _:eRangInfos { sRangName[ 32 ], iRangPoint };
  33.  
  34. new g_iUserData[ 33 ][ ePlayerInfos ];
  35. new const g_iRangs[ MaxRang ][ eRangInfos ] =
  36. {
  37. { "Újonc", 0 },
  38. { "Honvéd", 300 },
  39. { "Õrvezetõ", 500 },
  40. { "Tizedes", 700 },
  41. { "Szakaszvezetõ", 900 },
  42. { "Õrmester", 1100 },
  43. { "Törzsõrmester", 1400 },
  44. { "Fõtörzsõrmester", 1700 },
  45. { "Hadnagy", 2100 },
  46. { "Fõhadnagy", 2600 },
  47. { "Százados", 3300 },
  48. { "Õrnagy", 4000 },
  49. { "Alezredes", 4600 },
  50. { "Ezredes", 5300 },
  51. { "Dandártábornok", 6500 },
  52. { "Vezérnagy", 8000 },
  53. { "Altábornok", 10000 },
  54. { "Vezérezredes", 12000 },
  55. { "Egyedi prefix", 15000 }
  56. };
  57. new g_iRoundKills[ 33 ], g_iRang[ 33 ], g_sAuthID[ 33 ][ 32 ], g_sUsername[ 33 ][ 32 ], bool: g_bHud[ 33 ];
  58.  
  59. public plugin_init( )
  60. {
  61. register_plugin( "Rang Rendszer", "1.0", "Demon" );
  62. register_cvar( "Rang Rendsze", "By Demon", FCVAR_SERVER );
  63.  
  64. register_dictionary( "RangSystem.txt" );
  65.  
  66. g_iSqlTuple = SQL_MakeDbTuple( g_sSQL_INFOS[ 0 ], g_sSQL_INFOS[ 1 ], g_sSQL_INFOS[ 2 ], g_sSQL_INFOS[ 3 ] );
  67.  
  68. new sThread[ 512 ];
  69. formatex( sThread, charsmax( sThread ), "CREATE TABLE IF NOT EXISTS `%s` (`authid` varchar(32) NOT NULL,`online_time` INT(11) NOT NULL,`online_timew` INT(11) NOT NULL,`kills` INT(11) NOT NULL,`deaths` INT(11) NOT NULL,`points` INT(11) NOT NULL,`first_con_time` INT(15) NOT NULL,`prefix` varchar(16) NOT NULL,`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY);", g_sTable );
  70.  
  71. SQL_ThreadQuery( g_iSqlTuple, "ThreadHandler", sThread, { 0 }, 1 );
  72.  
  73. Load( );
  74.  
  75. register_event( "SendAudio", "evCTWin", "a", "2&%!MRAD_ctwin" );
  76. register_event( "SendAudio", "evTEWin", "a", "2&%!MRAD_terwin" );
  77. register_event( "DeathMsg", "evDeath", "a" );
  78.  
  79. register_clcmd( "say /hud", "cmdHud" );
  80. register_clcmd( "say /rang", "cmdRang" );
  81. register_clcmd( "say /myrank", "cmdRang" );
  82. register_clcmd( "say /rangok", "cmdRangs" );
  83. register_clcmd( "say /ranks", "cmdRangs" );
  84. register_clcmd( "say /prefix", "cmdPrefix" );
  85. register_clcmd( "reset_prefix", "cmdResetPrefix", ADMIN_RCON, "<jatekos> - Reset prefix." );
  86.  
  87. register_concmd( "PREFIX", "GetPrefix" );
  88.  
  89. register_forward( FM_ClientUserInfoChanged, "fwClientUserInfoChanged" );
  90. }
  91.  
  92. public plugin_natives( )
  93. {
  94. register_library( "rang_sys" );
  95. register_native( "get_user_rang", "_get_rang", 1 );
  96. }
  97.  
  98. public _get_rang( iPlayerId, sRang[ ], iLen )
  99. {
  100. param_convert( 2 );
  101. if ( g_iRang[ iPlayerId ] >= MaxRang ) copy( sRang, iLen, g_iUserData[ iPlayerId ][ sPrefix ] );
  102. else copy( sRang, iLen, g_iRangs[ g_iRang[ iPlayerId ] - 1 ][ sRangName ] );
  103. }
  104.  
  105. public SaveDatas( iPlayerId, iMode )
  106. {
  107. static sText[ 512 ];
  108.  
  109. if ( iMode == 1 ) formatex( sText, charsmax( sText ), "INSERT INTO `%s` (`authid`,`first_con_time`,`prefix`) VALUES (^"%s^",^"%d^",^"%s^");", g_sTable, g_sAuthID[ iPlayerId ], get_systime( ), g_iRangs[ MaxRang - 1 ][ sRangName ] );
  110. else if ( iMode == 2 ) formatex( sText, charsmax( sText ), "UPDATE `%s` SET online_time = ^"%d^", online_timew = ^"%d^", kills = ^"%d^", deaths = ^"%d^", points = ^"%d^", prefix = ^"%s^" WHERE authid = ^"%s^";", g_sTable, g_iUserData[ iPlayerId ][ iOnlineTime ], g_iUserData[ iPlayerId ][ iOnlineTimeW ], g_iUserData[ iPlayerId ][ iKills ], g_iUserData[ iPlayerId ][ iDeaths ], g_iUserData[ iPlayerId ][ iPoints ], g_iUserData[ iPlayerId ][ sPrefix ], g_sAuthID[ iPlayerId ] );
  111. else if ( iMode == 3 ) formatex( sText, charsmax( sText ), "UPDATE `%s` SET online_timew = ^"0^";", g_sTable );
  112. else formatex( sText, charsmax( sText ), "UPDATE `%s` SET points = points - %d WHERE %d - first_con_time > 604799 AND online_timew < %d AND points > %d;", g_sTable, SubPoint, get_systime( ), MinOnlineTime, ( SubPoint - 1 ) );
  113.  
  114. SQL_ThreadQuery( g_iSqlTuple, "ThreadHandler", sText, { 0 }, 1 );
  115. }
  116.  
  117. public LoadDatas( iPlayerId )
  118. {
  119. static sText[ 128 ], iArray[ 1 ];
  120.  
  121. formatex( sText, charsmax( sText ), "SELECT * FROM `%s` WHERE authid = ^"%s^";", g_sTable, g_sAuthID[ iPlayerId ] );
  122. iArray[ 0 ] = iPlayerId;
  123.  
  124. SQL_ThreadQuery( g_iSqlTuple, "ThreadHandler", sText, iArray, sizeof ( iArray ) );
  125. }
  126.  
  127. public ThreadHandler( iFailState, Handle:iQuery, const sErrorMsg[ ], iErrorCode, const iARRAY[ ], iArraySize, Float:fQueueTime )
  128. {
  129. if ( iFailState == TQUERY_CONNECT_FAILED )
  130. {
  131. set_fail_state( "Nem tudtam csatlakozni az adatbazishoz." );
  132. return;
  133. }
  134. else if ( iFailState == TQUERY_QUERY_FAILED )
  135. {
  136. set_fail_state( "Query Error" );
  137. return;
  138. }
  139.  
  140. if ( iErrorCode )
  141. {
  142. log_amx( "%i - %s", iErrorCode, sErrorMsg );
  143. return;
  144. }
  145.  
  146. new iPlayerId = iARRAY[ 0 ];
  147. if ( iPlayerId )
  148. {
  149. if ( SQL_NumResults( iQuery ) > 0 )
  150. {
  151. g_iUserData[ iPlayerId ][ iOnlineTime ] = SQL_ReadResult( iQuery, 1 );
  152. g_iUserData[ iPlayerId ][ iOnlineTimeW ] = SQL_ReadResult( iQuery, 2 );
  153. g_iUserData[ iPlayerId ][ iKills ] = SQL_ReadResult( iQuery, 3 );
  154. g_iUserData[ iPlayerId ][ iDeaths ] = SQL_ReadResult( iQuery, 4 );
  155. g_iUserData[ iPlayerId ][ iPoints ] = SQL_ReadResult( iQuery, 5 );
  156. g_iUserData[ iPlayerId ][ iFCTime ] = SQL_ReadResult( iQuery, 6 );
  157. SQL_ReadResult( iQuery, 7, g_iUserData[ iPlayerId ][ sPrefix ], charsmax( g_iUserData[ ][ sPrefix ] ) );
  158.  
  159. g_iRang[ iPlayerId ] = 0;
  160. for ( new i; i < MaxRang; ++i ) if ( g_iUserData[ iPlayerId ][ iPoints ] >= g_iRangs[ i ][ iRangPoint ] ) ++g_iRang[ iPlayerId ];
  161.  
  162. #if defined USE_ICHAT
  163. if ( g_iRang[ iPlayerId ] >= MaxRang ) iChatSendCustomData( iPlayerId, 0, g_iUserData[ iPlayerId ][ sPrefix ] );
  164. else iChatSendCustomData( iPlayerId, 0, g_iRangs[ g_iRang[ iPlayerId ] - 1 ][ sRangName ] );
  165. #endif
  166. }
  167. else SaveDatas( iPlayerId, 1 );
  168. }
  169.  
  170. return;
  171. }
  172.  
  173. public evCTWin( ) { GivePoint( "CT" ); }
  174. public evTEWin( ) { GivePoint( "TERRORIST" ); }
  175.  
  176. public GivePoint( const sTeam[ ] )
  177. {
  178. static iPlayers[ 32 ], iPlrNum, iPlayerId;
  179.  
  180. get_players( iPlayers, iPlrNum, "ech", sTeam );
  181.  
  182. for ( new i; i < iPlrNum; ++i )
  183. {
  184. iPlayerId = iPlayers[ i ];
  185.  
  186. if ( g_iRoundKills[ iPlayerId ] == 0 ) continue;
  187.  
  188. if ( get_playersnum( ) > 11 )
  189. {
  190. if ( 14400 <= g_iUserData[ iPlayerId ][ iOnlineTimeW ] < 21600 )
  191. g_iRoundKills[ iPlayerId ] *= 2;
  192. else if ( 21600 <= g_iUserData[ iPlayerId ][ iOnlineTimeW ] < 28800 )
  193. g_iRoundKills[ iPlayerId ] *= 3;
  194. else if ( g_iUserData[ iPlayerId ][ iOnlineTimeW ] >= 28800 )
  195. g_iRoundKills[ iPlayerId ] *= 4;
  196. }
  197.  
  198. g_iUserData[ iPlayerId ][ iPoints ] += g_iRoundKills[ iPlayerId ];
  199. if ( g_iRang[ iPlayerId ] < MaxRang )
  200. {
  201. if ( g_iUserData[ iPlayerId ][ iPoints ] >= g_iRangs[ g_iRang[ iPlayerId ] ][ iRangPoint ] )
  202. {
  203. ++g_iRang[ iPlayerId ];
  204. #if defined USE_ICHAT
  205. if ( g_iRang[ iPlayerId ] >= MaxRang ) iChatSendCustomData( iPlayerId, 0, g_iUserData[ iPlayerId ][ sPrefix ] );
  206. else iChatSendCustomData( iPlayerId, 0, g_iRangs[ g_iRang[ iPlayerId ] - 1 ][ sRangName ] );
  207. #endif
  208. }
  209. }
  210. }
  211. arrayset( g_iRoundKills, 0, sizeof( g_iRoundKills ) );
  212. }
  213.  
  214. public evDeath( )
  215. {
  216. new iKiller = read_data( 1 );
  217. new iVictim = read_data( 2 );
  218.  
  219. if ( ( iKiller != iVictim ) && !( get_user_team( iKiller ) == get_user_team( iVictim ) ))
  220. {
  221. ++g_iUserData[ iKiller ][ iKills ];
  222. ++g_iUserData[ iVictim ][ iDeaths ];
  223. ++g_iRoundKills[ iKiller ];
  224. }
  225. }
  226.  
  227. public cmdHud( iPlayerId ) { ChatColor( iPlayerId, "%L", iPlayerId, "HUD", iPlayerId, ( g_bHud[ iPlayerId ] ^= true ) ? "ON" : "OFF" ); }
  228.  
  229. public cmdRang( iPlayerId )
  230. {
  231. static sCurRang[ 32 ], sNextRang[ 32 ], iLen = 0, sMotd[ 2048 ], iMotdLen = charsmax( sMotd ), iTime;
  232. copy( sCurRang, charsmax( sCurRang ), g_iRangs[ g_iRang[ iPlayerId ] - 1 ][ sRangName ] );
  233.  
  234. iTime = get_systime( ) - g_iUserData[ iPlayerId ][ iFCTime ];
  235.  
  236. if ( g_iRang[ iPlayerId ] >= MaxRang )
  237. format( sCurRang, charsmax( sCurRang ), "%s (%s)", sCurRang, g_iUserData[ iPlayerId ][ sPrefix ] );
  238.  
  239. if ( g_iRang[ iPlayerId ] < MaxRang )
  240. copy( sNextRang, charsmax( sNextRang ), g_iRangs[ g_iRang[ iPlayerId ] ][ sRangName ] );
  241.  
  242. iLen = formatex( sMotd, iMotdLen, "<meta charset=utf-8><body bgcolor=#000000><font color=#FFB000><pre>" );
  243. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n", iPlayerId, "MOTD0", iTime / 3600,( iTime / 60 ) % 60, iTime % 60 );
  244. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n", iPlayerId, "MOTD1", g_iUserData[ iPlayerId ][ iOnlineTime ] / 3600,(g_iUserData[ iPlayerId ][ iOnlineTime ] / 60 ) % 60, g_iUserData[ iPlayerId ][ iOnlineTime ] % 60 );
  245. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n", iPlayerId, "MOTD2", g_iUserData[ iPlayerId ][ iOnlineTimeW ] / 3600, (g_iUserData[ iPlayerId ][ iOnlineTimeW ] / 60 ) % 60, g_iUserData[ iPlayerId ][ iOnlineTimeW ] % 60 );
  246. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n%L^n%L^n", iPlayerId, "MOTD3", g_iUserData[ iPlayerId ][ iKills ], iPlayerId, "MOTD4", g_iUserData[ iPlayerId ][ iDeaths ], iPlayerId, "MOTD5", g_iUserData[ iPlayerId ][ iPoints ] );
  247.  
  248. if ( g_iRang[ iPlayerId ] >= MaxRang ) iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n^n", iPlayerId, "MOTD6", sCurRang );
  249. else iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n%L^n^n", iPlayerId, "MOTD6", sCurRang, iPlayerId, "MOTD7", sNextRang, ( g_iRangs[ g_iRang[ iPlayerId ] ][ iRangPoint ] - g_iUserData[ iPlayerId ][ iPoints ] ) );
  250.  
  251. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n", iPlayerId, "MOTD8", MinOnlineTime / 3600 );
  252. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n", iPlayerId, "MOTD9" );
  253. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L^n", iPlayerId, "MOTD13" );
  254. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "%L", iPlayerId, "MOTD10" );
  255.  
  256. show_motd( iPlayerId, sMotd, "Rangrendszer info" );
  257. }
  258.  
  259. public cmdRangs( iPlayerId )
  260. {
  261. static sRang[ 32 ], iLen = 0, sMotd[ 2048 ], iMotdLen = charsmax( sMotd );
  262.  
  263. iLen = formatex( sMotd, iMotdLen, "<meta charset=utf-8><style>table{color:#FFB000;} td,th{border:1px solid #666;text-align:center;}</style><body bgcolor=#000000><center><h1><font color=#FFB000>%L</h1><br><table width='400'><tr><th>%L</th><th>%L</th><tr>", iPlayerId, "MOTD11", iPlayerId, "RANG", iPlayerId, "MOTD12" );
  264.  
  265. for ( new i; i < MaxRang; ++i )
  266. {
  267. copy( sRang, charsmax( sRang ), g_iRangs[ i ][ sRangName ] );
  268.  
  269. if ( i < g_iRang[ iPlayerId ] - 1 )
  270. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "<tr><td>%s</td><td>0</td><tr>", sRang );
  271. else if ( i == g_iRang[ iPlayerId ] - 1 )
  272. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "<tr style='background-color:#666;'><td>%s</td><td>0</td><tr>", sRang );
  273. else
  274. iLen += formatex( sMotd[ iLen ], iMotdLen - iLen, "<tr><td>%s</td><td>%d</td><tr>", sRang, ( g_iRangs[ i ][ iRangPoint ] - g_iUserData[ iPlayerId ][ iPoints ] ) );
  275. }
  276.  
  277. show_motd( iPlayerId, sMotd, "Rangrendszer info" );
  278. }
  279.  
  280. public cmdPrefix( iPlayerId )
  281. {
  282. if ( g_iRang[ iPlayerId ] < MaxRang )
  283. {
  284. ChatColor( iPlayerId, "%L", iPlayerId, "PREFIX1" );
  285. return;
  286. }
  287. ChatColor( iPlayerId, "%L", iPlayerId, "PREFIX2" );
  288. client_cmd( iPlayerId, "messagemode PREFIX" );
  289. }
  290.  
  291. public cmdResetPrefix( iPlayerId, iLevel, iCid )
  292. {
  293. if ( !cmd_access( iPlayerId, iLevel, iCid, 2 ) ) return PLUGIN_HANDLED;
  294.  
  295. static sUser[ 32 ], iPlrId;
  296. read_argv( 1, sUser, charsmax( sUser ) );
  297.  
  298. iPlrId = cmd_target( iPlayerId, sUser, ( CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF ) );
  299.  
  300. if ( !iPlrId )
  301. {
  302. ChatColor( iPlayerId, "Nincs %s nevezetű játékos.", sUser );
  303. return PLUGIN_HANDLED;
  304. }
  305.  
  306. copy( g_iUserData[ iPlrId ][ sPrefix ], charsmax( g_iUserData[ ][ sPrefix ] ), g_iRangs[ MaxRang - 1 ][ sRangName ] );
  307.  
  308. #if defined USE_ICHAT
  309. iChatSendCustomData( iPlrId, 0, g_iRangs[ MaxRang - 1 ][ sRangName ] );
  310. #endif
  311.  
  312. ChatColor( iPlayerId, "Sikeresen resetelted a jatekos prefixet." );
  313.  
  314. return PLUGIN_CONTINUE;
  315. }
  316.  
  317. public GetPrefix( iPlayerId )
  318. {
  319. if ( g_iRang[ iPlayerId ] < MaxRang ) return PLUGIN_HANDLED;
  320.  
  321. static sString[ 17 ], iLen;
  322. read_args( sString, charsmax( sString ) );
  323. remove_quotes( sString );
  324.  
  325. replace_all( sString, charsmax( sString ), "'", "" );
  326. replace_all( sString, charsmax( sString ), "^"", "" );
  327. replace_all( sString, charsmax( sString ), "`", "" );
  328.  
  329. iLen = strlen( sString );
  330.  
  331. if ( iLen < 3 || iLen > 15 )
  332. {
  333. ChatColor( iPlayerId, "%L", iPlayerId, "PREFIX3" );
  334.  
  335. return PLUGIN_HANDLED;
  336. }
  337. format( sString, charsmax( sString ), "%s", sString );
  338. copy( g_iUserData[ iPlayerId ][ sPrefix ], charsmax( g_iUserData[ ][ sPrefix ] ), sString );
  339. #if defined USE_ICHAT
  340. iChatSendCustomData( iPlayerId, 0, sString );
  341. #endif
  342. ChatColor( iPlayerId, "%L", iPlayerId, "PREFIX4", sString );
  343.  
  344. return PLUGIN_CONTINUE;
  345. }
  346.  
  347. public fwClientUserInfoChanged( iPlayerId, iBuffer )
  348. {
  349. if ( !is_user_connected( iPlayerId ) ) return FMRES_IGNORED;
  350.  
  351. static sOldName[ 32 ], sNewName[ 32 ];
  352. get_user_name( iPlayerId, sOldName, charsmax( sOldName ) );
  353.  
  354. engfunc( EngFunc_InfoKeyValue, iBuffer, "name", sNewName, charsmax( sNewName ) );
  355.  
  356. if ( equal( sNewName, sOldName ) ) return FMRES_IGNORED;
  357.  
  358. engfunc( EngFunc_SetClientKeyValue, iPlayerId, iBuffer, "name", sOldName );
  359. client_cmd( iPlayerId, "name ^"%s^"; setinfo name ^"%s^"", sOldName, sOldName );
  360.  
  361. return FMRES_SUPERCEDE;
  362. }
  363.  
  364. public OnlineTimeCounter( iPlayerId )
  365. {
  366. ++g_iUserData[ iPlayerId ][ iOnlineTime ];
  367. ++g_iUserData[ iPlayerId ][ iOnlineTimeW ];
  368.  
  369. if ( g_bHud[ iPlayerId ] )
  370. {
  371. if ( !is_user_alive( iPlayerId ) )
  372. {
  373. set_hudmessage( 0, 255, 0, 0.01, 0.20, 0, 6.0, 0.9 );
  374. new iTarget = entity_get_int( iPlayerId, EV_INT_iuser2 );
  375.  
  376. if ( iTarget != 0 )
  377. {
  378. show_hudmessage( iPlayerId, "%L^n%L^n%L^n%L^n%L^n%L^n%L", iPlayerId, "HUD1",
  379. g_sUsername[ iTarget ], iPlayerId, "HUD2",
  380. g_iUserData[ iTarget ][ iOnlineTime ] / 3600,( g_iUserData[ iTarget ][ iOnlineTime ] / 60 ) % 60, g_iUserData[ iTarget ][ iOnlineTime ] % 60, iPlayerId, "HUD3",
  381. g_iUserData[ iTarget ][ iOnlineTimeW ] / 3600, ( g_iUserData[ iTarget ][ iOnlineTimeW ] / 60 ) % 60, g_iUserData[ iTarget ][ iOnlineTimeW ] % 60, iPlayerId, "HUD4",
  382. g_iUserData[ iTarget ][ iKills ], iPlayerId, "HUD5", g_iUserData[ iTarget ][ iDeaths ], iPlayerId, "HUD6", g_iRangs[ g_iRang[ iTarget ] - 1 ][ sRangName ], g_iUserData[ iTarget ][ iPoints ], iPlayerId, "MOTD10" );
  383. }
  384. else
  385. {
  386. show_hudmessage( iPlayerId, "%L^n%L^n%L^n%L^n%L^n%L^n%L", iPlayerId, "HUD7", iPlayerId, "HUD2",
  387. g_iUserData[ iPlayerId ][ iOnlineTime ] / 3600,( g_iUserData[ iPlayerId ][ iOnlineTime ] / 60 ) % 60, g_iUserData[ iPlayerId ][ iOnlineTime ] % 60, iPlayerId, "HUD3",
  388. g_iUserData[ iPlayerId ][ iOnlineTimeW ] / 3600, ( g_iUserData[ iPlayerId ][ iOnlineTimeW ] / 60 ) % 60, g_iUserData[ iPlayerId ][ iOnlineTimeW ] % 60, iPlayerId, "HUD4",
  389. g_iUserData[ iPlayerId ][ iKills ], iPlayerId, "HUD5", g_iUserData[ iPlayerId ][ iDeaths ], iPlayerId, "HUD6", g_iRangs[ g_iRang[ iPlayerId ] - 1 ][ sRangName ], g_iUserData[ iPlayerId ][ iPoints ], iPlayerId, "MOTD10" );
  390. }
  391. }
  392. }
  393. }
  394.  
  395. public Save( iNum )
  396. {
  397. new sNewLine[ 16 ];
  398.  
  399. formatex( sNewLine, charsmax( sNewLine ), "^"%d^"", iNum );
  400. write_file( "addons/amxmodx/configs/rangsys.ini", sNewLine, 0 );
  401. }
  402.  
  403. public Load( )
  404. {
  405. new pFile = fopen( "addons/amxmodx/configs/rangsys.ini", "rt" );
  406.  
  407. if ( pFile )
  408. {
  409. new sLine[ 16 ], sTime[ 64 ], iNum;
  410. fgets( pFile, sLine, charsmax( sLine ) );
  411.  
  412. trim( sLine );
  413. remove_quotes( sLine );
  414.  
  415. iNum = str_to_num( sLine );
  416.  
  417. get_time( "%a", sTime, charsmax( sTime ) );
  418.  
  419. if ( equal( sTime, "Mon" ) )
  420. {
  421. if ( iNum == 0 )
  422. {
  423. SaveDatas( 0, 4 );
  424. Save( 1 );
  425. set_task( 2.5, "ResetOTimeW" );
  426. }
  427. }
  428. else { if ( iNum == 1 ) Save( 0 ); }
  429.  
  430. fclose(pFile);
  431. }
  432. else Save( 0 );
  433. }
  434.  
  435. public ResetOTimeW( ) { SaveDatas( 0, 3 ); }
  436.  
  437. public client_putinserver( iPlayerId )
  438. {
  439. if ( is_user_bot( iPlayerId ) || is_user_hltv( iPlayerId ) ) return;
  440.  
  441. g_iRoundKills[ iPlayerId ] = 0;
  442. g_bHud[ iPlayerId ] = true;
  443. g_iRang[ iPlayerId ] = 1;
  444.  
  445. arrayset( g_iUserData[ iPlayerId ], 0, sizeof( g_iUserData[ ] ) );
  446. copy( g_iUserData[ iPlayerId ][ sPrefix ], charsmax( g_iUserData[ ][ sPrefix ] ), g_iRangs[ MaxRang - 1 ][ sRangName ] );
  447. #if defined USE_ICHAT
  448. iChatSendCustomData( iPlayerId, 0, g_iRangs[ 0 ][ sRangName ] );
  449. #endif
  450. get_user_name( iPlayerId, g_sUsername[ iPlayerId ], charsmax( g_sUsername[ ] ) );
  451. get_user_authid( iPlayerId, g_sAuthID[ iPlayerId ], charsmax( g_sAuthID[ ] ) );
  452.  
  453. LoadDatas( iPlayerId );
  454. set_task( 1.0, "OnlineTimeCounter", iPlayerId, _, _, "b" );
  455. }
  456.  
  457. public client_disconnect( iPlayerId ) { if ( task_exists( iPlayerId ) ) remove_task( iPlayerId ); SaveDatas( iPlayerId, 2 ); }
  458. public plugin_end( ) { SQL_FreeHandle( g_iSqlTuple ); }
  459.  
  460. stock ChatColor( iPlayerId, const sMessage[ ], any:... )
  461. {
  462. static iPlrNum, iPlayers[ 32 ], sMsg[ 256 ], iIdMsg, iMsgLen = charsmax( sMsg );
  463.  
  464. vformat( sMsg, iMsgLen, sMessage, 3 );
  465. format( sMsg, iMsgLen, "!g[%s]!y %s", g_sPrefix, sMsg );
  466.  
  467. replace_all( sMsg, iMsgLen, "!g", "^4" );
  468. replace_all( sMsg, iMsgLen, "!y", "^1" );
  469. replace_all( sMsg, iMsgLen, "!t", "^3" );
  470.  
  471. if ( !iIdMsg ) iIdMsg = get_user_msgid( "SayText" );
  472.  
  473. if ( iPlayerId )
  474. {
  475. iPlayers[ 0 ] = iPlayerId;
  476. iPlrNum = 1;
  477. }
  478. else get_players( iPlayers, iPlrNum, "ch" );
  479.  
  480. for ( new i, iPId; i < iPlrNum; ++i )
  481. {
  482. iPId = iPlayers[ i ];
  483.  
  484. if ( !is_user_connected( iPId ) ) continue;
  485.  
  486. message_begin( MSG_ONE, iIdMsg, _, iPId );
  487. write_byte( iPId );
  488. write_string( sMsg );
  489. message_end( );
  490. }
  491. }
  492. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  493. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  494. */
  495.