problem with code
#1

I Would like to make it total cars instead of the traditional blowing up
here is the code I Tryed
pawn Код:
public OnVehicleTotal()
{
    for(new count; count < MAX_VEHICLES;count++)
    {
        new Float:health;
        GetVehicleHealth(count,health);
        if((health) < 300.0)
        {
            SetVehicleHealth(count,290.0);
            new engine,lights,alarm,doors,bonnet,boot,objective;
            total[count] = 1;
            GetVehicleParamsEx(count,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(count,false,false,alarm,doors,bonnet,boot,objective);
            for(new i;i < MAX_PLAYERS;i++)
            {
                if(IsPlayerConnected(i))
                {
                    if(IsPlayerInVehicle(i,count))
                    {
                        GameTextForPlayer(i,"~r~Totaled",12,0);
                    }
                }
            }
        }
        else
        {
            total[count] = 0;
        }
    }
    return 1;
}
The Code works when you are near the car but if you teleport a car or your spawn a car it will be totaled any way to fix this
Reply
#2

Hmm..

You can try do something similar to:

> If the car is being teleported, get the cars health, and set it's health to what it was after being teleported.
> If the car is being spawned, set the cars health to 1000.0.

Also, set the car's "total" variable, to 0.

(Kind of rigging the code, but hey, if the shoe fits.)
Reply
#3

Quote:
Originally Posted by zDivine
Посмотреть сообщение
Hmm..

You can try do something similar to:

> If the car is being teleported, get the cars health, and set it's health to what it was after being teleported.
> If the car is being spawned, set the cars health to 1000.0.

Also, set the car's "total" variable, to 0.

(Kind of rigging the code, but hey, if the shoe fits.)
Good news and bad news

The good news is it worked the bad news is it also sets the vhealth to 0 when going to a vehicle or driving by one
Reply
#4

Quote:
Originally Posted by horsemeat
Посмотреть сообщение
Good news and bad news

The good news is it worked the bad news is it also sets the vhealth to 0 when going to a vehicle or driving by one
Something is wrong elsewhere in your code then.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)