Jump to content

moveObject auto close


bosslorenz

Recommended Posts

local marker1 = createMarker ( 2507.2998046875, 1603, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate1 = createObject ( 16775, 2507.400390625, 1602.7001953125, 13.7) 
  
function movingObject ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.3999023438, 1602.6999511719, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
    end 
end 
end 
addEventHandler ( "onMarkerHit", marker1 , movingObject ) 
addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) 
  
local marker2 = createMarker ( 2567.3000488281, 1483.6999511719, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate2 = createObject ( 16775, 2567.1005859375, 1484.099609375, 13.7) 
  
function movingObject2 ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack2 (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 13.7 ) 
    end 
end 
end 
addEventHandler ( "onMarkerHit", marker2 , movingObject2 ) 
addEventHandler ( "onMarkerLeave", marker2, moveObjectBack2 ) 

Someone knows how to make it auto close when hitElement is on the marker and quits... the door automatically closes?.

B`coz mine is when I`m on the marker it opens and when I quit the door stays open.

Link to comment
local marker1 = createMarker ( 2507.2998046875, 1603, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate1 = createObject ( 16775, 2507.400390625, 1602.7001953125, 13.7) 
  
function movingObject ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.3999023438, 1602.6999511719, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
    end 
end 
end 
addEventHandler ( "onMarkerHit", marker1 , movingObject ) 
addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) 
  
local marker2 = createMarker ( 2567.3000488281, 1483.6999511719, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate2 = createObject ( 16775, 2567.1005859375, 1484.099609375, 13.7) 
  
function movingObject2 ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack2 (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 13.7 ) 
    end 
end 
end 
addEventHandler ( "onMarkerHit", marker2 , movingObject2 ) 
addEventHandler ( "onMarkerLeave", marker2, moveObjectBack2 ) 
  
function moveObjectBack3 (leaveElement, matchingDimension) 
    local gPT = getPlayerTeam ( leaveElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( leaveElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
    end 
end 
end 
  
addEventHandler ("onPlayerQuit, marker1,  
function () 
    moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
end 
) 
 

Still doesnt close when player quits ....

Link to comment
local marker1 = createMarker ( 2507.2998046875, 1603, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate1 = createObject ( 16775, 2507.400390625, 1602.7001953125, 13.7) 
  
function movingObject ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.3999023438, 1602.6999511719, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
    end 
end 
end 
addEventHandler ( "onMarkerHit", marker1 , movingObject ) 
addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) 
  
local marker2 = createMarker ( 2567.3000488281, 1483.6999511719, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate2 = createObject ( 16775, 2567.1005859375, 1484.099609375, 13.7) 
  
function movingObject2 ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack2 (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 13.7 ) 
    end 
end 
end 
addEventHandler ( "onMarkerHit", marker2 , movingObject2 ) 
addEventHandler ( "onMarkerLeave", marker2, moveObjectBack2 ) 
  
function moveObjectBack3 (leaveElement, matchingDimension) 
    local gPT = getPlayerTeam ( leaveElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="LV" then 
    if getElementType ( leaveElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
    end 
end 
end 
  
addEventHandler ("onPlayerQuit", marker1, --Here you forgot to put the quote 
function () 
    moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
end 
) 
  

Link to comment
function playerQuit () 
    if ( isElementWithinMarker ( source, marker1 ) ) then 
    moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
end 
end 
addEventHandler ("onPlayerQuit", root, playerQuit ) 
  
function playerQuit2 () 
    if ( isElementWithinMarker ( source, marker2 ) ) then 
    moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 13.7 ) 
end 
end 
addEventHandler ("onPlayerQuit", root, playerQuit2 ) 

Thanks for your helps.. I already solved it :)

Link to comment

Actually one function and one event is enough, the same apply to the rest of your code.

function playerQuit() 
    if isElementWithinMarker(source, marker1) then 
        moveObject(gate1, 3000, 2507.400390625, 1602.7001953125, 13.7) 
    end 
    if isElementWithinMarker(source, marker2) then 
        moveObject(gate2, 3000, 2567.1005859375, 1484.099609375, 13.7) 
    end 
end 
addEventHandler("onPlayerQuit", root, playerQuit) 

Link to comment
local marker1 = createMarker ( 2507.2998046875, 1603, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate1 = createObject ( 16775, 2507.400390625, 1602.7001953125, 13.7) 
  
function movingObject ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="Las Venturas Mafia" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.3999023438, 1602.6999511719, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="Las Venturas Mafia" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
    end 
end 
end 
addEventHandler ( "onMarkerHit", marker1 , movingObject ) 
addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) 
  
local marker2 = createMarker ( 2567.3000488281, 1483.6999511719, 9.6000003814697, 'cylinder', 6, 0, 255, 0, 0) 
local gate2 = createObject ( 16775, 2567.1005859375, 1484.099609375, 13.7) 
  
function movingObject2 ( hitElement, matchingDimension ) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="Las Venturas Mafia" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 5.7 ) 
    end 
end 
end 
  
function moveObjectBack2 (hitElement, matchingDimension) 
    local gPT = getPlayerTeam ( hitElement ) 
    local gTN = ( gPT and getTeamName ( gPT ) or "" ) 
    if gTN =="Las Venturas Mafia" then 
    if getElementType ( hitElement ) == "player" then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 13.7 ) 
    end 
end 
end 
  
addEventHandler ( "onMarkerHit", marker2 , movingObject2 ) 
addEventHandler ( "onMarkerLeave", marker2, moveObjectBack2 ) 
  
function playerQuit () 
    if isElementWithinMarker ( source, marker1 ) then 
        moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) 
    end 
    if isElementWithinMarker ( source, marker2 ) then 
        moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 13.7 ) 
    end 
end 
addEventHandler ("onPlayerQuit", root, playerQuit ) 
     
  

Got error : :5: Bad argument @ `getPlayerTeam` [Expected player at argument 1, got vehicle]

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