Jump to content

[AJUDA]Mod trancar veiculo


Recommended Posts

Olá pessoal tenho aqui um script de Trancar veiculo porem se eu sair do veiculo e deixar ele trancado e entrar noutro veiculo e trancar ficam os dois trancados e tenho acesso para destrancar os dois, mas todos os player tambem tenhem ou seja eles podem destrancar os veiculos que eu tranquei alguem pode ajudar?   :(

Client Side

function processLockUnlock(vehicle)
local locked = isVehicleLocked(vehicle)
	if isPedInVehicle(localPlayer) then
	if locked then
	playSounds("lockin")
	triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, false)
	else
	playSounds("lockin")
	triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, true)
	end
	else
	if locked then
	playSounds("lockout")
	triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, false)
    setVehicleOverrideLights ( vehicle, 2 )
    setTimer ( setVehicleOverrideLights, 1000, 1, vehicle, 1 )
	outputChatBox ( "\n#ff8c00✘ #ffffffINFO #ff8c00✘➺ #ffffffVeiculo Destrancado!\n", 255, 165, 0, true )
	else
	playSounds("lockout")
	triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, true)
	setVehicleOverrideLights ( vehicle, 2 )
    setTimer ( setVehicleOverrideLights, 1000, 1, vehicle, 1 )
	setTimer ( setVehicleOverrideLights, 1500, 1, vehicle, 2 )
	setTimer ( setVehicleOverrideLights, 2000, 1, vehicle, 1 )
	outputChatBox ( "\n#ff8c00✘ #ffffffINFO #ff8c00✘➺ #ffffffVeiculo Trancado!\n", 255, 165, 0, true )
	end
	end
end

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,500,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 <= 10 and int2 == int and dim2 == dim then
					processLockUnlock(v)
					return
				end
			end
	end
end
bindKey("l", "down", setVehicleLockState)

 

 

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