SA-MP Forums Archive
How to detect the highest vehicle health ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to detect the highest vehicle health ? (/showthread.php?tid=255205)



How to detect the highest vehicle health ? - Michael@Belgium - 14.05.2011

Well, that's the question
I've tried several things but ... it just don't work. IM MAKING A DERBY GM (update)!
Now i have this:

SOLVED

------------------------------------------------------------------------------------------------------
And i have another problem

pawn Код:
forward NewMap();
public NewMap()
{
    foreach(Player,i)
    {
             DontSpectating(i);
        SetPVarInt(i,"Missiles",0);
        SetPlayerColor(i,COLOR_GREEN);
        new OtherSpawn = random(7);
        switch (OtherSpawn)
        {
            case 0:
            {
                //blahblah
            }
            case 1:
            {
                //blahblah
            }
            case 2:
            {
                //blahblah
            }
            case 3:
            {
                //blahblah
            }
            case 4:
            {
                //blahblah
            }
            case 5:
            {
                //blahblah
            }
            case 6:
            {
                //blahblah
            }
        }
        //EndRound();
    }
    return 1;
}

stock DontSpectating(playerid)
{
    SpawnPlayer(playerid);
    TogglePlayerSpectating(playerid,0);
}
They must stop spectating and spawn ! x)


Re: How to detect the highest vehicle health ? - Sascha - 14.05.2011

try this..
pawn Код:
forward Winner();
public Winner()
{
    new Float:maxx = 0;
    new winner = -1;
    foreach(Playeri, i)
    {
        new Float:h;
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInAnyVehicle(i))
            {
                GetVehicleHealth(GetPlayerVehicleID(i), h);
                if(h > maxx)
                {
                    maxx = h;
                    winner = i;
                }
            }
        }
    }
    if(winner != -1)
    {
        new namee[MAX_PLAYER_NAME];
        new stringg[80];
        GetPlayerName(winner,namee,sizeof(namee));
        format(stringg,sizeof(stringg)," ~n~ ~n~ ~n~ ~n~ %s won this round ! ~n~ ~g~ SURVIVER !",namee);
        GameTextForAll(stringg,2500,6);
        SetPlayerScore(winner, GetPlayerScore(winner)+3);//And normally the winner gains 3 points, but if you can do it now, i want to give the winner random score x) but not more then 5...
    }
    return 1;
}



Re: How to detect the highest vehicle health ? - Michael@Belgium - 14.05.2011

Quote:
Originally Posted by Sascha
Посмотреть сообщение
try this..
pawn Код:
forward Winner();
public Winner()
{
    new Float:maxx = 0;
    new winner = -1;
    foreach(Playeri, i)
    {
        new Float:h;
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInAnyVehicle(i))
            {
                GetVehicleHealth(GetPlayerVehicleID(i), h);
                if(h > maxx)
                {
                    maxx = h;
                    winner = i;
                }
            }
        }
    }
    if(winner != -1)
    {
        new namee[MAX_PLAYER_NAME];
        new stringg[80];
        GetPlayerName(winner,namee,sizeof(namee));
        format(stringg,sizeof(stringg)," ~n~ ~n~ ~n~ ~n~ %s won this round ! ~n~ ~g~ SURVIVER !",namee);
        GameTextForAll(stringg,2500,6);
        SetPlayerScore(winner, GetPlayerScore(winner)+3);//And normally the winner gains 3 points, but if you can do it now, i want to give the winner random score x) but not more then 5...
    }
    return 1;
}
Euh ok ... you've change anything ? xD it's like the same ;p


Re: How to detect the highest vehicle health ? - Sascha - 14.05.2011

I've set the "new Float:maxx = 0;" and "new winner = -1;", as well as the "if(winner != -1)..,...." out of the "Foreach"
if I'm right it won't work if you put it into the foreach, as it would detect each player as winner (except if he isn't in a vehicle or the vehicle has the health 0.0000)


Re: How to detect the highest vehicle health ? - Michael@Belgium - 14.05.2011

Quote:
Originally Posted by Sascha
Посмотреть сообщение
I've set the "new Float:maxx = 0;" and "new winner = -1;", as well as the "if(winner != -1)..,...." out of the "Foreach"
if I'm right it won't work if you put it into the foreach, as it would detect each player as winner (except if he isn't in a vehicle or the vehicle has the health 0.0000)
ah ok,
Well i tested it, and we were with 2 players ... me and another one x) i didn't 'drive' ... so i didn't lost health but the other bumped against the wall ... and who wins ... THE BUMPER xD


Re: How to detect the highest vehicle health ? - Sascha - 14.05.2011

fail lol...
well if there will be any problems, you can PM me^^


Re: How to detect the highest vehicle health ? - Michael@Belgium - 14.05.2011

Quote:
Originally Posted by Sascha
Посмотреть сообщение
fail lol...
well if there will be any problems, you can PM me^^
;o well i added a new problem xD if you didn't saw it


Re: How to detect the highest vehicle health ? - Michael@Belgium - 16.05.2011

HELP ! (i bumped after 48 hours )


Re: How to detect the highest vehicle health ? - WackoX - 16.05.2011

What if there are 16 cars all with 1000.0 health?


Re: How to detect the highest vehicle health ? - Michael@Belgium - 16.05.2011

Quote:
Originally Posted by WackoX
Посмотреть сообщение
What if there are 16 cars all with 1000.0 health?
Lol ... i don't think 16 ppl are not going to play derby ?! :S It mustn't happen i think .. it's not going to be xD