Permalink
Browse files

Log invalid target index - Random Teleport

Don't reduce credits with failed teleporter
  • Loading branch information...
Bara committed May 18, 2018
1 parent 89b62c7 commit 5635527e75ab621909efa559e9992e93c34b05e8
@@ -602,7 +602,7 @@ stock void TTT_ShowOverlayToAll(const char[] overlaypath)
stock int TTT_GetRandomPlayer(bool alive = true, int role = -1)
{
int[] clients = new int[MaxClients + 1];
int clientCount;
int clientCount = 0;
LoopValidClients(i)
{
@@ -618,7 +618,13 @@ stock int TTT_GetRandomPlayer(bool alive = true, int role = -1)
clients[clientCount++] = i;
}
return (clientCount == 0) ? -1 : clients[GetRandomInt(0, clientCount-1)];
if (clientCount == 0)
{
return -1;
}
return clients[GetRandomInt(0, clientCount-1)];
}
stock bool TTT_IsWorldDamage(int iAttacker, int damagetype)
@@ -146,6 +146,11 @@ public Action TTT_OnItemPurchased(int client, const char[] itemshort, bool count
int target = RandomTeleport(client);
if (target == -1)
{
return Plugin_Stop;
}
if (count && target != -1)
{
if (role == TTT_TEAM_TRAITOR)
@@ -179,9 +184,15 @@ int RandomTeleport(int client)
int target = TTT_GetRandomPlayer(bAlive);
if (target == -1 || !TTT_IsClientValid(target))
{
LogToFile(g_sLog, "[Random Teleport] Target %d is invalid (with Ragdoll? %d)", target, g_cRagdoll.BoolValue);
return -1;
}
if (g_bDebug)
{
LogToFile(g_sLog, "[Random Teleport] Target: \"%L\" - UserID: %d - Index: %d - Valid: %d", target, GetClientUserId(target), target, TTT_IsClientValid(target));
LogToFile(g_sLog, "[Random Teleport] Target: \"%L\" - UserID: %d - Index: %d - Valid: %d - Ragdoll: %d", target, GetClientUserId(target), target, TTT_IsClientValid(target), g_cRagdoll.BoolValue);
}
if (TTT_IsPlayerAlive(target))

0 comments on commit 5635527

Please sign in to comment.