Jump to content

need a hand with gate script


Greenie0101

Recommended Posts

Posted

im trying to make a script where if someone on the LV team enters a colrectangle the gate door opens

LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgate(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == LV then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgate ) 

no idea what im doing wrong

Posted

try this

LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
     
    function LVgate() 
        local LVTeam = getPlayerTeam( source ) 
            if LVTeam == LV then 
                moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
            end 
    end 
addEventHandler("onColShapeHit", LVsensor, LVgate ) 

Posted
try this
LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
     
    function LVgate() 
        local LVTeam = getPlayerTeam( source ) 
            if LVTeam == LV then 
                moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
            end 
    end 
addEventHandler("onColShapeHit", LVsensor, LVgate ) 

badPlayerPointer @ getPlayerTeam

Guest Guest4401
Posted
im trying to make a script where if someone on the LV team enters a colrectangle the gate door opens
LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgate(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == LV then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgate ) 

no idea what im doing wrong

Is LV (in line 6) a team element? I don't see it defined anywhere.

Posted
im trying to make a script where if someone on the LV team enters a colrectangle the gate door opens
LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgate(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == LV then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgate ) 

no idea what im doing wrong

Is LV (in line 6) a team element? I don't see it defined anywhere.

its part of a gamemode with a team called LV

Guest Guest4401
Posted
LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgate(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == getTeamFromName("LV") then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgate ) 

Posted
LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgate(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == getTeamFromName("LV") then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgate ) 

LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgate(theColShape) 
 if theColShape == LVsensor then    
    if getElementType(source) == "player" then -- To avoid bugs, you aren't able to get a teamname from a vehicle. 
    local LVTeam = getPlayerTeam(source) 
    if ( LVTeam ) then -- Checks if player have a team 
    if LVTeam == getTeamFromName('LV') then -- Check if teamname is LV 
         
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgate ) 

Posted
im trying to make a script where if someone on the LV team enters a colrectangle the gate door opens
LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgate(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == LV then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgate ) 

no idea what im doing wrong

Is LV (in line 6) a team element? I don't see it defined anywhere.

this one works thanks mate however im having one small issue.

LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgateOpen(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == getTeamFromName("LV") then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
            moveObject(LVgateR, 2000, 2497.3999023438, 2787, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgateOpen ) 
  
function LVgateClose(theColShape) 
    if theColShape == LVsensor then 
        if getPlayerTeam(source) == getTeamFromName("LV") then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2769.1999511719, 11.5) 
            moveObject(LVgateR, 2000, 2497.3999023438, 2777.1000976563, 11.5) 
        end 
    end 
end 
addEventHandler( "onElementColShapeLeave", getRootElement(), LVgateClose ) 

that is the script now but the gate opens for all teams, not just the LV one

Posted

Did you try albers14's code?

LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgateOpen(theColShape) 
 if theColShape == LVsensor then 
    if getElementType(source) == "player" then 
    local LVTeam = getPlayerTeam(source) 
    if ( LVTeam ) then 
    if LVTeam == getTeamFromName('LV') then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
            moveObject(LVgateR, 2000, 2497.3999023438, 2787, 11.5) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgateOpen ) 
  
function LVgateClose(theColShape) 
    if theColShape == LVsensor then 
        if getElementType(source) == "player" then 
        local LVTeam = getPlayerTeam(source) 
            if ( LVTeam ) then 
                if LVTeam == getTeamFromName('LV') then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2769.1999511719, 11.5) 
            moveObject(LVgateR, 2000, 2497.3999023438, 2777.1000976563, 11.5) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onElementColShapeLeave", getRootElement(), LVgateClose ) 

Posted
Did you try albers14's code?
LVgateL = createObject ( 986, 2497.3999023438, 2769.1999511719, 11.5, 0, 0, 90 ) 
LVgateR = createObject ( 985, 2497.3999023438, 2777.1000976563, 11.5, 0, 0, 90 ) 
LVsensor = createColRectangle(2471.5, 2763.2, 50, 20) 
function LVgateOpen(theColShape) 
 if theColShape == LVsensor then 
    if getElementType(source) == "player" then 
    local LVTeam = getPlayerTeam(source) 
    if ( LVTeam ) then 
    if LVTeam == getTeamFromName('LV') then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2760, 11.5) 
            moveObject(LVgateR, 2000, 2497.3999023438, 2787, 11.5) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), LVgateOpen ) 
  
function LVgateClose(theColShape) 
    if theColShape == LVsensor then 
        if getElementType(source) == "player" then 
        local LVTeam = getPlayerTeam(source) 
            if ( LVTeam ) then 
                if LVTeam == getTeamFromName('LV') then 
            moveObject(LVgateL, 2000, 2497.3999023438, 2769.1999511719, 11.5) 
            moveObject(LVgateR, 2000, 2497.3999023438, 2777.1000976563, 11.5) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onElementColShapeLeave", getRootElement(), LVgateClose ) 

yes it didn't work. The only wrong thing is that it opens for all teams not just LV

Posted

my bad, the team was actually called Las Venturas and thats why it wouldn't open. got it working tho. Thanks for all you're help! I'll make a video tutorial on how to make a gate soon for people who dont want to go through this process

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