How to kill a vehicle
#1

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

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

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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)