Jump to content

Engine Switch


TorNix~|nR

Recommended Posts

Hello guys, I have a little problem, I don't know from where it come, the engine switch on the vehicle system was working so fine! but suddenly it won't work anymore

I don't know why, I tried so many different codes, but it's the same

function engineSwitch ()
  if (isPedInVehicle (source)) then
    local veh = getPedOccupiedVehicle (source)
    if (getVehicleEngineState (veh) == true) then
      setVehicleEngineState (veh, false)
        outputChatBox ("Successfully closed vehicle.", source, r, g, b, true)
    elseif (getVehicleEngineState (veh) == false) then
      setVehicleEngineState (veh, true)
        outputChatBox ("Successfully open vehicle.", source, r, g, b, true)
      else
        outputChatBox ("This is not your vehicle.", source, r, g, b, true)
      end
    end
end
addEvent("engenieSwitch",true)
addEventHandler("engenieSwitch",getRootElement(),engineSwitch)

any help please?

Link to comment
46 minutes ago, TorNix~|nR said:

Hello guys, I have a little problem, I don't know from where it come, the engine switch on the vehicle system was working so fine! but suddenly it won't work anymore

I don't know why, I tried so many different codes, but it's the same


function engineSwitch ()
  if (isPedInVehicle (source)) then
    local veh = getPedOccupiedVehicle (source)
    if (getVehicleEngineState (veh) == true) then
      setVehicleEngineState (veh, false)
        outputChatBox ("Successfully closed vehicle.", source, r, g, b, true)
    elseif (getVehicleEngineState (veh) == false) then
      setVehicleEngineState (veh, true)
        outputChatBox ("Successfully open vehicle.", source, r, g, b, true)
      else
        outputChatBox ("This is not your vehicle.", source, r, g, b, true)
      end
    end
end
addEvent("engenieSwitch",true)
addEventHandler("engenieSwitch",getRootElement(),engineSwitch)

any help please?

function engineSwitch()
    if isPedInVehicle(source) then
        local veh, engine = getPedOccupiedVehicle(source), getVehicleEngineState(veh)
        setVehicleEngineState(veh, not engine)
		outputChatBox(engine and "you've successfully turn the engine off" or "engine turned on successfully", source, 255, 255, 255, true)
    end
end
addEvent("engenieSwitch", true)
addEventHandler("engenieSwitch", getRootElement(), engineSwitch)

try this, by the way your code is fine but did you define (r, g, b) ?

Edited by #َxLysandeR
Link to comment
  • 5 months later...

I'm sorry I didn't see the reply, even the problem is still on xd :(

I tested this code on local and it's working, but when I test it on my server it won't work, only the engine, help please

addEvent("engenieSwitch", true)
addEventHandler("engenieSwitch", root, 
function(id)
	local vehicle = getVehicleByID(id)
	if isElement(vehicle) then
	    if (getVehicleEngineState (vehicle) == true) then
      setVehicleEngineState (vehicle, false)
	  setVehicleOverrideLights(vehicle, 1)
    elseif (getVehicleEngineState (vehicle) == false) then
      setVehicleEngineState (vehicle, true)
	  setVehicleOverrideLights(vehicle, 2)
      else
		end
	end
end)

 

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