Getting largest value in an array.
#5

pawn Код:
new Float: dmg_bodypart, index = -1;
for (new i; i != 10; ++i)
{
    if (index == -1)
    {
        index = 0;
        dmg_bodypart = BodyPartDamage[playerid][0];
    }
    else if (index != -1 && BodyPartDamage[playerid][i] > BodyPartDamage[playerid][index])
    {
        index = i;
        dmg_bodypart = BodyPartDamage[playerid][i];
    }
}
if (index != -1) printf("highest damage (%f) on bodypart (%i)", dmg_bodypart, index);
Reply


Messages In This Thread
Getting largest value in an array. - by Dokins - 08.05.2015, 19:35
AW: Getting largest value in an array. - by Mencent - 08.05.2015, 19:40
Re: Getting largest value in an array. - by Konstantinos - 08.05.2015, 19:41
Re: Getting largest value in an array. - by Dokins - 08.05.2015, 19:45
Re: Getting largest value in an array. - by Konstantinos - 08.05.2015, 19:52
Re: Getting largest value in an array. - by Dokins - 08.05.2015, 19:56
Re: Getting largest value in an array. - by Dokins - 08.05.2015, 20:04

Forum Jump:


Users browsing this thread: 1 Guest(s)