Need help with seatbelt
#1

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

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

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

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

Still need help with this, please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)