Jump to content

[HELP] Gate System PROBLEM


Booms

Recommended Posts

local gate = createObject (10558, 1588.6999511719, -1638.5, 14.39999961853, 0, 0, 270);

function handleGate(player)
    gX, gY, gZ = getElementPosition(gate);
    if ( (gX >= 1588.6999511719) and (gY >= -1638.5) and (gZ >= 14.39999961853) ) then -- HA a kapu csukva van
        moveObject(gate, 5000, 1588.6999511719, -1638.5, 10, 0, 0, 0);
    elseif    ( (gX >= 1588.6999511718) and (gY >= -1638.5) and (gZ <= 10.00002) ) then
        moveObject(gate, 5000, 1588.6999511719, -1638.5, 14.39999961853, 0, 0, 0);
    end    
end
addCommandHandler("gate", handleGate, false, false);

 

Link to comment

The if checks are unnecessarily complicated. All you need to test for is z position.

if (gZ >= 14.39999961853) then -- if it's up at or above Z=14.4
  moveObject(gate, 5000, 1588.6999511719, -1638.5, 10, 0, 0, 0) -- move it down to z=10
elseif (gZ <= 10) then -- if it's down at or below Z=10
  moveObject(gate, 5000, 1588.6999511719, -1638.5, 14.39999961853, 0, 0, 0) -- move it to Z=14.4
end

 

Edited by MrTasty
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...