Jump to content

Cruise control script?


Recommended Posts

  • 2 weeks later...
Posted

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:

  • 1 month later...
Posted

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 ;)

Posted

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

Posted

if you mean

.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

that, i am guessing its math :P

as long as it works...

it just gets the speed in KMH

  • 10 months later...
Posted

Can someone help me?

I copied the script into a text file and called it cruisecontrol.lua, created a meta.xml but it doesnt work.

What button do i use to start the cruisecontrol? Isnt it working properly?

Posted

The problem that I pointed out is still there..

he's doing

.sqrt(blah) local variable = math.

which is really weird, as it should be

local variable = math.sqrt(blah)

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