The function is also in efficient in that the order of operations for example is not optimized which is critical for a function that runs constantly.
Code:
if (G_bConfigLoaded && !G_bRoundTransition && IsValidEdict(trigger))
{
for (new index = 0; index < entArraySize; index++)
{
if (entArray[index][ent_hammerid] == Entity_GetHammerID(trigger))
{
if (entArray[index][ent_trigger] == 1)
{
if (G_bRestricted[client] || G_bTemp[client])
{
if (entArray[index][ent_torient] == 0)
{
CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted");
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, straight);
return Plugin_Handled;
}
else if (entArray[index][ent_torient] == 1)
{
CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted");
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, left);
return Plugin_Handled;
}
else if (entArray[index][ent_torient] == 2)
{
CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted");
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, right);
return Plugin_Handled;
}
else if (entArray[index][ent_torient] == 3)
{
CPrintToChat(client, "\x07%s[entWatch] \x07%s%t", color_tag, color_warning, "status restricted");
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, back);
return Plugin_Handled;
}
}
}
}
}
}
Note that in this code we are waiting to check if the client is even supposed to be restricted at the very end within a loop! Also any check that can be done outside of a loop needs to for performance.