Advertisement
Guest User

Untitled

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