Jump to content

Help please


Recommended Posts

Posted (edited)

How do I fix this? https://youtu.be/UjKePNof-6A

 

Code (server):

parkgate1 = createObject( 968, 2777.123, 905.84, 10.666, 0, 90, 90 )
parkgate2 = createObject( 968, 2777.127, 920.71, 10.62, 0, -90, 90 )
gatebar1 = createObject( 966, 2777.127, 920.71, 9.7, 0, 0, 90 )
gatebar2 = createObject( 966, 2777.123, 905.84, 9.7, 0, 0, -90 )
parkmarker = createMarker(2777, 912.994, 7.75, "cylinder", 13, 255, 0, 0, 0 )
local isMoving = false
function gatefunc( hitPlayer )
    if isMoving == false then
        isMoving = true
        moveObject ( parkgate1, 2000,  2777.123, 905.84, 10.666, 0, -90, 0)
		moveObject ( parkgate2, 2000,  2777.127, 920.71, 10.62, 0, 90, 0)
    end
end
addEventHandler( "onMarkerHit", parkmarker, gatefunc )
function gatefuncclose( )
    moveObject ( parkgate1, 2000, 2777.123, 905.84, 10.666, 0, 90, 0)
	moveObject ( parkgate2, 2000,  2777.127, 920.71, 10.62, 0, -90, 0)
setTimer(function()
        isMoving = false
		end,2000,1)
end
addEventHandler( "onMarkerLeave", parkmarker, gatefuncclose )
Edited by Egor_Varaksa
  • Other Languages Moderators
Posted

The same way you did the first function, you should do in the second one. In this case, check if the isMoving is true.

Posted
18 minutes ago, andr0xy said:

The same way you did the first function, you should do in the second one. In this case, check if the isMoving is true.

It didn't help. Maybe you can somehow make the object not rotate more than 90 degrees?

 

  • Other Languages Moderators
Posted

Tested:

Spoiler

parkgate1 = createObject( 968, 2777.123, 905.84, 10.666, 0, 90, 90 )
parkgate2 = createObject( 968, 2777.127, 920.71, 10.62, 0, -90, 90 )
gatebar1 = createObject( 966, 2777.127, 920.71, 9.7, 0, 0, 90 )
gatebar2 = createObject( 966, 2777.123, 905.84, 9.7, 0, 0, -90 )
parkmarker = createMarker(2777, 912.994, 7.75, "cylinder", 13, 255, 0, 0, 0 )

local isMoving = false

function gatefunc( hitPlayer )
    if isMoving == false then
        moveObject ( parkgate1, 2000, 2777.123, 905.84, 10.666, 0, -90, 0)
		moveObject ( parkgate2, 2000, 2777.127, 920.71, 10.62, 0, 90, 0)
        setTimer(function()
            isMoving = true
        end, 2000, 1)
    end
end
addEventHandler( "onMarkerHit", parkmarker, gatefunc )

function gatefuncclose( )
    if isMoving then
        moveObject ( parkgate1, 2000, 2777.123, 905.84, 10.666, 0, 90, 0)
        moveObject ( parkgate2, 2000, 2777.127, 920.71, 10.62, 0, -90, 0)
        setTimer(function()
            isMoving = false
        end, 2000, 1)
    end
end
addEventHandler( "onMarkerLeave", parkmarker, gatefuncclose )

 

I made a mistake by telling you to make the second function like the first one, actually it was first one like the second one, but adding a checker for isMoving variable. My bad ?

Posted
4 minutes ago, andr0xy said:

Tested:

  Hide contents


parkgate1 = createObject( 968, 2777.123, 905.84, 10.666, 0, 90, 90 )
parkgate2 = createObject( 968, 2777.127, 920.71, 10.62, 0, -90, 90 )
gatebar1 = createObject( 966, 2777.127, 920.71, 9.7, 0, 0, 90 )
gatebar2 = createObject( 966, 2777.123, 905.84, 9.7, 0, 0, -90 )
parkmarker = createMarker(2777, 912.994, 7.75, "cylinder", 13, 255, 0, 0, 0 )

local isMoving = false

function gatefunc( hitPlayer )
    if isMoving == false then
        moveObject ( parkgate1, 2000, 2777.123, 905.84, 10.666, 0, -90, 0)
		moveObject ( parkgate2, 2000, 2777.127, 920.71, 10.62, 0, 90, 0)
        setTimer(function()
            isMoving = true
        end, 2000, 1)
    end
end
addEventHandler( "onMarkerHit", parkmarker, gatefunc )

function gatefuncclose( )
    if isMoving then
        moveObject ( parkgate1, 2000, 2777.123, 905.84, 10.666, 0, 90, 0)
        moveObject ( parkgate2, 2000, 2777.127, 920.71, 10.62, 0, -90, 0)
        setTimer(function()
            isMoving = false
        end, 2000, 1)
    end
end
addEventHandler( "onMarkerLeave", parkmarker, gatefuncclose )

 

I made a mistake by telling you to make the second function like the first one, actually it was first one like the second one, but adding a checker for isMoving variable. My bad ?

Thanks, but now if you quickly pass the marker the barrier will remain open

  • Other Languages Moderators
Posted

Yes, I could notice that too. That's weird, because the x, y and z axis don't seem to have this behaviour, it's just the rotation. Dunno what you should do to solve it, without some workaround.

  • Like 1

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