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



/seatbelt? - Lajko1 - 26.01.2014

How should I make /seatbelt command so it would work like this: If player doesn't has buckled seatbelt and if he hit a wall with high speed he would be thrown out of car, in other case he won't be thrown out of car..?

Ty for help


Re: /seatbelt? - Manyula - 26.01.2014

https://sampwiki.blast.hk/wiki/SetPlayerVelocity

Create a global timer and let him check and compare certain states of the player's velocity. If the velocity drop is too big (which means, he ran into a wall or something), you can use SetPlayerVelocity to throw the player out of the car, if he didn't put on his seat belt. Simply add the check of a boolean.
Clear the variable when the player gets out of the vehicle. (OnPlayerStateChange)


Re: /seatbelt? - KJz - 26.01.2014

Already posted, my post removed.


Re: /seatbelt? - Lajko1 - 27.01.2014

Umm I know I can do something with SetPlayerVelocity but I don't know how ^^ may someone show the code or something? I can't say how I'm thankful for that


Re: /seatbelt? - Pizzy - 27.01.2014

I'm not too sure if I am much help, but you should try and download a script with /seatbelt already implemented, and read through the code. I guess that would give you a general idea of how it worked?


Re: /seatbelt? - Lajko1 - 27.01.2014

I was searching for seatbelt with that system but I couldn't find, that's why I'm asking here


Re: /seatbelt? - Manyula - 27.01.2014

https://sampforum.blast.hk/showthread.php?tid=357082

Have a look at this.


Re: /seatbelt? - Lajko1 - 27.01.2014

Umm may someone explain me this ?
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 0)
    {
        new Float:TempCarHealth;
        GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
        new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
        if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
        {
            Difference = floatdiv(Difference, 10.0);
            new Float:OldHealth;
            GetPlayerHealth(playerid, OldHealth);
            SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
        }
        CarHealth[playerid] = TempCarHealth;
    }
    else
    {
        CarHealth[playerid] = 0.0;
    }
    return 1;
}



Re: /seatbelt? - Shetch - 28.01.2014

You don't need to do anything with the velocity.

Get the vehicle's health, if it drops, remove some of the player's health.


Re: /seatbelt? - Lajko1 - 28.01.2014

Okay this lower player's health and I like it but how can I make that player will throw out of car if he will hit wall with high speed (so there will look like he was thrown out of car through front windshield window)