SA-MP Forums Archive
Vehicle respawn disabled - 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: Vehicle respawn disabled (/showthread.php?tid=244371)



Vehicle respawn disabled - Noah_Roufus - 27.03.2011

Hi! I'm working on a vehicle system and I'm trying to make it to where when the vehicle explodes, it doesn't respawn. Thanks for any help.


Re: Vehicle respawn disabled - Skylar Paul - 27.03.2011

When the vehicle health gets to 1, just destroy the vehicle.


Re: Vehicle respawn disabled - Noah_Roufus - 27.03.2011

Soo...?
pawn Код:
public OnPlayerUpdate(playerid)
{
     new Float:health;
     for(new i=0; i<MAX_VEHICLES; i++)
     {
         GetVehicleHealth(i, health);
         if(health < 1) DestroyVehicle(i);
     }
}



Re: Vehicle respawn disabled - Skylar Paul - 27.03.2011

Something along the lines of that, although for efficiency, I recommend creating a timer instead of using OnPlayerUpdate as that is called wayyyy too many times a second.


Re: Vehicle respawn disabled - Noah_Roufus - 27.03.2011

Ok, thanks. I agree with you. I realized that that was stupid after I hit post. haha Thanks for your help.


Re: Vehicle respawn disabled - Skylar Paul - 27.03.2011

Quote:
Originally Posted by Noah_Roufus
Посмотреть сообщение
Ok, thanks. I agree with you. I realized that that was stupid after I hit post. haha Thanks for your help.
You got the point of my post, nonetheless. Oh, and not a problem.


Re: Vehicle respawn disabled - Noah_Roufus - 27.03.2011

OK, I have this. It still doesn't destroy the vehicles. Any advice?

pawn Код:
forward DestroyDeadVehicles();

public OnGameModeInit()
{  
    SetTimer("DestroyDeadVehicles", 2000, true);
}

public DestroyDeadVehicles()
{
    new Float:health;
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        GetVehicleHealth(i, health);
        if(health <= 1) DestroyVehicle(i);
    }
    return 1;
}



Re: Vehicle respawn disabled - Skylar Paul - 27.03.2011

Hmm, I'm thinking the vehicle starts to flame at a higher health than 1, so check the wiki and see which health amount sets the vehicle on fire, and put it a little higher than that.


Re: Vehicle respawn disabled - Hashski - 27.03.2011

pawn Код:
forward DestroyDeadVehicles();

public OnGameModeInit()
{  
    SetTimer("DestroyDeadVehicles", 2000, true);
}

public DestroyDeadVehicles()
{
    new Float:health;
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        GetVehicleHealth(i, health);
        if(health <= 251) DestroyVehicle(i);
    }
    return 1;
}