SA-MP Forums Archive
On Vehicle damage - 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: On Vehicle damage (/showthread.php?tid=452662)



On Vehicle damage REP +++ for help - CTAntonio - 22.07.2013

How can I make FS when vehicle HP is 260 to vehicle engine is off and he cannot start it,
I have made this but it's not working, idk wha
Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
	new Float:vehiclehealth;
	GetVehicleHealth(vehicleid, vehiclehealth);
	if(vehiclehealth <= 280)
	{
		SetVehicleHealth(vehicleid, 280);
		new engine, lights, alarm, doors, bonnet, boot, objective;
		GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessage(playerid, 0xFF0000FF, "Text");
	}
  	return 1;
}



Re: On Vehicle damage - JimmyCh - 22.07.2013

You can put this
pawn Код:
TogglePlayerControllable(playerid, 0);
This won't let him move or anything, I dont know if its what ur looking for


Re: On Vehicle damage - CTAntonio - 22.07.2013

no, not that
well when car is heavy damaged 250-270hp, Car stop, and can't move, but player can and he need to call assistance to fix it, i have seen it on many RP servers...


Re: On Vehicle damage - Misiur - 22.07.2013

Are you testing this FS ramming into trees, or manually changing vehicle health?

https://sampwiki.blast.hk/wiki/OnVehicleDamageStatusUpdate
If the latter, then according to orange box it's not the way to go


Re: On Vehicle damage - Antonio144 - 22.07.2013

"This callback is called when a vehicle element such as doors, tires, panels, or lights get damaged. This does not include vehicle health changes" - wiki

You'll need a timer to accomplish that.


Re: On Vehicle damage - reckst4r - 22.07.2013

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new Float:h, id = GetPlayerVehicleID(playerid);
        GetVehicleHealth(id, h);
        if(h <= 260.0)
        {
            SetVehicleHealth(id, 260.0);
            new engine, lights, alarm, doors, bonnet, boot, objective;
            new vid = GetPlayerVehicleID(playerid);
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            if(engine) SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective); // engine off
            GameTextForPlayer(playerid, "Your engine has broken down.", 5000, 3);
        }
        return 1;
    }
    return 1;
}

CMD:engine(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new Float:h;
        GetVehicleHealth(GetPlayerVehicleID(playerid), h);
        if(h <= 260.0)
        {
        SendClientMessage(playerid, COLOR_GREY, "You can not use this command while inside a broken vehicle!");
        }
        else
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            new vid = GetPlayerVehicleID(playerid);
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            if(engine) SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective); // engine off
            else SetVehicleParamsEx(vid,1,lights,alarm,doors,bonnet,boot,objective); // engine on
        }
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You have to be inside a vehicle to use this command!");
    }
    return 1;
}
There you go.
(I'm assuming you're using a command to start an engine)