iron015 Posted October 25, 2015 Share Posted October 25, 2015 Добрый день, у меня функция getNearestVehicle иногда работает неправильно, пишет, что машина открыта, однако она остаётся закрытой. function getNearestVehicle( player ) x, y, z = getElementPosition( player ) for i, v in ipairs( getElementsByType( "vehicle" ) ) do if(getElementData (v, "owner" ) == getAccountName( getPlayerAccount( player ) ) ) then distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ) if distance <= ( prevDistance or distance + 1 ) then prevDistance = distance nearestVehicle = v end end end return nearestVehicle or false end function switchLock ( player ) veh = getNearestVehicle(player) if veh then locked = isVehicleLocked(veh) if locked then setVehicleLocked ( veh, false ) outputChatBox("Вы открыли ближайшую машину!", player, 243,149,72 ) setElementData (veh,"lock", 0) saveCars() else setVehicleLocked ( veh, true ) outputChatBox("Вы закрыли ближайшую машину!", player, 243,149,72 ) setElementData (veh,"lock", 1) saveCars() end end end addEvent( "switchLock", true ) addEventHandler( "switchLock", resourceRoot, switchLock ) 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