ExtraCommands: better sm_setscore
make it possible to decrease or increase the current score
This commit is contained in:
parent
1c3352f08a
commit
c4e3b3a17c
@ -51,7 +51,7 @@ public void OnPluginStart()
|
|||||||
RegAdminCmd("sm_modelscale", Command_ModelScale, ADMFLAG_GENERIC, "sm_modelscale <#userid|name> <scale>");
|
RegAdminCmd("sm_modelscale", Command_ModelScale, ADMFLAG_GENERIC, "sm_modelscale <#userid|name> <scale>");
|
||||||
RegAdminCmd("sm_resize", Command_ModelScale, ADMFLAG_GENERIC, "sm_resize <#userid|name> <scale>");
|
RegAdminCmd("sm_resize", Command_ModelScale, ADMFLAG_GENERIC, "sm_resize <#userid|name> <scale>");
|
||||||
RegAdminCmd("sm_setmodel", Command_SetModel, ADMFLAG_GENERIC, "sm_setmodel <#userid|name> <modelpath>");
|
RegAdminCmd("sm_setmodel", Command_SetModel, ADMFLAG_GENERIC, "sm_setmodel <#userid|name> <modelpath>");
|
||||||
RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> <value>");
|
RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> <(optional +/-) value>");
|
||||||
RegAdminCmd("sm_setdeaths", Command_SetDeaths, ADMFLAG_GENERIC, "sm_setdeaths <#userid|name> <value>");
|
RegAdminCmd("sm_setdeaths", Command_SetDeaths, ADMFLAG_GENERIC, "sm_setdeaths <#userid|name> <value>");
|
||||||
RegAdminCmd("sm_setmvp", Command_SetMvp, ADMFLAG_GENERIC, "sm_setmvp <#userid|name> <value>");
|
RegAdminCmd("sm_setmvp", Command_SetMvp, ADMFLAG_GENERIC, "sm_setmvp <#userid|name> <value>");
|
||||||
RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore <team> <value>");
|
RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore <team> <value>");
|
||||||
@ -918,7 +918,7 @@ public Action Command_SetScore(int client, int argc)
|
|||||||
{
|
{
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_setscore <#userid|name> <value>");
|
ReplyToCommand(client, "[SM] Usage: sm_setscore <#userid|name> <(optional +/-) value>");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,25 +932,53 @@ public Action Command_SetScore(int client, int argc)
|
|||||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
GetCmdArg(1, sArgs, sizeof(sArgs));
|
||||||
GetCmdArg(2, sArgs2, sizeof(sArgs2));
|
GetCmdArg(2, sArgs2, sizeof(sArgs2));
|
||||||
|
|
||||||
int iVal = StringToInt(sArgs2);
|
|
||||||
|
|
||||||
if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
|
if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
|
||||||
{
|
{
|
||||||
ReplyToTargetError(client, iTargetCount);
|
ReplyToTargetError(client, iTargetCount);
|
||||||
return Plugin_Handled;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
ShowActivity2(client, "\x01[SM] \x04", "\x01Set score to \x04%d\x01 on target \x04%s", iVal, sTargetName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(iTargetCount > 1)
|
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
|
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;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user