Jump to content

Moving gates with team or clan


Recommended Posts

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

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

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