Jump to content

[REL] Vehicle Airbrake Script


Recommended Posts

My Airbrake script I made for my MTA DM server and released it because it's quite useful. It's based off of s0beit's airbrake script where you can hover around in your car, but it's scripted for an MTA DM server and 100% hack free. It's a simple clientside script.

Info:

Vehicle Airbrake Script

By: OffRoader23

Controls:

'B' Enable/Disable Airbrake

'Num Pad 8' - Move Forwards

'Num Pad 5' - Move Backwards

'Num Pad 4' - Rotate Car Left

'Num Pad 6' - Rotate Car Right

'Num Pad +' - Move Car Up

'Num Pad -' - Move Car Down

Download

117.png

Edited by Guest
Link to comment

nice script! I had the same idea but didnt had the time to code it^^ and btw a suggestion: To make it easier for admins to see if someone uses the sobeit or your airbreak it would be good to add an image about the car that uses the scripted airbreak just like the chaticon =)

Link to comment

Nice script. But one thing: Could you change some buttons? In the SA stunting scene many stunters use the 'San Andreas Control Center (SACC)'. Those commands are the same. Would be just helpful to have the same buttons in MTA like in the singeplayer. But not all functions should be in it.

Would be:

'Num Pad Divide' - Move Forwards (accelerate)

'Num Pad 7' - Rotate Car Left

'Num Pad 9' - Rotate Car Left

'Num Pad +' - Move Car Up

'Num Pad Multiply' - Freeze vehicle at current position

That move backwards, left and right shouldn't be there. Hope you know what I mean. Maybe would be good if you download the SACC and test the commands to see what I'm talking about.

http://gta.onlinewelten.com/downloads.php?id=127

Link to comment

Well you can easily edit it yourself, I used that program in single player also but always changed the controls to these because it just makes it easier to remember unlike those controls. If you want to edit it to be those controls you just have to open the brake.lua and look at the if getKeyState("key") and change it to what you want. You can get all the key names from this page.

http://development.mtasa.com/index.php?title=Key_names

Link to comment
  • 1 year later...

A link for pastebay:

http://mta.pastebay.com/78022

Or you can copy it from here:

local thisResourceRoot = getResourceRootElement(getThisResource())
 
function activateBreak ( )
if  ( carbreak ) then
	carbreak = nil
	setElementCollisionsEnabled ( getPedOccupiedVehicle ( getLocalPlayer() ), true )
	setGravity ( 0.008 )
	removeEventHandler ( "onClientRender", getRootElement(), checkBreak )
else
	carbreak = 1
	setElementCollisionsEnabled ( getPedOccupiedVehicle ( getLocalPlayer() ), false )
	setElementVelocity ( getPedOccupiedVehicle ( getLocalPlayer() ), 0, 0, 0 )
	setGravity ( 0.001 )
	addEventHandler ( "onClientRender", getRootElement(), checkBreak )
end
end
addCommandHandler ( "airbrake" , activateBreak )
 
function thisResourceStart ()
bindKey ( "b", "down", activateBreak, "AirBreakDance" )
end
 
function checkBreak()
if isPedInVehicle (getLocalPlayer()) then
	local vehicle = getPedOccupiedVehicle ( getLocalPlayer() )
	setElementVelocity ( vehicle, 0, 0, 0 )
	local px, py, pz = getElementPosition ( vehicle )
	local rx, ry, rz = getElementRotation ( vehicle )
	setElementRotation ( vehicle, 0, 0, rz)
	if ( getKeyState ( "num_8") ) then
		local x = (2)*math.cos((rz+90)*math.pi/180)
		local y = (2)*math.sin((rz+90)*math.pi/180)
		local nx = px + x
		local ny = py + y
		setElementRotation ( vehicle, 0, 0, rz)
		setElementPosition ( vehicle, nx, ny, pz )
	end
	if ( getKeyState ( "num_5") ) then		
		local x = (-2)*math.cos((rz+90)*math.pi/180)
		local y = (-2)*math.sin((rz+90)*math.pi/180)
		local nx = px + x
		local ny = py + y
		setElementRotation ( vehicle, 0, 0, rz)
		setElementPosition ( vehicle, nx, ny, pz )
	end	
	if ( getKeyState ( "num_4") ) then		
		setElementRotation ( vehicle, 0, 0, rz + 5)
	end	
	if ( getKeyState ( "num_6") ) then		
		setElementRotation ( vehicle, 0, 0, rz - 5)
	end
	if ( getKeyState ( "num_add") ) then		
		setElementPosition ( vehicle, px, py, pz + 2)
	end
	if ( getKeyState ( "num_sub") ) then		
		setElementPosition ( vehicle, px, py, pz - 2)
	end
end
end
 
addEventHandler ( "onClientResourceStart", thisResourceRoot, thisResourceStart )

Help file:

<help>
Vehicle Airbrake Script
By: OffRoader23
 
Controls:
'B' Enable/Disable Airbrake
'Num Pad 8' - Move Forwards
'Num Pad 5' - Move Backwards
'Num Pad 4' - Rotate Car Left
'Num Pad 6' - Rotate Car Right
'Num Pad +' - Move Car Up
'Num Pad -' - Move Car Down
</help>

Meta file:

<meta>
<info author="OffRoader23" description="Car Airbrake System" />
<script src="brake.lua" type="client" />
<config src="help.xml" type="client" />
</meta>

Don't bother telling me I stole his code. First of all, I am simply posting a working version. Secondly, he's my friend and I talk to him everyday. I am not claiming his code as mine and even if I did, he wouldn't care.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...