From c4e3b3a17cfe025a6e0aec57929a4e87e3452a7c Mon Sep 17 00:00:00 2001 From: Dogan Date: Fri, 31 May 2019 01:27:18 +0200 Subject: [PATCH] ExtraCommands: better sm_setscore make it possible to decrease or increase the current score --- ExtraCommands/scripting/ExtraCommands.sp | 46 +++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/ExtraCommands/scripting/ExtraCommands.sp b/ExtraCommands/scripting/ExtraCommands.sp index 5dc71045..a11fa797 100644 --- a/ExtraCommands/scripting/ExtraCommands.sp +++ b/ExtraCommands/scripting/ExtraCommands.sp @@ -51,7 +51,7 @@ public void OnPluginStart() RegAdminCmd("sm_modelscale", Command_ModelScale, ADMFLAG_GENERIC, "sm_modelscale <#userid|name> "); RegAdminCmd("sm_resize", Command_ModelScale, ADMFLAG_GENERIC, "sm_resize <#userid|name> "); RegAdminCmd("sm_setmodel", Command_SetModel, ADMFLAG_GENERIC, "sm_setmodel <#userid|name> "); - RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> "); + RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> <(optional +/-) value>"); RegAdminCmd("sm_setdeaths", Command_SetDeaths, ADMFLAG_GENERIC, "sm_setdeaths <#userid|name> "); RegAdminCmd("sm_setmvp", Command_SetMvp, ADMFLAG_GENERIC, "sm_setmvp <#userid|name> "); RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore "); @@ -918,7 +918,7 @@ public Action Command_SetScore(int client, int argc) { if(argc < 2) { - ReplyToCommand(client, "[SM] Usage: sm_setscore <#userid|name> "); + ReplyToCommand(client, "[SM] Usage: sm_setscore <#userid|name> <(optional +/-) value>"); return Plugin_Handled; } @@ -932,25 +932,53 @@ public Action Command_SetScore(int client, int argc) GetCmdArg(1, sArgs, sizeof(sArgs)); GetCmdArg(2, sArgs2, sizeof(sArgs2)); - int iVal = StringToInt(sArgs2); - if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0) { ReplyToTargetError(client, iTargetCount); return Plugin_Handled; } - for(int i = 0; i < iTargetCount; i++) + int iMode = 0; + int iVal; + + if(StrContains(sArgs2, "+", true) != -1) { - SetEntProp(iTargets[i], Prop_Data, "m_iFrags", iVal); + iMode = 1; + iVal = StringToInt(sArgs2[1]); + } + else if(StrContains(sArgs2, "-", true) != -1) + { + iMode = 2; + iVal = StringToInt(sArgs2[1]); + } + else + { + iVal = StringToInt(sArgs2); } - ShowActivity2(client, "\x01[SM] \x04", "\x01Set score to \x04%d\x01 on target \x04%s", iVal, sTargetName); + for(int i = 0; i < iTargetCount; i++) + { + if(iMode == 1) + { + SetEntProp(iTargets[i], Prop_Data, "m_iFrags", GetEntProp(iTargets[i], Prop_Data, "m_iFrags") + iVal); + ShowActivity2(client, "\x01[SM] \x04", "\x01Increased score by \x04%d\x01 on target \x04%s", iVal, sTargetName); + } + else if(iMode == 2) + { + SetEntProp(iTargets[i], Prop_Data, "m_iFrags", GetEntProp(iTargets[i], Prop_Data, "m_iFrags") - iVal); + ShowActivity2(client, "\x01[SM] \x04", "\x01Decreased score by \x04%d\x01 on target \x04%s", iVal, sTargetName); + } + else + { + SetEntProp(iTargets[i], Prop_Data, "m_iFrags", iVal); + ShowActivity2(client, "\x01[SM] \x04", "\x01Set score to \x04%d\x01 on target \x04%s", iVal, sTargetName); + } + } if(iTargetCount > 1) - LogAction(client, -1, "\"%L\" set score to \"%d\" on target \"%s\"", client, iVal, sTargetName); + LogAction(client, -1, "\"%L\" set score \"%s\" on target \"%s\"", client, sArgs2, sTargetName); else - LogAction(client, iTargets[0], "\"%L\" set score to \"%d\" on target \"%L\"", client, iVal, iTargets[0]); + LogAction(client, iTargets[0], "\"%L\" set score \"%s\" on target \"%L\"", client, sArgs2, iTargets[0]); return Plugin_Handled; }