Negriukas Posted June 23, 2014 Share Posted June 23, 2014 Hello guys, I'm new here, so i'm trying to do the following; Open the gate only for a specified team called "Army" Open the gate and close it with the same command. but i failed i have no idea what's wrong gate1 = createObject ( 980, -579.5, -189.7, 80, 0, 0, 90 ) function openMainGate(thePlayer) if getTeamName(getPlayerTeam(thePlayer)) == "Army" then if getElementPosition(gate1, -579.5, -189.7, 80 ) then moveObject (gate1, 3000, -579.5, -179.7, 80 ) else moveObject (gate1, 3000, -579.5, -189.7, 80 ) end end end addCommandHandler("main", openMainGate) Link to comment
myonlake Posted June 23, 2014 Share Posted June 23, 2014 Instead of checking a specific location you should use a variable to define when the gate is totally open and totally closed and if in the middle then either go for the closest route or cancel the action. Checking object coordinates is not always accurate as it may depend on several things. Link to comment
Negriukas Posted June 23, 2014 Author Share Posted June 23, 2014 Can you help me with code pls? i am new to this scriptin and i used some codes from https://wiki.multitheftauto.com Link to comment
Max+ Posted June 23, 2014 Share Posted June 23, 2014 (edited) gate1 = createObject ( 980, -579.5, -189.7, 80, 0, 0, 90 ) open = false addCommandHandler('main', function ( max ) if getPlayerTeam ( max ) and getPlayerTeam ( max ) == getTeamFromName ( "Army" ) then if ( open == false ) then moveObject (gate1, 3000, -579.5, -179.7, 80 ) open = true elseif ( open == true ) then moveObject (gate1, 3000, -579.5, -189.7, 80 ) open = false end end end ) Edited June 24, 2014 by Guest Link to comment
Castillo Posted June 24, 2014 Share Posted June 24, 2014 You are never updating the "open" variable, which means it'll always be 'false'. Link to comment
Max+ Posted June 24, 2014 Share Posted June 24, 2014 You are never updating the "open" variable, which means it'll always be 'false'. Fixed , 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