ABS Braking System Script help - 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: ABS Braking System Script help (
/showthread.php?tid=658630)
ABS Braking System Script help -
BrightLeaN - 08.09.2018
I am trying to create a ABS System for Vehicles like
When i press the buttom Brake(S) less then 3 seconds the car will break normaly
but when i hold the Brake(S) more then 3 seconds the car will use ABS like it will Brake and stop and brake in a fast time but i don't know how to code it. Can someone help?
i know that this section is the right one
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
Re: ABS Braking System Script help -
Infin1ty - 09.09.2018
I have personally never attempted something like this however using vehicle velocity you should be able to do this, along with OnPlayerKeyStateChange.
Re: ABS Braking System Script help -
BrightLeaN - 09.09.2018
"using vehicle velocity"
i only want a simple thing like how i explained it nothing with velocity just with holding the brake key but i have no clue how to script it
Re: ABS Braking System Script help -
ShihabSoft - 09.09.2018
Try this function
Код:
stock SetVehicleSpeed(vehicleid, Float:speed)
{
new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:a;
GetVehicleVelocity(vehicleid, x1, y1, z1);
GetVehiclePos(vehicleid, x2, y2, z2);
GetVehicleZAngle(vehicleid, a); a = 360 - a;
x1 = (floatsin(a, degrees) * (speed/100) + floatcos(a, degrees) * 0 + x2) - x2;
y1 = (floatcos(a, degrees) * (speed/100) + floatsin(a, degrees) * 0 + y2) - y2;
SetVehicleVelocity(vehicleid, x1, y1, z1);
}
from
https://sampforum.blast.hk/showthread.php?tid=307052
Re: ABS Braking System Script help -
Sithis - 10.09.2018
Quote:
Originally Posted by BrightLeaN
"using vehicle velocity"
i only want a simple thing like how i explained it nothing with velocity just with holding the brake key but i have no clue how to script it
|
If you don't want to "use velocity", then it will not be possible to script it as you "explained". What the other user meant, is that you will need to create a callback for when the brake key is pressed/held (your preference), and in that callback you should lower the velocity of the vehicle manually. This can all be found in the wiki. If that's too much work for you, then you should consider hiring a scripter or just give up since you don't want to put in any effort.