Niick Posted December 22, 2019 Share Posted December 22, 2019 Achei esse mod de ligar, desligar o motor do carro, trancar e acender a luz, porem quando eu aperto a o botão "J" que é para ligar o veiculo, faz o som de ligar, Porem nao liga o veiculo, alguem pode mim ajuda? SourceC --[[ --]] local types = { ["Automobile"] = true, ["Bike"] = true, ["Plane"] = true, ["Helicopter"] = true, ["Boat"] = true, ["Train"] = true, ["Monster Truck"] = true, ["Quad"] = true } local beltVehicles = { ["Automobile"] = true, ["Plane"] = true, ["Helicopter"] = true, ["Boat"] = true, ["Train"] = true, ["Monster Truck"] = true } function playSounds(sounds, bool) if not bool then bool = false end if sounds == "ov" then beltSound = playSound("files/".. sounds ..".mp3", bool) else playSound("files/".. sounds ..".mp3", bool) end end local beltVehicles = { ["Automobile"] = true, ["Plane"] = true, ["Helicopter"] = true, ["Boat"] = true, ["Train"] = true, ["Monster Truck"] = true } addEventHandler("onClientVehicleEnter", root, function(player) if player == localPlayer and beltVehicles[getVehicleType(getPedOccupiedVehicle(localPlayer))] then setElementData(localPlayer, "veh:ov", false) end end) addEventHandler("onClientVehicleExit", root, function(player) if player == localPlayer then if isElement(beltSound) then end end end) addEventHandler("onClientKey", root, function(key, pressed) if isChatBoxInputActive() or isConsoleActive() then return end if key == "x" and pressed and getPedOccupiedVehicle(localPlayer) and beltVehicles[getVehicleType(getPedOccupiedVehicle(localPlayer))] then if not getElementData(localPlayer, "veh:ov") then setElementData(localPlayer, "veh:ov", true) playSound("files/ovbe.mp3", false) outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVocê colocou o cinto de segurança!", 255, 255, 255, true) else setElementData(localPlayer, "veh:ov", false) playSound("files/ovki.mp3", false) outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVocê tirou o cinto de segurança!", 255, 255, 255, true) end end end) addEventHandler("onClientElementDestroy", getRootElement(), function () if getElementType(source) == "vehicle" and types[getVehicleType(source)] and getVehicleType(source) ~= "Bike" then setElementData(localPlayer, "veh:ov", false) end end) addEventHandler("onClientPlayerVehicleEnter", localPlayer, function(vehicle, seat) if source == localPlayer then local engine = vehicle:getData("veh:motor") local vehicle = getPedOccupiedVehicle(localPlayer) if getVehicleType(getPedOccupiedVehicle(localPlayer)) == "BMX" then setVehicleEngineState(vehicle, true) else if not engine then setVehicleEngineState(vehicle, false) else setVehicleEngineState(vehicle, true) end end end end) addEventHandler("onClientPlayerVehicleEnter", localPlayer, function(vehicle, seat) if source == localPlayer then local engine = vehicle:getData("veh:motor") local vehicle = getPedOccupiedVehicle(localPlayer) if getVehicleType(getPedOccupiedVehicle(localPlayer)) == "BMX" then setVehicleEngineState(vehicle, true) else if not engine then setVehicleEngineState(vehicle, false) else setVehicleEngineState(vehicle, true) end end if vehicle then outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFPara ligar o veículo, pressione #1066E7J", 255, 255, 255, true) outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFColoque o cinto de segurança, pressione #1066E7X", 255, 255, 255, true) end end end) function keyHandler(button,state) --Função Ligar motor if not (not guiGetInputEnabled() and not isMTAWindowActive() and not isCursorShowing()) then return end if isPedInVehicle(localPlayer) and getPedOccupiedVehicleSeat(localPlayer) == 0 then if not types[getVehicleType(getPedOccupiedVehicle(localPlayer))] then return end local veh = getPedOccupiedVehicle(localPlayer) if button == "j" and state then if isPedInVehicle(localPlayer) and getPedOccupiedVehicleSeat(localPlayer) == 0 then local state = getVehicleEngineState ( veh ) if not state then playSounds("lightswitch") vehTimer = setTimer(kocsiindit,1000,1) playSounds("starter") else kocsiindit() end end end end end addEventHandler("onClientKey",getRootElement(),keyHandler) function kocsiindit() local veh = getPedOccupiedVehicle(localPlayer) local state = getVehicleEngineState ( veh ) if not state then m = true if getElementHealth(veh) >= 321 then --Verifica se o carro ta quebrado se sim m = true else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFParece que está com o motor fundido chame por um Mecânico /mecanicos!", 255, 255, 255, true) end if getElementData(veh, "DNL:Combustivel") > 0 then --Verifica se o veiculo ta sem gasolina se sim m = true outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo ligado!", 255, 255, 255, true) else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFO Veiculo está sem gasolina", 255, 255, 255, true) end else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo desligado!", 255, 255, 255, true) end triggerServerEvent("vehicleStart",localPlayer,localPlayer,veh,m) end function processLockUnlock(vehicle) local locked = isVehicleLocked(vehicle) if isPedInVehicle(localPlayer) then playSounds("lockin") else playSounds("lockout") end if locked then triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, false) outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo destrancado!", 255, 255, 255, true) else triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, true) outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo trancado!", 255, 255, 255, true) end end function light() --Função do farol if klikkTimer then return end if isTimer(klikkTimerRun) then return end klikkTimer = true klikkTimerRun = setTimer(function() klikkTimer = false end,1000,1) local vehicle = getPedOccupiedVehicle(localPlayer) if isPedInVehicle(localPlayer) and getVehicleController(vehicle) == localPlayer and getVehicleType(vehicle) ~= "BMX" then local vehicle = getPedOccupiedVehicle ( localPlayer ) local vehLampaStat = tonumber(vehicle:getData("veh:light")) or 0 if vehLampaStat == 0 then playSounds("lightswitch") triggerServerEvent("setVehLightState",vehicle,vehicle,2, localPlayer) vehicle:setData("veh:light",1) vehicle:setData("veh >> light",true) else triggerServerEvent("setVehLightState",vehicle,vehicle,1, localPlayer) vehicle:setData("veh:light",0) playSounds("lightswitch") vehicle:setData("veh >> light",false) end end end bindKey("l", "down", light) local klikkTimer = false function setVehicleLockState() --Função trancar o carro if klikkTimer then return end if isTimer(klikkTimerRun) then return end klikkTimer = true klikkTimerRun = setTimer(function() klikkTimer = false end,1000,1) local vehicle = getPedOccupiedVehicle ( localPlayer ) if vehicle then processLockUnlock(vehicle) else local int2 = getElementInterior(localPlayer) local dim2 = getElementDimension(localPlayer) local mx,my,mz = getElementPosition(localPlayer) for k,v in ipairs(getElementsByType("vehicle")) do local x,y,z = getElementPosition(v) local int = getElementInterior(v) local dim = getElementDimension(v) local dist = getDistanceBetweenPoints3D(x,y,z,mx,my,mz) if dist <= 3 and int2 == int and dim2 == dim then processLockUnlock(v) return end end end end bindKey("k", "down", setVehicleLockState) --[[ --]] addEvent("vehicleStart",true) addEventHandler("vehicleStart",getRootElement(),function(player,veh,value) if not isElement(veh) and not value and not isPedInVehicle(player) then return end if getElementHealth(veh) > 300 then setVehicleEngineState(veh,value) veh:setData("veh:motor",value) end end) addEvent("vehicleLock",true) addEventHandler("vehicleLock",getRootElement(),function(player,veh,value) setVehicleLocked(veh, value) veh:setData("veh:status", value) end) function vehicleStartExit(thePlayer, seat, jacked) if isVehicleLocked(getPlayerOccupiedVehicle(thePlayer)) then outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFF O seu veículo está fechado!", thePlayer, 255, 255, 255, true) cancelEvent() end if getElementData(thePlayer, "isFuelling") then cancelEvent() end end addEventHandler("onVehicleStartExit",getRootElement(),vehicleStartExit) addEvent("setVehLightState",true) addEventHandler("setVehLightState",root,function(veh,stat, playerSource) setVehicleOverrideLights(veh, stat) if playerSource then if (stat == 2) then outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFF Farol ligado!", thePlayer, 255, 255, 255, true) else outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFF Farol desligado!", thePlayer, 255, 255, 255, true) --outputChatBox("#1066E7[HiqueC - Veiculo]: #FFFFFF desligou a luz do veículo.", thePlayer, 255, 255, 255, true) end end end) -- Se o carro estiver quebrado o motor e desligado function onVehicleDamage(damage) if getElementHealth(source) - damage <= 319 then setElementHealth(source, 320) resetVehicleExplosionTime(source) setElementData(source, "veh:motor", false) setVehicleEngineState(source, false) end end addEventHandler("onVehicleDamage", root, onVehicleDamage) addEventHandler("onVehicleStartEnter", root, function(player, _, _) if source:getData("veh:status") and getVehicleType(source) == "BMX" then cancelEvent() end if isVehicleLocked(source) then outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFF O veículo está fechado!", player, 255, 255, 255, true) cancelEvent() end end) function vehicleDamage ( loss ) local vehHealth = getElementHealth ( source ) if ( vehHealth < 300 ) then setElementHealth ( source, 300 ) setVehicleDamageProof ( source, true ) end end addEventHandler ( "onVehicleDamage", root, vehicleDamage ) SourceS Link to comment
Other Languages Moderators Lord Henry Posted December 24, 2019 Other Languages Moderators Share Posted December 24, 2019 (edited) Erro na linha 162. Se o veículo não possuir data de combustível, ele para de ler a função e nada acontece. Use essa: function kocsiindit() local veh = getPedOccupiedVehicle(localPlayer) local state = getVehicleEngineState ( veh ) if not state then m = true if getElementHealth(veh) >= 321 then --Verifica se o carro ta quebrado, se não estiver: m = true else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFParece que está com o motor fundido chame por um Mecânico /mecanicos!", 255, 255, 255, true) end if (getElementData(veh, "DNL:Combustivel")) then -- Verifica se o veículo tem dados de gasolina, se tiver: if getElementData(veh, "DNL:Combustivel") > 0 then --Verifica se o veiculo ta sem gasolina, se estiver com gasolina: m = true outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo ligado!", 255, 255, 255, true) else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFO Veiculo está sem gasolina", 255, 255, 255, true) end else m = true outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFO Veiculo ligado. Este modelo não usa gasolina.", 255, 255, 255, true) end else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo desligado!", 255, 255, 255, true) end triggerServerEvent("vehicleStart",localPlayer,localPlayer,veh,m) end Edited December 24, 2019 by Lord Henry 1 Link to comment
HiqueC Posted December 25, 2019 Share Posted December 25, 2019 Eu até tinha explicado como adicionar o combustível os caras não presta atenção. 1 Link to comment
Niick Posted December 26, 2019 Author Share Posted December 26, 2019 10 hours ago, HiqueC said: Eu até tinha explicado como adicionar o combustível os caras não presta atenção. Desculpa, fiquei um tempo fora, não pude ver. On 24/12/2019 at 16:36, Lord Henry said: Erro na linha 162. Se o veículo não possuir data de combustível, ele para de ler a função e nada acontece. Use essa: function kocsiindit() local veh = getPedOccupiedVehicle(localPlayer) local state = getVehicleEngineState ( veh ) if not state then m = true if getElementHealth(veh) >= 321 then --Verifica se o carro ta quebrado, se não estiver: m = true else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFParece que está com o motor fundido chame por um Mecânico /mecanicos!", 255, 255, 255, true) end if (getElementData(veh, "DNL:Combustivel")) then -- Verifica se o veículo tem dados de gasolina, se tiver: if getElementData(veh, "DNL:Combustivel") > 0 then --Verifica se o veiculo ta sem gasolina, se estiver com gasolina: m = true outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo ligado!", 255, 255, 255, true) else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFO Veiculo está sem gasolina", 255, 255, 255, true) end else m = true outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFO Veiculo ligado. Este modelo não usa gasolina.", 255, 255, 255, true) end else m = false outputChatBox("#1066E7[BVH - Veiculo]: #FFFFFFVeiculo desligado!", 255, 255, 255, true) end triggerServerEvent("vehicleStart",localPlayer,localPlayer,veh,m)end Muito Obrigado, Funcionou Perfeitamente, Feliz Natal ♥ :). Link to comment
Other Languages Moderators Lord Henry Posted December 26, 2019 Other Languages Moderators Share Posted December 26, 2019 De nada, deixe um Thanks no comentário que lhe ajudou. 1 Link to comment
Niick Posted December 27, 2019 Author Share Posted December 27, 2019 On 26/12/2019 at 13:03, Lord Henry said: De nada, deixe um Thanks no comentário que lhe ajudou. Ok, Desculpa, as não sei mexer muito com forum, tais opções eu nao sei fazer. Link to comment
jeffersonco Posted February 25, 2020 Share Posted February 25, 2020 entao eu sou mt burro tenho esse mesmo script copiei isso e colei do msm jeito la e o script parou de funcionar Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now