Tokio

[HELP] Why not working this bindKey function?

Recommended Posts

Client.lua:

function processLockUnlock(vehicle)
	if vehicle then
		local vehicleID = tonumber(getElementData(vehicle, "veh:id")) or -1
		local vehFaction = tonumber(getElementData(vehicle, "veh:faction")) or 0
		local vehOwner = tonumber(getElementData(vehicle, "veh:owner")) or -1
		local vehJobID = tonumber(getElementData(vehicle, "veh:jobvehID")) or -1
				local locked = isVehicleLocked(vehicle)
				local vehID = getElementModel(vehicle)
				local vehName = getVehicleRealName(vehID)
					if isPedInVehicle(localPlayer) then
						playSounds("lockin")
					else
						playSounds("lockout")
					end
				
					if locked then
						triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, false)
					else
						triggerServerEvent("vehicleLock", localPlayer,localPlayer, vehicle, true)
    end
		else
			outputChatBox("#FFFFFF Nincs kulcsod ehhez a járműhöz.", 169,139,101, true)

		end
	end

local klikkTimer = false

function setVehicleLockState()

	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)

		local interior = getElementData(localPlayer, "interior") or false

		if not interior then

			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

end

		bindKey("k", "down", setVehicleLockState)


setTimer(function()

	if not bindKey("k", "down", setVehicleLockState) then

		bindKey("k", "down", setVehicleLockState)

	end

end, 1000, 0)

Server.lua:

addEvent("vehicleLock",true)
addEventHandler("vehicleLock",getRootElement(),function(player,veh,value)
	setVehicleLocked(veh, value)
	veh:setData("veh:status", value)
end)

 

No errors / warnings in debugscript... if i press the [K] button, nothing happens... what wrong in this code? how to fix?

Share this post


Link to post

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.