SA-MP Forums Archive
Need help with seatbelt - 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: Need help with seatbelt (/showthread.php?tid=492117)



Need help with seatbelt - Lajko1 - 02.02.2014

Hey guys I want to make if player is driving fast and if he crash he will be thrown out of car here is the code:

But when I crash into the object with high speed sometimes I'm thrown out of car and sometimes not, why?

pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    if(SeatBelt[playerid] == 0)
    {
        new Float:phealth;
        new Float:vhealth;
        GetPlayerHealth(playerid, phealth);
        new veh = GetPlayerVehicleID(playerid);
        GetVehicleHealth(veh, vhealth);
        SetPlayerHealth(playerid, phealth - vhealth /100);
        new Float:Velocity[3];
        GetVehicleVelocity(veh, Velocity[0], Velocity[1], Velocity[2]);
        if(Velocity[1] > 0.5)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0],pos[1],pos[2]);
            SetPlayerPos(playerid, pos[0],pos[1],pos[2]+0.4);
            ApplyAnimation(playerid,"ped","CAR_fallout_LHS",4.1,0,1,1,1,1,1);
            SendClientMessage(playerid,-1,"You've been thrown from the vehicle! Press shift to get up.");
        }
        else if(Velocity[0] > 0.5)
        {
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0],pos[1],pos[2]);
            SetPlayerPos(playerid, pos[0],pos[1],pos[2]+0.4);
            ApplyAnimation(playerid,"ped","CAR_fallout_LHS",4.1,0,1,1,1,1,1);
            SendClientMessage(playerid,-1,"You've been thrown from the vehicle! Press shift to get up.");
        }
    }
    else
    {
    }
    return 1;
}



Re: Need help with seatbelt - Lajko1 - 02.02.2014

c'mon I really need help with this guys :/


Re: Need help with seatbelt - Hoborific - 02.02.2014

Because the callback is called when they crash by the time you get their velocity, they might of already stopped from that brickwall they drove straight into, it would be optimal to determine how much damage the car took from the crash and determine if they actually crashed by checking their velocity/distance and then throwing them out of the car rather then checking if their velocity is greater than 0.5 after the crash.


Re: Need help with seatbelt - Lajko1 - 02.02.2014

Hmm I see, but how should I make it work may you show a part of code ?


Re: Need help with seatbelt - Lajko1 - 03.02.2014

Still need help with this, please