HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <cstrike>
  4. #include <colors>
  5.  
  6. #define PLUGIN_VERSION "1.5fix"
  7. #pragma newdecls required
  8.  
  9. Handle hPluginEnable;
  10. Handle hPublic;
  11. Handle hSaveScores;
  12. Handle hResetCost;
  13. bool CSGO;
  14.  
  15. ArrayList playersList;
  16. ArrayList scores;
  17.  
  18. public Plugin myinfo =
  19. {
  20. name = "[CSS/CS:GO] AbNeR ResetScore",
  21. author = "AbNeR_CSS",
  22. description = "Statisztikád nullázásához írd be hogy !resetscore",
  23. version = PLUGIN_VERSION,
  24. url = "www.tecnohardclan.com"
  25. };
  26.  
  27. public void OnPluginStart()
  28. {
  29. HookEvent("player_disconnect", PlayerDisconnect);
  30.  
  31. char theFolder[40];
  32. GetGameFolderName(theFolder, sizeof(theFolder));
  33. CSGO = StrEqual(theFolder, "csgo");
  34.  
  35. RegConsoleCmd("resetscore", CommandResetScore);
  36. RegConsoleCmd("rs", CommandResetScore);
  37.  
  38. RegAdminCmd("sm_resetplayer", CommandResetPlayer, ADMFLAG_SLAY);
  39. RegAdminCmd("sm_reset", CommandResetPlayer, ADMFLAG_SLAY);
  40. RegAdminCmd("sm_setstars", CommandSetStars, ADMFLAG_SLAY);
  41.  
  42. LoadTranslations("common.phrases");
  43. LoadTranslations("abner_resetscore.phrases");
  44.  
  45. ServerCommand("mp_backup_round_file \"\"");
  46. ServerCommand("mp_backup_round_file_last \"\"");
  47. ServerCommand("mp_backup_round_file_pattern \"\"");
  48. ServerCommand("mp_backup_round_auto 0");
  49.  
  50. if(CSGO)
  51. {
  52. RegAdminCmd("sm_setassists", CommandSetAssists, ADMFLAG_SLAY);
  53. RegAdminCmd("sm_setpoints", CommandSetPoints, ADMFLAG_SLAY);
  54. RegAdminCmd("sm_setscore", CommandSetScoreCSGO, ADMFLAG_SLAY);
  55. }
  56. else
  57. {
  58. RegAdminCmd("sm_setscore", CommandSetScore, ADMFLAG_SLAY);
  59. }
  60.  
  61. AutoExecConfig();
  62. CreateConVar("abner_resetscore_version", PLUGIN_VERSION, "Resetscore Version", FCVAR_NOTIFY|FCVAR_REPLICATED);
  63. hPluginEnable = CreateConVar("sm_resetscore", "1", "Enable/Disable the Plugin.");
  64. hPublic = CreateConVar("sm_resetscore_public", "1", "Enable or disable the messages when player reset score.");
  65. hSaveScores = CreateConVar("sm_resetscore_savescores", "1", "Save scores when players retry.");
  66. hResetCost = CreateConVar("sm_resetscore_cost", "0", "Money cost to reset score.");
  67.  
  68. playersList = new ArrayList(64);
  69. scores = new ArrayList(4);
  70.  
  71. for(int i = 0;i < GetMaxClients();i++)
  72. {
  73. if(!IsValidClient(i))
  74. continue;
  75. OnClientPutInServer(i);
  76. }
  77. }
  78.  
  79.  
  80. public void OnMapStart()
  81. {
  82. playersList = new ArrayList(64);
  83. scores = new ArrayList(4);
  84. ServerCommand("mp_backup_round_file \"\"");
  85. ServerCommand("mp_backup_round_file_last \"\"");
  86. ServerCommand("mp_backup_round_file_pattern \"\"");
  87. ServerCommand("mp_backup_round_auto 0");
  88. }
  89.  
  90. public void OnClientPutInServer(int client)
  91. {
  92. if(GetConVarInt(hSaveScores) != 1 || IsFakeClient(client))
  93. return;
  94.  
  95. char steamId[64];
  96. GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));
  97. int infoArray[5];
  98. int index = playersList.FindString(steamId);
  99. if(index != -1)
  100. {
  101. CreateTimer(2.0, MSG, client);
  102. scores.GetArray(index, infoArray, sizeof(infoArray));
  103. SetEntProp(client, Prop_Data, "m_iFrags", infoArray[0]);
  104. SetEntProp(client, Prop_Data, "m_iDeaths", infoArray[1]);
  105. CS_SetMVPCount(client, infoArray[2]);
  106. if(CSGO)
  107. {
  108. CS_SetClientContributionScore(client, infoArray[3]);
  109. CS_SetClientAssists(client, infoArray[4]);
  110. }
  111. }
  112. else
  113. {
  114. playersList.PushString(steamId);
  115. scores.PushArray(infoArray);
  116. }
  117. }
  118.  
  119. public Action MSG(Handle timer, any client)
  120. {
  121. if(IsValidClient(client))
  122. CPrintToChat(client, "{green}[AbNeR ResetScore] \x01%t", "Statisztikád nullázva");
  123. }
  124. public void PlayerDisconnect(Handle event,const char[] name,bool dontBroadcast)
  125. {
  126. int client = GetClientOfUserId(GetEventInt(event, "userid"));
  127. if(!IsValidClient(client))
  128. return;
  129. if(GetConVarInt(hSaveScores) != 1 || IsFakeClient(client))
  130. return;
  131.  
  132. char steamId[64];
  133. GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));
  134. int infoArray[5];
  135. int index = playersList.FindString(steamId);
  136. if(index != -1)
  137. {
  138. infoArray[0] = GetClientFrags(client);
  139. infoArray[1] = GetClientDeaths(client);
  140. infoArray[2] = CS_GetMVPCount(client);
  141. if(CSGO)
  142. {
  143. infoArray[3] = CS_GetClientContributionScore(client);
  144. infoArray[4] = CS_GetClientAssists(client);
  145. }
  146. scores.SetArray(index, infoArray);
  147. }
  148. }
  149.  
  150. public Action CommandResetScore(int client, int args)
  151. {
  152. if(GetConVarInt(hPluginEnable) == 0)
  153. {
  154. CPrintToChat(client, "{green}[AbNeR ResetScore] \x01%t", "Plugin kikapcsolva");
  155. return Plugin_Continue;
  156. }
  157.  
  158. if(GetClientDeaths(client) == 0 && GetClientFrags(client) == 0 && CS_GetMVPCount(client) == 0)
  159. {
  160. if(!CSGO || CS_GetClientAssists(client) == 0)
  161. {
  162. CPrintToChat(client, "{green}[AbNeR ResetScore] \x01%t", "pontszám 0");
  163. return Plugin_Continue;
  164. }
  165. }
  166.  
  167. int cost = GetConVarInt(hResetCost);
  168. int money = GetEntProp(client, Prop_Send, "m_iAccount");
  169. if(cost > 0 && money < cost)
  170. {
  171. CPrintToChat(client, "{green}[AbNeR ResetScore] \x01%t", "Nincs pénzed a statisztikai nullázáshoz", cost);
  172. return Plugin_Continue;
  173. }
  174.  
  175. ResetPlayer(client);
  176. SetEntProp(client, Prop_Send, "m_iAccount", money-cost);
  177.  
  178. char name[MAX_NAME_LENGTH];
  179. GetClientName(client, name, sizeof(name));
  180. if(GetConVarInt(hPublic) == 1)
  181. {
  182. if(GetClientTeam(client) == 2)
  183. {
  184. CPrintToChatAll("{green}[AbNeR ResetScore] \x01%t", "Játékos statisztikája nullázva", name);
  185. }
  186. else if(GetClientTeam(client) == 3)
  187. {
  188. CPrintToChatAll("{green}[AbNeR ResetScore] \x01%t", "Játékos statisztikája kiegyenlítve", name);
  189. }
  190. else
  191. {
  192. CPrintToChatAll("{green}[AbNeR ResetScore] \x01%t", "Játékos statisztikája 3:3", name);
  193. }
  194. }
  195. else
  196. {
  197. CPrintToChat(client, "{green}[AbNeR ResetScore] \x01%t", "Sikeresen lenullázva");
  198. }
  199. return Plugin_Continue;
  200. }
  201.  
  202. void ResetPlayer(int client)
  203. {
  204. if(IsValidClient(client))
  205. {
  206. SetEntProp(client, Prop_Data, "m_iFrags", 0);
  207. SetEntProp(client, Prop_Data, "m_iDeaths", 0);
  208. CS_SetMVPCount(client, 0);
  209. if(CSGO)
  210. {
  211. CS_SetClientAssists(client, 0);
  212. CS_SetClientContributionScore(client, 0);
  213. }
  214. }
  215. }
  216.  
  217. public Action CommandResetPlayer(int client, int args)
  218. {
  219. char arg1[32];
  220. GetCmdArg(1, arg1, sizeof(arg1));
  221.  
  222. if (args != 1)
  223. {
  224. ReplyToCommand(client, "\x01[AbNeR ResetScore] sm_resetplayer <name or #userid>");
  225. return Plugin_Continue;
  226. }
  227.  
  228. char target_name[MAX_TARGET_LENGTH];
  229. char nameadm[MAX_NAME_LENGTH];
  230. GetClientName(client, nameadm, sizeof(nameadm));
  231. int target_list[MAXPLAYERS], target_count; bool tn_is_ml;
  232.  
  233. if ((target_count = ProcessTargetString(
  234. arg1,
  235. client,
  236. target_list,
  237. MAXPLAYERS,
  238. COMMAND_TARGET_NONE,
  239. target_name,
  240. sizeof(target_name),
  241. tn_is_ml)) <= 0)
  242. {
  243. ReplyToTargetError(client, target_count);
  244. return Plugin_Continue;
  245. }
  246.  
  247. for (int i = 0; i < target_count; i++)
  248. {
  249. ResetPlayer(target_list[i]);
  250. }
  251. ShowActivity2(client, "[AbNeR ResetScore] ", "%t", "Statisztikai pontszám", target_name);
  252. return Plugin_Continue;
  253. }
  254.  
  255. public Action CommandSetScore(int client, int args)
  256. {
  257. char arg1[32], arg2[20], arg3[20],arg4[20];
  258. GetCmdArg(1, arg1, sizeof(arg1));
  259. GetCmdArg(2, arg2, sizeof(arg2));
  260. GetCmdArg(3, arg3, sizeof(arg3));
  261. GetCmdArg(4, arg4, sizeof(arg4));
  262. int kills = StringToInt(arg2);
  263. int deaths = StringToInt(arg3);
  264. int stars = StringToInt(arg4);
  265.  
  266. if (args != 4)
  267. {
  268. ReplyToCommand(client, "\x01[AbNeR ResetScore] sm_setscore <name or #userid> <Kills> <Deaths><Stars>");
  269. return Plugin_Continue;
  270. }
  271.  
  272. char target_name[MAX_TARGET_LENGTH];
  273. char nameadm[MAX_NAME_LENGTH];
  274. GetClientName(client, nameadm, sizeof(nameadm));
  275. int target_list[MAXPLAYERS], target_count; bool tn_is_ml;
  276.  
  277. if ((target_count = ProcessTargetString(
  278. arg1,
  279. client,
  280. target_list,
  281. MAXPLAYERS,
  282. COMMAND_TARGET_NONE,
  283. target_name,
  284. sizeof(target_name),
  285. tn_is_ml)) <= 0)
  286. {
  287. ReplyToTargetError(client, target_count);
  288. return Plugin_Continue;
  289. }
  290.  
  291. for (int i = 0; i < target_count; i++)
  292. {
  293. SetEntProp(target_list[i], Prop_Data, "m_iFrags", kills);
  294. SetEntProp(target_list[i], Prop_Data, "m_iDeaths", deaths);
  295. CS_SetMVPCount(target_list[i], stars);
  296. }
  297.  
  298. ShowActivity2(client, "[AbNeR ResetScore] ", "%t", "Set Score", target_name);
  299. return Plugin_Continue;
  300. }
  301.  
  302. public Action CommandSetScoreCSGO(int client, int args)
  303. {
  304. if (args != 6)
  305. {
  306. ReplyToCommand(client, "\x01[AbNeR ResetScore] sm_setscore <name or #userid> <Kills> <Deaths><Assists><Stars><Points>");
  307. return Plugin_Continue;
  308. }
  309.  
  310. char arg1[32], arg2[20], arg3[20], arg4[20], arg5[20], arg6[20];
  311. GetCmdArg(1, arg1, sizeof(arg1));
  312. GetCmdArg(2, arg2, sizeof(arg2));
  313. GetCmdArg(3, arg3, sizeof(arg3));
  314. GetCmdArg(4, arg4, sizeof(arg4));
  315. GetCmdArg(5, arg5, sizeof(arg5));
  316. GetCmdArg(6, arg6, sizeof(arg6));
  317. int kills = StringToInt(arg2);
  318. int deaths = StringToInt(arg3);
  319. int assists = StringToInt(arg4);
  320. int stars = StringToInt(arg5);
  321. int points = StringToInt(arg6);
  322.  
  323. char target_name[MAX_TARGET_LENGTH];
  324. char nameadm[MAX_NAME_LENGTH];
  325. GetClientName(client, nameadm, sizeof(nameadm));
  326. int target_list[MAXPLAYERS], target_count; bool tn_is_ml;
  327.  
  328. if ((target_count = ProcessTargetString(
  329. arg1,
  330. client,
  331. target_list,
  332. MAXPLAYERS,
  333. COMMAND_TARGET_NONE,
  334. target_name,
  335. sizeof(target_name),
  336. tn_is_ml)) <= 0)
  337. {
  338. ReplyToTargetError(client, target_count);
  339. return Plugin_Continue;
  340. }
  341.  
  342. for (int i = 0; i < target_count; i++)
  343. {
  344. SetEntProp(target_list[i], Prop_Data, "m_iFrags", kills);
  345. SetEntProp(target_list[i], Prop_Data, "m_iDeaths", deaths);
  346. CS_SetClientAssists(target_list[i], assists);
  347. CS_SetMVPCount(target_list[i], stars);
  348. CS_SetClientContributionScore(target_list[i], points);
  349. }
  350.  
  351. ShowActivity2(client, "[AbNeR ResetScore] ", "%t", "Pontszám", target_name);
  352. return Plugin_Continue;
  353. }
  354.  
  355. public Action CommandSetPoints(int client, int args)
  356. {
  357. char arg1[32], arg2[20];
  358. GetCmdArg(1, arg1, sizeof(arg1));
  359. GetCmdArg(2, arg2, sizeof(arg2));
  360. int points = StringToInt(arg2);
  361.  
  362. if (args != 2)
  363. {
  364. ReplyToCommand(client, "\x01[AbNeR ResetScore] sm_setpoints <name or #userid> <points>");
  365. return Plugin_Continue;
  366. }
  367.  
  368. char target_name[MAX_TARGET_LENGTH];
  369. char nameadm[MAX_NAME_LENGTH];
  370. GetClientName(client, nameadm, sizeof(nameadm));
  371. int target_list[MAXPLAYERS], target_count; bool tn_is_ml;
  372.  
  373. if ((target_count = ProcessTargetString(
  374. arg1,
  375. client,
  376. target_list,
  377. MAXPLAYERS,
  378. COMMAND_TARGET_NONE,
  379. target_name,
  380. sizeof(target_name),
  381. tn_is_ml)) <= 0)
  382. {
  383. ReplyToTargetError(client, target_count);
  384. return Plugin_Continue;
  385. }
  386.  
  387. for (int i = 0; i < target_count; i++)
  388. {
  389. CS_SetClientContributionScore(target_list[i], points);
  390. }
  391.  
  392. ShowActivity2(client, "[AbNeR ResetScore] ", "%t", "Set Points of", target_name, points);
  393. return Plugin_Continue;
  394. }
  395.  
  396. public Action CommandSetAssists(int client, int args)
  397. {
  398. char arg1[32], arg2[20];
  399. GetCmdArg(1, arg1, sizeof(arg1));
  400. GetCmdArg(2, arg2, sizeof(arg2));
  401. int assists = StringToInt(arg2);
  402.  
  403. if (args != 2)
  404. {
  405. ReplyToCommand(client, "\x01[AbNeR ResetScore] sm_setassists <name or #userid> <assists>");
  406. return Plugin_Continue;
  407. }
  408.  
  409. char target_name[MAX_TARGET_LENGTH];
  410. char nameadm[MAX_NAME_LENGTH];
  411. GetClientName(client, nameadm, sizeof(nameadm));
  412. int target_list[MAXPLAYERS], target_count; bool tn_is_ml;
  413.  
  414. if ((target_count = ProcessTargetString(
  415. arg1,
  416. client,
  417. target_list,
  418. MAXPLAYERS,
  419. COMMAND_TARGET_NONE,
  420. target_name,
  421. sizeof(target_name),
  422. tn_is_ml)) <= 0)
  423. {
  424. ReplyToTargetError(client, target_count);
  425. return Plugin_Continue;
  426. }
  427.  
  428. for (int i = 0; i < target_count; i++)
  429. {
  430. CS_SetClientAssists(target_list[i], assists);
  431. }
  432.  
  433. ShowActivity2(client, "[AbNeR ResetScore] ", "%t", "Nincs ellegendő játékos lenullázni a statisztikád!", target_name, assists);
  434. return Plugin_Continue;
  435. }
  436.  
  437. public Action CommandSetStars(int client, int args)
  438. {
  439. char arg1[32], arg2[20];
  440. GetCmdArg(1, arg1, sizeof(arg1));
  441. GetCmdArg(2, arg2, sizeof(arg2));
  442. int stars = StringToInt(arg2);
  443.  
  444. if (args != 2)
  445. {
  446. ReplyToCommand(client, "\x01[AbNeR ResetScore] sm_setstars <name or #userid> <stars>");
  447. return Plugin_Continue;
  448. }
  449.  
  450. char target_name[MAX_TARGET_LENGTH];
  451. int target_list[MAXPLAYERS], target_count; bool tn_is_ml;
  452.  
  453. if ((target_count = ProcessTargetString(
  454. arg1,
  455. client,
  456. target_list,
  457. MAXPLAYERS,
  458. COMMAND_TARGET_NONE,
  459. target_name,
  460. sizeof(target_name),
  461. tn_is_ml)) <= 0)
  462. {
  463. ReplyToTargetError(client, target_count);
  464. return Plugin_Continue;
  465. }
  466.  
  467. for (int i = 0; i < target_count; i++)
  468. {
  469. CS_SetMVPCount(target_list[i], stars);
  470. }
  471.  
  472. ShowActivity2(client, "[AbNeR ResetScore] ", "%t", "Plugin elindítva.", target_name, stars);
  473. return Plugin_Continue;
  474. }
  475.  
  476. stock bool IsValidClient(int client)
  477. {
  478. if(client <= 0 ) return false;
  479. if(client > MaxClients) return false;
  480. if(!IsClientConnected(client)) return false;
  481. return IsClientInGame(client);
  482. }