Jump to content

Cruise control script?


Recommended Posts

  • 2 weeks later...

In the future, DaK, it'd be nice if you didn't plagiarize, let alone steal my scripts. This is not the first time it's happened. Just learn scriptng yourself. What if you need something and there's no ready script to steal? :roll:

Link to comment
  • 1 month later...

Hello, i know this topic is a few months old, but i have infact made a successful cruise control script, even though it is kinda weird :D

--some form of cruise control
theCruiseTimer = "noone-nothing"
function cruiseOff(thePlayer)
--its on, so turn it off
killTimer(theCruiseTimer)
theCruiseTimer = "noone-nothing"
setControlState ( thePlayer, "accelerate", false )
setControlState ( thePlayer, "brake_reverse", false )
end
function cruiseOn(thePlayer, speed, theCar)
theCar1 = getPedOccupiedVehicle(thePlayer)
if(theCar1) then
local x1, y1, z1 = getElementVelocity(theCar)
local speed1 = math.sqrt(x1^2 + y1^2 + z1^2) * 161
if(speed1 < speed) then
setControlState ( thePlayer, "brake_reverse", false )
setControlState ( thePlayer, "accelerate", true )
elseif(speed1 > speed) then
setControlState ( thePlayer, "accelerate", false )
setControlState ( thePlayer, "brake_reverse", true )
end
else
	cruiseOff(thePlayer)
end
end
function cruiseControl(thePlayer)
local theCar = getPedOccupiedVehicle(thePlayer)
if(theCruiseTimer == "noone-nothing") then
if(theCar) then
local x, y, z = getElementVelocity(theCar)
.sqrt(x^2 + y^2 + z^2) * 161			local speed = math			local.sqrt(x^2 + y^2 + z^ speed =2) * 161 math.sqrt(x^2 + y^2 + z^2) * 161
--its off, so turn it on
		theCruiseTimer = setTimer(cruiseOn, 50, 0, thePlayer, speed, theCar)
else
outputChatBox("Error: players don't have cruise control switches. Must be in car.", thePlayer)
end
else
	cruiseOff(thePlayer)
end
end
addCommandHandler("ct", cruiseControl)

it is a bit weird, so you may wanna remove the

setControlState ( thePlayer, "brake_reverse", true )

and anything other setControlState with "brake_reverse" in it, thats only if you dis-like the constant breaking though.

Now, when you type /ct this function should keep the car going what ever km/h speed your car is driving.

have fun :D

P.S. i don't care if anyone else has posted theirs already, so what, i posted mine too ;)

Link to comment

wth is that?

if(theCar) then
local x, y, z = getElementVelocity(theCar)
.sqrt(x^2 + y^2 + z^2) * 161         local speed = math         local.sqrt(x^2 + y^2 + z^ speed =2) * 161 math.sqrt(x^2 + y^2 + z^2) * 161
--its off, so turn it on
        theCruiseTimer = setTimer(cruiseOn, 50, 0, thePlayer, speed, theCar)
else

Link to comment
  • 10 months later...

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...