Permalink
Browse files

Fix negative value with rslays

  • Loading branch information...
Bara committed May 24, 2018
1 parent aa1f693 commit 7ca6c2868c3fdf5e9f2f60aaabfafbb150f11231
Showing with 39 additions and 6 deletions.
  1. +14 −0 addons/sourcemod/scripting/ttt/core/natives.sp
  2. +25 −6 addons/sourcemod/scripting/ttt/ttt.sp
@@ -320,6 +320,13 @@ public int Native_AddRoundSlays(Handle plugin, int numParams)
if (TTT_IsClientValid(client))
{
int rounds = GetNativeCell(2);
if (rounds < 1)
{
CReplyToCommand(client, "Rounds must be positive and higher as zero.");
return -1;
}
bool force = view_as<bool>(GetNativeCell(3));
g_iRoundSlays[client] += rounds;
@@ -351,6 +358,13 @@ public int Native_SetRoundSlays(Handle plugin, int numParams)
if (TTT_IsClientValid(client))
{
int rounds = GetNativeCell(2);
if (rounds < 1)
{
CReplyToCommand(client, "Rounds must be positive and higher as zero.");
return -1;
}
bool force = view_as<bool>(GetNativeCell(3));
g_iRoundSlays[client] = rounds;
@@ -868,20 +868,33 @@ public Action Timer_Selection(Handle hTimer)
{
if (IsPlayerAlive(i) && g_iRoundSlays[i] > 0)
{
if (g_iRoundSlays[i] < 0)
{
g_iRoundSlays[i] = 0;
UpdateRoundSlaysCookie(i);
continue;
}
else if (g_iRoundSlays[i] == 0)
{
UpdateRoundSlaysCookie(i);
continue;
}
ForcePlayerSuicide(i);
g_iRoundSlays[i]--;
if (g_cOpenRulesOnPunish.BoolValue)
{
TTT_ClientOpenRules(i);
}
if (g_iRoundSlays[i] > 0)
{
CPrintToChat(i, "%s %T", g_sTag, "RS - Slayed", i, g_iRoundSlays[i]);
LogAction(0, i, "\"%L\" was slayed! Remaining Rounds: %d", i, g_iRoundSlays[i]);
}
UpdateRoundSlaysCookie(i);
if (g_cOpenRulesOnPunish.BoolValue)
{
TTT_ClientOpenRules(i);
}
}
}
@@ -2084,12 +2097,18 @@ public Action Command_RSlays(int client, int args)
if (target == -1)
{
ReplyToCommand(client, "[SM] Invalid target.");
CReplyToCommand(client, "Invalid target");
return Plugin_Handled;
}
int rounds = StringToInt(arg2);
if (rounds < 0)
{
CReplyToCommand(client, "Rounds must be zero (reset) or higher.");
return Plugin_Handled;
}
TTT_SetRoundSlays(target, rounds, true);
LoopValidClients(j)

0 comments on commit 7ca6c28

Please sign in to comment.