HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* ==================================================== Forditotta: Smack ==================================================== */
  2.  
  3. #define USE_FAKEMETA // comment this if you are more willing to use Cstrike and Fun modules instead of FakeMeta
  4. //#define PROCESSOR_TYPE 0 // 1 = 32bit server; 0 = 64bit server; if commented - automatic bit detection
  5.  
  6. #define SAVE_LIMIT 1024 // limit of people to save (0 - dynamic [not recommended])
  7.  
  8. #define DATA_SAVE 1 // (1|2|4|8|16) // save data by:
  9. // 1 - steam id (automatically checks is steam ID valid)
  10. // 2 - ip
  11. // 4 - if first two numbers of ip and nick are the same
  12. // 8 - dynamic ip (first two numbers [123.456.*.*])
  13. // 16 - nick
  14. // NOTE: if save won't contain none of this numbers - next connected player will just have the longest time ago disconnected player data
  15.  
  16. /* ===================================================== CONFIG END ===================================================== */
  17.  
  18. #define PLUGIN_NAME "Reconnect Data Saver"
  19. #define PLUGIN_VERSION "1.7"
  20. #define PLUGIN_AUTHOR "Numb"
  21.  
  22. #include <amxmodx>
  23. #if defined USE_FAKEMETA
  24. #include <fakemeta>
  25. #else
  26. #include <cstrike>
  27. #include <fun>
  28. #endif
  29.  
  30. #if defined USE_FAKEMETA
  31. #if !defined PROCESSOR_TYPE
  32. #if cellbits == 32
  33. #define PD_CSDEATHS 493
  34. #define PD_CSMONEY 115
  35. #define PD_CSTEAM 114
  36. #define PD_CSINTERNALMODEL 126
  37. #else
  38. #define PD_CSDEATHS 444
  39. #define PD_CSMONEY 140
  40. #define PD_CSTEAM 139
  41. #define PD_CSINTERNALMODEL 152
  42. #endif
  43. #else
  44. #if PROCESSOR_TYPE == 1
  45. #define PD_CSDEATHS 493
  46. #define PD_CSMONEY 115
  47. #define PD_CSTEAM 114
  48. #define PD_CSINTERNALMODEL 126
  49. #else
  50. #define PD_CSDEATHS 444
  51. #define PD_CSMONEY 140
  52. #define PD_CSTEAM 139
  53. #define PD_CSINTERNALMODEL 152
  54. #endif
  55. #endif
  56.  
  57. set_user_frags(iPlrId, iFragsNum, bool:bSendToAllPlugins=true)
  58. {
  59. if( !native_check_plrid(iPlrId) ) // checking is player valid
  60. return 0;
  61.  
  62. static s_iMsg_ScoreInfo;
  63. if( !s_iMsg_ScoreInfo )
  64. s_iMsg_ScoreInfo = get_user_msgid("ScoreInfo");
  65.  
  66. if( bSendToAllPlugins ) // changing frags in scoreboard
  67. {
  68. emessage_begin(MSG_BROADCAST, s_iMsg_ScoreInfo);
  69. ewrite_byte(iPlrId);
  70. ewrite_short(iFragsNum);
  71. ewrite_short(get_pdata_int(iPlrId, PD_CSDEATHS));
  72. ewrite_short(0);
  73. ewrite_short(get_pdata_int(iPlrId, PD_CSTEAM));
  74. emessage_end();
  75. }
  76. else
  77. {
  78. message_begin(MSG_BROADCAST, s_iMsg_ScoreInfo);
  79. write_byte(iPlrId);
  80. write_short(iFragsNum);
  81. write_short(get_pdata_int(iPlrId, PD_CSDEATHS));
  82. write_short(0);
  83. write_short(get_pdata_int(iPlrId, PD_CSTEAM));
  84. message_end();
  85. }
  86.  
  87. new iMsgBlockType = get_msg_block(s_iMsg_ScoreInfo);
  88. set_msg_block(s_iMsg_ScoreInfo, BLOCK_SET);
  89. set_pev(iPlrId, pev_frags, float(iFragsNum)); // setting frags silently
  90. set_msg_block(s_iMsg_ScoreInfo, iMsgBlockType);
  91.  
  92. return 1;
  93. }
  94.  
  95. cs_get_user_deaths(iPlrId)
  96. {
  97. if( !native_check_plrid(iPlrId) ) // checking is player valid
  98. return 0;
  99.  
  100. return get_pdata_int(iPlrId, PD_CSDEATHS);
  101. }
  102.  
  103. cs_set_user_deaths(iPlrId, iDeathsNum, bool:bSendToAllPlugins=true)
  104. {
  105. if( !native_check_plrid(iPlrId) ) // checking is player valid
  106. return 0;
  107.  
  108. static s_iMsg_ScoreInfo;
  109. if( !s_iMsg_ScoreInfo )
  110. s_iMsg_ScoreInfo = get_user_msgid("ScoreInfo");
  111.  
  112. if( bSendToAllPlugins ) // changing deaths in scoreboard
  113. {
  114. emessage_begin(MSG_BROADCAST, s_iMsg_ScoreInfo);
  115. ewrite_byte(iPlrId);
  116. ewrite_short(pev(iPlrId, pev_frags));
  117. ewrite_short(iDeathsNum);
  118. ewrite_short(0);
  119. ewrite_short(get_pdata_int(iPlrId, PD_CSTEAM));
  120. emessage_end();
  121. }
  122. else
  123. {
  124. message_begin(MSG_BROADCAST, s_iMsg_ScoreInfo);
  125. write_byte(iPlrId);
  126. write_short(pev(iPlrId, pev_frags));
  127. write_short(iDeathsNum);
  128. write_short(0);
  129. write_short(get_pdata_int(iPlrId, PD_CSTEAM));
  130. message_end();
  131. }
  132.  
  133. new iMsgBlockType = get_msg_block(s_iMsg_ScoreInfo);
  134. set_msg_block(s_iMsg_ScoreInfo, BLOCK_SET);
  135. set_pdata_int(iPlrId, PD_CSDEATHS, iDeathsNum); // setting deaths silently
  136. set_msg_block(s_iMsg_ScoreInfo, iMsgBlockType);
  137.  
  138. return 1;
  139. }
  140.  
  141. cs_set_user_money(iPlrId, iNewMoney, iPlayAnimation=1, bool:bSendToAllPlugins=true)
  142. {
  143. if( !native_check_plrid(iPlrId) ) // checking is player valid
  144. return 0;
  145.  
  146. static s_iMsgId_Money;
  147. if( !s_iMsgId_Money )
  148. s_iMsgId_Money = get_user_msgid("Money");
  149.  
  150. if( bSendToAllPlugins ) // sending money changes to client
  151. {
  152. emessage_begin(MSG_ONE_UNRELIABLE, s_iMsgId_Money, _, iPlrId);
  153. ewrite_long(iNewMoney);
  154. ewrite_byte(iPlayAnimation);
  155. emessage_end();
  156. }
  157. else
  158. {
  159. message_begin(MSG_ONE_UNRELIABLE, s_iMsgId_Money, _, iPlrId);
  160. write_long(iNewMoney);
  161. write_byte(iPlayAnimation);
  162. message_end();
  163. }
  164.  
  165. new iMsgBlockType = get_msg_block(s_iMsgId_Money);
  166. set_msg_block(s_iMsgId_Money, BLOCK_SET);
  167. set_pdata_int(iPlrId, PD_CSMONEY, iNewMoney); // changing money silently
  168. set_msg_block(s_iMsgId_Money, iMsgBlockType);
  169.  
  170. return 1;
  171. }
  172.  
  173. enum CsTeams
  174. {
  175. CS_TEAM_UNASSIGNED = 0,
  176. CS_TEAM_T = 1,
  177. CS_TEAM_CT = 2,
  178. CS_TEAM_SPECTATOR = 3
  179. };
  180.  
  181. enum CsInternalModel {
  182. CS_DONTCHANGE = 0,
  183. CS_CT_URBAN = 1,
  184. CS_T_TERROR = 2,
  185. CS_T_LEET = 3,
  186. CS_T_ARCTIC = 4,
  187. CS_CT_GSG9 = 5,
  188. CS_CT_GIGN = 6,
  189. CS_CT_SAS = 7,
  190. CS_T_GUERILLA = 8,
  191. CS_CT_VIP = 9,
  192. CZ_T_MILITIA = 10,
  193. CZ_CT_SPETSNAZ = 11
  194. };
  195.  
  196. CsTeams:cs_get_user_team(iPlrId, &{CsInternalModel,_}:iModel=CS_DONTCHANGE)
  197. {
  198. if( !native_check_plrid(iPlrId) ) // checking is player valid
  199. return CsTeams:0;
  200.  
  201. iModel = CsInternalModel:get_pdata_int(iPlrId, PD_CSINTERNALMODEL);
  202.  
  203. return CsTeams:get_pdata_int(iPlrId, PD_CSTEAM);
  204. }
  205.  
  206. cs_set_user_team(iPlrId, {CsTeams,_}:iTeam, {CsInternalModel,_}:iModel=CS_DONTCHANGE, bool:bSendToAllPlugins=true)
  207. {
  208. if( !native_check_plrid(iPlrId) ) // checking is player valid
  209. return 0;
  210.  
  211. if( (_:iTeam)<0 || (_:iTeam)>3 )
  212. return 0;
  213.  
  214. static s_iMsg_TeamInfo;
  215. if( !s_iMsg_TeamInfo )
  216. s_iMsg_TeamInfo = get_user_msgid("TeamInfo");
  217.  
  218. if( bSendToAllPlugins ) // sending team changes in scoreboard
  219. {
  220. emessage_begin(MSG_BROADCAST, s_iMsg_TeamInfo);
  221. ewrite_byte(iPlrId);
  222. switch( iTeam )
  223. {
  224. case CS_TEAM_T: ewrite_string("TERRORIST");
  225. case CS_TEAM_CT: ewrite_string("CT");
  226. case CS_TEAM_SPECTATOR: ewrite_string("SPECTATOR");
  227. default: ewrite_string("UNASSIGNED");
  228. }
  229. emessage_end();
  230. }
  231. else
  232. {
  233. message_begin(MSG_BROADCAST, s_iMsg_TeamInfo);
  234. write_byte(iPlrId);
  235. switch( iTeam )
  236. {
  237. case CS_TEAM_T: write_string("TERRORIST");
  238. case CS_TEAM_CT: write_string("CT");
  239. case CS_TEAM_SPECTATOR: write_string("SPECTATOR");
  240. default: write_string("UNASSIGNED");
  241. }
  242. message_end();
  243. }
  244.  
  245. new iMsgBlockType = get_msg_block(s_iMsg_TeamInfo);
  246. set_msg_block(s_iMsg_TeamInfo, BLOCK_SET);
  247. set_pdata_int(iPlrId, PD_CSTEAM, (_:iTeam)); // changing team silently
  248. if( (_:iModel)>0 && (_:iModel)<=(native_check_is_cz()?11:9) )
  249. set_pdata_int(iPlrId, PD_CSINTERNALMODEL, (_:iModel)); // changing model silently
  250. dllfunc(DLLFunc_ClientUserInfoChanged, iPlrId, engfunc(EngFunc_GetInfoKeyBuffer, iPlrId));
  251. set_msg_block(s_iMsg_TeamInfo, iMsgBlockType);
  252.  
  253. return 1;
  254. }
  255.  
  256. native_check_plrid(iPlrId)
  257. {
  258. if( iPlrId<1 )
  259. {
  260. log_error(AMX_ERR_NATIVE, "Érvénytelen játékos ID: %i", iPlrId);
  261. return 0;
  262. }
  263.  
  264. static s_iMaxPlayers;
  265. if( !s_iMaxPlayers )
  266. s_iMaxPlayers = get_maxplayers();
  267.  
  268. if( iPlrId>s_iMaxPlayers )
  269. {
  270. log_error(AMX_ERR_NATIVE, "Érvénytelen játékos ID: %i", iPlrId);
  271. return 0;
  272. }
  273.  
  274. if( !pev_valid(iPlrId) )
  275. {
  276. log_error(AMX_ERR_NATIVE, "Érvénytelen játékos ID: %i", iPlrId);
  277. return 0;
  278. }
  279.  
  280. return 1;
  281. }
  282.  
  283. native_check_is_cz()
  284. {
  285. static s_iIsGameCz;
  286. if( !s_iIsGameCz )
  287. {
  288. static s_iModName[8];
  289. get_modname(s_iModName, 8);
  290. if( equal(s_iModName, "czero") )
  291. {
  292. s_iIsGameCz = 1;
  293. return 1;
  294. }
  295. else
  296. {
  297. s_iIsGameCz = -1;
  298. return 0;
  299. }
  300. }
  301.  
  302. if( s_iIsGameCz==1 )
  303. return 1;
  304.  
  305. return 0;
  306. }
  307. #endif
  308.  
  309. new bool:g_bBombPlanted;
  310. new Float:g_fBlockSpawnAt[33];
  311. new g_iUserTeamChanged[33];
  312. new g_iUserTeam[33];
  313. new g_iRoundCount;
  314.  
  315. new g_iUserMoney[33];
  316. new g_iUserFrags[33];
  317. new g_iUserDeaths[33];
  318. new bool:g_bIsUserConnected[33];
  319. new bool:g_bWasCheckPerformed[33];
  320.  
  321. #if (DATA_SAVE & 1)
  322. new Array:g_aUserSteam;
  323. #endif
  324.  
  325. #if (DATA_SAVE & 2)
  326. new Array:g_aUserIp;
  327. #endif
  328.  
  329. #if (DATA_SAVE & 4)
  330. #if !(DATA_SAVE & 2)
  331. new Array:g_aUserIp;
  332. #endif
  333. #if !(DATA_SAVE & 16)
  334. new Array:g_aUserName;
  335. #endif
  336. #endif
  337.  
  338. #if (DATA_SAVE & 8) && !(DATA_SAVE & 4) && !(DATA_SAVE & 2)
  339. new Array:g_aUserIp;
  340. #endif
  341.  
  342. #if (DATA_SAVE & 16)
  343. new Array:g_aUserName;
  344. #endif
  345.  
  346. new Array:g_aUserMoneyArray;
  347. new Array:g_aUserFragArray;
  348. new Array:g_aUserDeathArray;
  349. new Array:g_aUserTcArray;
  350. new Array:g_aUserTeamArray;
  351. new g_iDataSize;
  352.  
  353. public plugin_init()
  354. {
  355. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  356.  
  357. register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0");
  358. register_event("TextMsg", "Event_JoinGame_t", "a", "1=1", "2=#Game_join_terrorist");
  359. register_event("TextMsg", "Event_JoinGame_c", "a", "1=1", "2=#Game_join_ct");
  360. register_event("TextMsg", "Event_GameRestart", "a", "1=4", "2=#Game_will_restart_in");
  361. register_event("TextMsg", "Event_GameRestart", "a", "1=4", "2=#Game_Commencing");
  362. register_event("ScoreInfo", "Event_ScoreInfo", "a");
  363. register_event("Money", "Event_Money", "b");
  364. register_event("ResetHUD", "Event_ResetHUD", "be");
  365.  
  366. register_logevent("LogEvent_RoundEnd", 2, "0=World triggered", "1=Round_End");
  367. register_logevent("LogEvent_PlantedTheBomb", 3, "2=Planted_The_Bomb");
  368.  
  369. #if (DATA_SAVE & 1)
  370. g_aUserSteam = ArrayCreate(16);
  371. #endif
  372.  
  373. #if (DATA_SAVE & 2)
  374. g_aUserIp = ArrayCreate(15);
  375. #endif
  376.  
  377. #if (DATA_SAVE & 4)
  378. #if !(DATA_SAVE & 2)
  379. g_aUserIp = ArrayCreate(8);
  380. #endif
  381. #if !(DATA_SAVE & 16)
  382. g_aUserName = ArrayCreate(26);
  383. #endif
  384. #endif
  385.  
  386. #if (DATA_SAVE & 8) && !(DATA_SAVE & 4) && !(DATA_SAVE & 2)
  387. g_aUserIp = ArrayCreate(8);
  388. #endif
  389.  
  390. #if (DATA_SAVE & 16)
  391. g_aUserName = ArrayCreate(26);
  392. #endif
  393. g_aUserMoneyArray = ArrayCreate(1);
  394. g_aUserFragArray = ArrayCreate(1);
  395. g_aUserDeathArray = ArrayCreate(1);
  396. g_aUserTcArray = ArrayCreate(1);
  397. g_aUserTeamArray = ArrayCreate(1);
  398. }
  399.  
  400. public client_putinserver(iPlrId)
  401. {
  402. g_iUserTeamChanged[iPlrId] = 0;
  403. g_iUserTeam[iPlrId] = 0;
  404.  
  405. g_iUserFrags[iPlrId] = 0;
  406. g_iUserDeaths[iPlrId] = 0;
  407. g_iUserMoney[iPlrId] = 0;
  408.  
  409. g_bWasCheckPerformed[iPlrId] = false;
  410. g_bIsUserConnected[iPlrId] = true;
  411. }
  412.  
  413. public client_disconnect(iPlrId) // biztos... írhatod "why I'm not getting all data here - would be much more simple"... try it yourself and be amazed by the errorlog/crash it makes if requesting cs_ info in this event
  414. {
  415. if( g_bWasCheckPerformed[iPlrId] && g_iRoundCount>0 )
  416. {
  417.  
  418. if( SAVE_LIMIT>0 && SAVE_LIMIT==g_iDataSize ) // here we delete information about longest time ago disconnected player
  419. {
  420. #if (DATA_SAVE & 1)
  421. ArrayDeleteItem(g_aUserSteam, 0);
  422. #endif
  423.  
  424. #if (DATA_SAVE & 2)
  425. ArrayDeleteItem(g_aUserIp, 0);
  426. #endif
  427.  
  428. #if (DATA_SAVE & 4)
  429. #if !(DATA_SAVE & 2)
  430. ArrayDeleteItem(g_aUserIp, 0);
  431. #endif
  432. #if !(DATA_SAVE & 16)
  433. ArrayDeleteItem(g_aUserName, 0);
  434. #endif
  435. #endif
  436.  
  437. #if (DATA_SAVE & 8) && !(DATA_SAVE & 4) && !(DATA_SAVE & 2)
  438. ArrayDeleteItem(g_aUserIp, 0);
  439. #endif
  440.  
  441. #if (DATA_SAVE & 16)
  442. ArrayDeleteItem(g_aUserName, 0);
  443. #endif
  444.  
  445. ArrayDeleteItem(g_aUserFragArray, 0);
  446. ArrayDeleteItem(g_aUserDeathArray, 0);
  447. ArrayDeleteItem(g_aUserMoneyArray, 0);
  448. ArrayDeleteItem(g_aUserTcArray, 0);
  449. ArrayDeleteItem(g_aUserTeamArray, 0);
  450. }
  451. else
  452. g_iDataSize++;
  453.  
  454. new iClientData[26];
  455. #if DATA_SAVE & 1
  456. get_user_authid(iPlrId, iClientData, 26);
  457.  
  458. if( contain(iClientData, ":")!=7 )
  459. copy(iClientData, 26, "");
  460. else
  461. {
  462. replace(iClientData, 26, "STEAM_", "");
  463. replace(iClientData, 26, "VALVE_", "");
  464. }
  465.  
  466. ArrayPushString(g_aUserSteam, iClientData);
  467. #endif
  468.  
  469. #if DATA_SAVE & 2
  470. get_user_ip(iPlrId, iClientData, 26, 1);
  471.  
  472. ArrayPushString(g_aUserIp, iClientData);
  473. #endif
  474.  
  475. #if DATA_SAVE & 4
  476. #if !(DATA_SAVE & 2)
  477. if( get_user_ip(iPlrId, iClientData[1], 25, 1)>15 )
  478. copy(iClientData, 26, "");
  479.  
  480. new iClientData[0] = contain(iClientData[1], ".");
  481. if( iClientData[0]<1 )
  482. copy(iClientData, 26, "");
  483. else
  484. {
  485. iClientData[0] += contain(iClientData[iClientData[0]+2], ".")+2;
  486.  
  487. if( iClientData[0]>=4 && iClientData[0]<=8 && contain(iClientData[iClientData[0]+1], ".")>0 )
  488. copy(iClientData[iClientData[0]], (26-iClientData[0]), "");
  489. else
  490. copy(iClientData, 26, "");
  491. }
  492.  
  493. ArrayPushString(g_aUserIp, iClientData);
  494. #endif
  495.  
  496. #if !(DATA_SAVE & 16)
  497. get_user_name(iPlrId, iClientData, 26);
  498.  
  499. ArrayPushString(g_aUserName, iClientData);
  500. #endif
  501. #endif
  502.  
  503. #if DATA_SAVE & 8 && !(DATA_SAVE & 4) && !(DATA_SAVE & 2)
  504. if( get_user_ip(iPlrId, iClientData[1], 25, 1)>15 )
  505. copy(iClientData, 26, "");
  506.  
  507. new iClientData[0] = contain(iClientData[1], ".");
  508. if( iClientData[0]<1 )
  509. copy(iClientData, 26, "");
  510. else
  511. {
  512. iClientData[0] += contain(iClientData[iClientData[0]+2], ".")+2;
  513.  
  514. if( iClientData[0]>=4 && iClientData[0]<=8 && contain(iClientData[iClientData[0]+1], ".")>0 )
  515. copy(iClientData[iClientData[0]], (26-iClientData[0]), "");
  516. else
  517. copy(iClientData, 26, "");
  518. }
  519.  
  520. ArrayPushString(g_aUserIp, iClientData);
  521. #endif
  522.  
  523. #if DATA_SAVE & 16 && !(DATA_SAVE & 4)
  524. get_user_name(iPlrId, iClientData, 26);
  525.  
  526. ArrayPushString(g_aUserName, iClientData);
  527. #endif
  528. ArrayPushCell(g_aUserFragArray, g_iUserFrags[iPlrId]);
  529. ArrayPushCell(g_aUserDeathArray, g_iUserDeaths[iPlrId]);
  530. ArrayPushCell(g_aUserMoneyArray, g_iUserMoney[iPlrId]);
  531. ArrayPushCell(g_aUserTcArray, g_iUserTeamChanged[iPlrId]);
  532. ArrayPushCell(g_aUserTeamArray, g_iUserTeam[iPlrId]);
  533. }
  534.  
  535. g_iUserFrags[iPlrId] = 0;
  536. g_iUserDeaths[iPlrId] = 0;
  537. g_iUserMoney[iPlrId] = 0;
  538.  
  539. g_bIsUserConnected[iPlrId] = false;
  540. g_bWasCheckPerformed[iPlrId] = false;
  541. }
  542.  
  543. public Event_NewRound()
  544. {
  545. for( new iPlrId=1; iPlrId<=32; iPlrId++ )
  546. g_fBlockSpawnAt[iPlrId] = 0.0;
  547.  
  548. g_bBombPlanted = false;
  549. g_iRoundCount++;
  550. }
  551.  
  552. public Event_GameRestart() // new round start after sv_restart 1 or some other event what reseted score
  553. {
  554. g_iRoundCount = 0;
  555.  
  556. if( g_iDataSize )
  557. {
  558. #if (DATA_SAVE & 1)
  559. ArrayClear(g_aUserSteam);
  560. #endif
  561.  
  562. #if (DATA_SAVE & 2)
  563. ArrayClear(g_aUserIp);
  564. #endif
  565.  
  566. #if (DATA_SAVE & 4)
  567. #if !(DATA_SAVE & 2)
  568. ArrayClear(g_aUserIp);
  569. #endif
  570. #if !(DATA_SAVE & 16)
  571. ArrayClear(g_aUserName);
  572. #endif
  573. #endif
  574.  
  575. #if (DATA_SAVE & 8) && !(DATA_SAVE & 4) && !(DATA_SAVE & 2)
  576. ArrayClear(g_aUserIp);
  577. #endif
  578.  
  579. #if (DATA_SAVE & 16)
  580. ArrayClear(g_aUserName);
  581. #endif
  582.  
  583. ArrayClear(g_aUserFragArray);
  584. ArrayClear(g_aUserDeathArray);
  585. ArrayClear(g_aUserMoneyArray);
  586. ArrayClear(g_aUserTcArray);
  587. ArrayClear(g_aUserTeamArray);
  588.  
  589. g_iDataSize = 0;
  590. }
  591. }
  592.  
  593. public Event_JoinGame_t()
  594. CL_ManualTeamChange(0);
  595.  
  596. public Event_JoinGame_c()
  597. CL_ManualTeamChange(1);
  598.  
  599. CL_ManualTeamChange(iJoinedCt=0)
  600. {
  601. new iName[26];
  602. if( read_data(3, iName, 26) )
  603. {
  604. new iPlrId = find_player("a", iName);
  605.  
  606. if( iPlrId<33 && g_bIsUserConnected[clamp(iPlrId, 0, 32)] )
  607. {
  608. new bool:bTeamSwitch;
  609.  
  610. if( !g_bWasCheckPerformed[iPlrId] ) // just joined some team so lets check was he connected before.
  611. {
  612. if( g_iDataSize )
  613. {
  614. #if !(DATA_SAVE & 1) && !(DATA_SAVE & 2) && !(DATA_SAVE & 4) && !(DATA_SAVE & 8) && !(DATA_SAVE & 16)
  615. set_user_data_back(iPlrId, bTeamSwitch, iJoinedCt, iName, 0);
  616. return;
  617. #else
  618. new iArrayItem, iClientData[26], iSavedData[26];
  619. #if (DATA_SAVE & 1)
  620. get_user_authid(iPlrId, iClientData, 26);
  621.  
  622. if( contain(iClientData, ":")==7 )
  623. {
  624. replace(iClientData, 26, "STEAM_", "");
  625. replace(iClientData, 26, "VALVE_", "");
  626.  
  627. for( iArrayItem=0; iArrayItem<g_iDataSize; iArrayItem++ )
  628. {
  629. ArrayGetString(g_aUserSteam, iArrayItem, iSavedData, 16);
  630.  
  631. if( equali(iClientData, iSavedData) )
  632. {
  633. set_user_data_back(iPlrId, bTeamSwitch, iJoinedCt, iName, iArrayItem);
  634.  
  635. return;
  636. }
  637. }
  638. }
  639. #endif
  640.  
  641. #if (DATA_SAVE & 2)
  642. if( get_user_ip(iPlrId, iClientData[1], 26, 1)>15 )
  643. copy(iClientData, 26, "");
  644. else
  645. {
  646. for( iArrayItem=0; iArrayItem<g_iDataSize; iArrayItem++ )
  647. {
  648. ArrayGetString(g_aUserIp, iArrayItem, iSavedData, 16);
  649.  
  650. if( equali(iClientData[1], iSavedData) )
  651. {
  652. set_user_data_back(iPlrId, bTeamSwitch, iJoinedCt, iName, iArrayItem);
  653.  
  654. return;
  655. }
  656. }
  657. }
  658. #endif
  659.  
  660. #if (DATA_SAVE & 4)
  661. new iSavedName[26];
  662. #if !(DATA_SAVE & 2)
  663. if( get_user_ip(iPlrId, iClientData[1], 26, 1)>15 )
  664. copy(iClientData, 26, "");
  665. #else
  666. iClientData[0] = contain(iClientData[1], ".");
  667. if( iClientData[0]<1 )
  668. copy(iClientData, 26, "");
  669. else
  670. {
  671. iClientData[0] += contain(iClientData[iClientData[0]+2], ".")+2;
  672.  
  673. if( iClientData[0]>=4 && iClientData[0]<=8 && contain(iClientData[iClientData[0]+1], ".")>0 )
  674. copy(iClientData[iClientData[0]], (26-iClientData[0]), "");
  675. else
  676. copy(iClientData, 26, "");
  677. }
  678. #endif
  679. if( iClientData[0] )
  680. {
  681. for( iArrayItem=0; iArrayItem<g_iDataSize; iArrayItem++ )
  682. {
  683. ArrayGetString(g_aUserName, iArrayItem, iSavedName, 26);
  684. #if (DATA_SAVE & 2)
  685. ArrayGetString(g_aUserIp, iArrayItem, iSavedData, 16);
  686. if( equali(iSavedData, iClientData[1], iClientData[0]) && equali(iName, iSavedName) )
  687. {
  688. #else
  689. ArrayGetString(g_aUserIp, iArrayItem, iSavedData, 8);
  690. if( equali(iClientData, iSavedData[1], iSavedData[0]) && equali(iName, iSavedName) )
  691. {
  692. #endif
  693. set_user_data_back(iPlrId, bTeamSwitch, iJoinedCt, iName, iArrayItem);
  694.  
  695. return;
  696. }
  697. }
  698. }
  699. #endif
  700.  
  701. #if (DATA_SAVE & 8)
  702. #if !(DATA_SAVE & 4)
  703. #if !(DATA_SAVE & 2)
  704. if( get_user_ip(iPlrId, iClientData[1], 26, 1)>15 )
  705. copy(iClientData, 26, "");
  706. #endif
  707. new iClientData[0] = contain(iClientData[1], ".");
  708. if( iClientData[0]<1 )
  709. copy(iClientData, 26, "");
  710. else
  711. {
  712. iClientData[0] += contain(iClientData[iClientData[0]+2], ".")+2;
  713.  
  714. if( iClientData[0]>=4 && iClientData[0]<=8 && contain(iClientData[iClientData[0]+1], ".")>0 )
  715. copy(iClientData[iClientData[0]], (26-iClientData[0]), "");
  716. else
  717. copy(iClientData, 26, "");
  718. }
  719. #endif
  720. if( iClientData[0] )
  721. {
  722. for( iArrayItem=0; iArrayItem<g_iDataSize; iArrayItem++ )
  723. {
  724. #if (DATA_SAVE & 2)
  725. ArrayGetString(g_aUserIp, iArrayItem, iSavedData, 16);
  726. if( equali(iSavedData, iClientData[1], iClientData[0]) )
  727. {
  728. #else
  729. ArrayGetString(g_aUserIp, iArrayItem, iSavedData, 8);
  730. if( equali(iClientData, iSavedData[1], iSavedData[0]) )
  731. {
  732. #endif
  733. set_user_data_back(iPlrId, bTeamSwitch, iJoinedCt, iName, iArrayItem);
  734.  
  735. return;
  736. }
  737. }
  738. }
  739. #endif
  740.  
  741. #if (DATA_SAVE & 16)
  742. for( iArrayItem=0; iArrayItem<g_iDataSize; iArrayItem++ )
  743. {
  744. ArrayGetString(g_aUserName, iArrayItem, iSavedData, 16);
  745.  
  746. if( equali(iName, iSavedData) )
  747. {
  748. set_user_data_back(iPlrId, bTeamSwitch, iJoinedCt, iName, iArrayItem);
  749.  
  750. return;
  751. }
  752. }
  753. #endif
  754. #endif
  755. }
  756.  
  757. g_bWasCheckPerformed[iPlrId] = true;
  758. }
  759.  
  760. g_iUserTeamChanged[iPlrId] = g_iRoundCount;
  761. g_iUserTeam[iPlrId] = (bTeamSwitch?(iJoinedCt?0:1):iJoinedCt);
  762. }
  763. }
  764. }
  765.  
  766. set_user_data_back(iPlrId, bool:bTeamSwitch, iJoinedCt, iName[], iArrayItem=0)
  767. {
  768. #if (DATA_SAVE & 1)
  769. ArrayDeleteItem(g_aUserSteam, iArrayItem);
  770. #endif
  771.  
  772. #if (DATA_SAVE & 2)
  773. ArrayDeleteItem(g_aUserIp, iArrayItem);
  774. #endif
  775.  
  776. #if (DATA_SAVE & 4)
  777. #if !(DATA_SAVE & 2)
  778. ArrayDeleteItem(g_aUserIp, iArrayItem);
  779. #endif
  780. #if !(DATA_SAVE & 16)
  781. ArrayDeleteItem(g_aUserName, iArrayItem);
  782. #endif
  783. #endif
  784.  
  785. #if (DATA_SAVE & 8) && !(DATA_SAVE & 4) && !(DATA_SAVE & 2)
  786. ArrayDeleteItem(g_aUserIp, iArrayItem);
  787. #endif
  788.  
  789. #if (DATA_SAVE & 16)
  790. ArrayDeleteItem(g_aUserName, iArrayItem);
  791. #endif
  792. g_iUserFrags[iPlrId] = ArrayGetCell(g_aUserFragArray, iArrayItem);
  793. g_iUserDeaths[iPlrId] = ArrayGetCell(g_aUserDeathArray, iArrayItem);
  794. g_iUserMoney[iPlrId] = ArrayGetCell(g_aUserMoneyArray, iArrayItem);
  795.  
  796. ArrayDeleteItem(g_aUserFragArray, iArrayItem);
  797. ArrayDeleteItem(g_aUserDeathArray, iArrayItem);
  798. ArrayDeleteItem(g_aUserMoneyArray, iArrayItem);
  799.  
  800. set_user_frags(iPlrId, g_iUserFrags[iPlrId]);
  801. cs_set_user_deaths(iPlrId, g_iUserDeaths[iPlrId]);
  802. cs_set_user_money(iPlrId, g_iUserMoney[iPlrId], 0);
  803.  
  804. if( ArrayGetCell(g_aUserTcArray, iArrayItem)==g_iRoundCount && g_iRoundCount>0 )
  805. {
  806. g_fBlockSpawnAt[iPlrId] = (get_gametime()+0.25);
  807. engclient_cmd(iPlrId, "menuselect", "5"); // speed up model select to block respawn
  808.  
  809. if( ArrayGetCell(g_aUserTeamArray, iArrayItem)!=iJoinedCt )
  810. {
  811. bTeamSwitch = true;
  812.  
  813. if( iJoinedCt )
  814. {
  815. switch( random_num(1, 4) )
  816. {
  817. case 1: cs_set_user_team(iPlrId, CS_TEAM_T, CS_T_TERROR);
  818. case 2: cs_set_user_team(iPlrId, CS_TEAM_T, CS_T_LEET);
  819. case 3: cs_set_user_team(iPlrId, CS_TEAM_T, CS_T_ARCTIC);
  820. default: cs_set_user_team(iPlrId, CS_TEAM_T, CS_T_GUERILLA);
  821. }
  822. }
  823. else
  824. {
  825. switch( random_num(1, 4) )
  826. {
  827. case 1: cs_set_user_team(iPlrId, CS_TEAM_CT, CS_CT_URBAN);
  828. case 2: cs_set_user_team(iPlrId, CS_TEAM_CT, CS_CT_GSG9);
  829. case 3: cs_set_user_team(iPlrId, CS_TEAM_CT, CS_CT_SAS);
  830. default: cs_set_user_team(iPlrId, CS_TEAM_CT, CS_CT_GIGN);
  831. }
  832. }
  833.  
  834. static s_iMsgId_TextMsg;
  835. if( !s_iMsgId_TextMsg )
  836. s_iMsgId_TextMsg = get_user_msgid("TextMsg");
  837.  
  838. message_begin(MSG_ONE_UNRELIABLE, s_iMsgId_TextMsg, _, iPlrId);
  839. write_byte(print_notify);
  840. write_string((iJoinedCt?"#Game_join_terrorist_auto":"#Game_join_ct_auto"));
  841. write_string(iName);
  842. message_end();
  843.  
  844. message_begin(MSG_ONE_UNRELIABLE, s_iMsgId_TextMsg, _, iPlrId);
  845. write_byte(print_center);
  846. write_string("#Only_1_Team_Change");
  847. message_end();
  848. }
  849. }
  850. ArrayDeleteItem(g_aUserTcArray, 0);
  851. ArrayDeleteItem(g_aUserTeamArray, 0);
  852.  
  853. client_print(iPlrId, print_chat, "*A pénzed, fegyvereid, és pontjaid visszakerültek!"); // Please don't change it to your language... If you really care - create your own ML (it sux for people from other countries...)
  854.  
  855. g_iDataSize--;
  856.  
  857. g_bWasCheckPerformed[iPlrId] = true;
  858.  
  859. g_iUserTeamChanged[iPlrId] = g_iRoundCount;
  860. g_iUserTeam[iPlrId] = (bTeamSwitch?(iJoinedCt?0:1):iJoinedCt);
  861.  
  862. return 1;
  863. }
  864.  
  865. public Event_ScoreInfo()
  866. {
  867. new iPlrId = read_data(1);
  868. g_iUserFrags[iPlrId] = read_data(2);
  869. g_iUserDeaths[iPlrId] = read_data(3);
  870. }
  871.  
  872. public Event_Money(iPlrId)
  873. g_iUserMoney[iPlrId] = read_data(1);
  874.  
  875. public Event_ResetHUD(iPlrId)
  876. {
  877. if( g_bWasCheckPerformed[iPlrId] && g_fBlockSpawnAt[iPlrId]>=get_gametime() )
  878. {
  879. g_fBlockSpawnAt[iPlrId] = 0.0;
  880.  
  881. if( is_user_alive(iPlrId) )
  882. {
  883. new iPlayers[32], iPlayerNum;
  884.  
  885. switch( cs_get_user_team(iPlrId) )
  886. {
  887. case CS_TEAM_T: get_players(iPlayers, iPlayerNum, "a", "CT");
  888. case CS_TEAM_CT:
  889. {
  890. get_players(iPlayers, iPlayerNum, "a", "TERRORIST");
  891.  
  892. if( !iPlayerNum )
  893. iPlayerNum = (g_bBombPlanted?1:0);
  894. }
  895. default:
  896. {
  897. get_players(iPlayers, iPlayerNum, "a");
  898.  
  899. if( !iPlayerNum )
  900. iPlayerNum = (g_bBombPlanted?1:0);
  901. }
  902. }
  903.  
  904. if( iPlayerNum )
  905. {
  906. set_user_frags(iPlrId, (g_iUserFrags[iPlrId]=(get_user_frags(iPlrId)+1)));
  907. cs_set_user_deaths(iPlrId, (g_iUserDeaths[iPlrId]=(cs_get_user_deaths(iPlrId)-1)));
  908.  
  909. static s_iMsgId_DeathMsg;
  910. if( !s_iMsgId_DeathMsg )
  911. s_iMsgId_DeathMsg = get_user_msgid("DeathMsg");
  912. new iMsgBlockType = get_msg_block(s_iMsgId_DeathMsg);
  913. set_msg_block(s_iMsgId_DeathMsg, BLOCK_ONCE);
  914. user_kill(iPlrId);
  915. set_msg_block(s_iMsgId_DeathMsg, iMsgBlockType);
  916. }
  917. }
  918. }
  919. }
  920.  
  921. public LogEvent_PlantedTheBomb()
  922. g_bBombPlanted = true;
  923.  
  924. public LogEvent_RoundEnd()
  925. g_bBombPlanted = false;
  926.