View Single Post
Shane1390
Member
Join Date: Apr 2018
Old 09-18-2018 , 09:49   Re: How to get the lowest health of the player?
#6

Bool function on new syntax, since you need to iterate through every client, I guess the earlier return point could help a bit(?)

Code:
public bool playerHasLowestHealth(int client)
{
	if (!IsValidClient(client)) {
		return false;
	}
	int clientHp = GetClientHealth(client);
	for (int i = 1; i <= MAXPLAYERS; i++) {
		if (!IsValidClient(i) || !IsPlayerAlive(i)) {
			continue;
		} else if (GetClientHealth(i) < clientHp) {
			return false;
		}
	}
	return true;
}

stock bool IsValidClient(int client, bool nobots = false) 
{
    if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)) || !IsClientInGame(client)) {
        return false;
    }
    return true;
}

Last edited by Shane1390; 09-18-2018 at 09:50. Reason: bracket went funny
Shane1390 is offline