SA-MP Forums Archive
How to kill a vehicle - 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: How to kill a vehicle (/showthread.php?tid=415869)



How to kill a vehicle - xXRealLegitXx - 15.02.2013

The title is a bit misleading, I need a code that shuts the vehicle off when the damage reaches 400.0 on /dl


Re: How to kill a vehicle - T0pAz - 15.02.2013

Someone like this should work.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new Float:fVehicleHealth; GetVehicleHealth(vehicleid, fVehicleHealth);
       
        if(fVehicleHealth <= 20.0)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
        }
    }

    return 1;
}



Re: How to kill a vehicle - xXRealLegitXx - 15.02.2013

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Someone like this should work.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new Float:fVehicleHealth; GetVehicleHealth(vehicleid, fVehicleHealth);
       
        if(fVehicleHealth <= 20.0)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
        }
    }

    return 1;
}
Ermagerd thank you. :P


Re: How to kill a vehicle - xXRealLegitXx - 15.02.2013

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Someone like this should work.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new Float:fVehicleHealth; GetVehicleHealth(vehicleid, fVehicleHealth);
       
        if(fVehicleHealth <= 20.0)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
        }
    }

    return 1;
}
So I just tried to add a SendClientMessage to let the player know their vehicle was damaged, but the vehicles won't even turn on.

Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new Float:fVehicleHealth; GetVehicleHealth(vehicleid, fVehicleHealth);

		if(fVehicleHealth <= 400.0)
		SendClientMessage(playerid, yellow, "Your vehicle has taken too much damage and refuses to move! ((Find a Mechanic))");
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
        }
    }

    return 1;
}
It's supposed to turn on with /v > engine


Re: How to kill a vehicle - xXRealLegitXx - 15.02.2013

Quote:
Originally Posted by xXRealLegitXx
Посмотреть сообщение
So I just tried to add a SendClientMessage to let the player know their vehicle was damaged, but the vehicles won't even turn on.

Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new Float:fVehicleHealth; GetVehicleHealth(vehicleid, fVehicleHealth);

		if(fVehicleHealth <= 400.0)
		SendClientMessage(playerid, yellow, "Your vehicle has taken too much damage and refuses to move! ((Find a Mechanic))");
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
        }
    }

    return 1;
}
It's supposed to turn on with /v > engine
I fixed it by moving send client message down below setvehicleperamsex, but now it spams the chat with 50 lol :P I'll do some rearranging and see what I can come up with, but please help


Re: How to kill a vehicle - doreto - 15.02.2013

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new Float:fVehicleHealth; GetVehicleHealth(vehicleid, fVehicleHealth);
       
        if(fVehicleHealth <= 20.0)
        {
            SendClientMessage(playerid, yellow, "Your vehicle has taken too much damage and refuses to move! ((Find a Mechanic))")''
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
        }
    }

    return 1;
}



Re: How to kill a vehicle - MP2 - 15.02.2013

Vehicles set on fire at 250 health. It's NEVER going to reach 20! Also, there is no need to check this so often. It would be better on a 1+ second timer. Most servers have a 'main' timer with their player loop in there.


Re: How to kill a vehicle - Vince - 15.02.2013

Hell, even OnDamageStatusUpdate would be better for this. A vehicle doesn't get damaged by itself. Don't abuse OnPlayerUpdate for this.