bosslorenz Posted January 17, 2015 Posted January 17, 2015 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.
Mizudori Posted January 17, 2015 Posted January 17, 2015 https://wiki.multitheftauto.com/wiki/SetGarageOpen
bosslorenz Posted January 17, 2015 Author Posted January 17, 2015 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 ....
Tekken Posted January 17, 2015 Posted January 17, 2015 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 )
bosslorenz Posted January 17, 2015 Author Posted January 17, 2015 Doesnt close still even with the quote "
TAPL Posted January 17, 2015 Posted January 17, 2015 That's because you attached the event onPlayerQuit to a marker, marker can quit from the server?
bosslorenz Posted January 17, 2015 Author Posted January 17, 2015 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
TAPL Posted January 17, 2015 Posted January 17, 2015 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)
bosslorenz Posted January 18, 2015 Author Posted January 18, 2015 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 : Bad argument @ `getPlayerTeam` [Expected player at argument 1, got vehicle]
bosslorenz Posted January 18, 2015 Author Posted January 18, 2015 What I mean if the other player is on vehicle that is not on team Las Venturas , it still opens the gate. I only want to open the gate when the player team Las Venturas Mafia is on vehicle. isPedonVehicle?
bosslorenz Posted January 18, 2015 Author Posted January 18, 2015 I want to check if the player on vehicle is on team Las Venturas Mafia it will open the gate..
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