SA-MP Forums Archive
problem with code - 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)
+--- Thread: problem with code (/showthread.php?tid=431583)



problem with code - horsemeat - 19.04.2013

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


Re: problem with code - zDivine - 19.04.2013

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.)


Re: problem with code - horsemeat - 19.04.2013

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


Re: problem with code - zDivine - 19.04.2013

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.