How to detect the highest vehicle health ?
#1

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)
Reply
#2

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;
}
Reply
#3

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
Reply
#4

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)
Reply
#5

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
Reply
#6

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

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
Reply
#8

HELP ! (i bumped after 48 hours )
Reply
#9

What if there are 16 cars all with 1000.0 health?
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)