bosslorenz Posted March 28, 2015 Share Posted March 28, 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 ) This is my problem. When I step into marker it doesnt have error. But when Im in a vehicle it gives me this error. *LVgate.lua:15: Bad argument @ `getPlayerTeam` [Expected player at argument 1, got vehicle] Link to comment
Enargy, Posted March 28, 2015 Share Posted March 28, 2015 try; #15 if getElementType ( hitElement ) == "player" or getElementType ( hitElement ) == "vehicle" then Link to comment
xXMADEXx Posted March 28, 2015 Share Posted March 28, 2015 try; #15 if getElementType ( hitElement ) == "player" or getElementType ( hitElement ) == "vehicle" then This would still allow the script to get the team of a vehicle.. It should be something like this, at the beginning of the movingObject function. if ( getElementType ( hitElement ) == "vehicle" ) then hitElement = getVehicleController ( hitElement ); if ( not hitElement ) then return false; end end Link to comment
bosslorenz Posted March 28, 2015 Author Share Posted March 28, 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 ) if ( getElementType ( hitElement ) == "vehicle" ) then hitElement = getVehicleController ( hitElement ); if ( not hitElement ) then return false; end end 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) if ( getElementType ( hitElement ) == "vehicle" ) then hitElement = getVehicleController ( hitElement ); if ( not hitElement ) then return false; end end 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 ) if ( getElementType ( hitElement ) == "vehicle" ) then hitElement = getVehicleController ( hitElement ); if ( not hitElement ) then return false; end end 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) if ( getElementType ( hitElement ) == "vehicle" ) then hitElement = getVehicleController ( hitElement ); if ( not hitElement ) then return false; end end 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 ( hitElement, marker1 ) then moveObject ( gate1, 3000, 2507.400390625, 1602.7001953125, 13.7 ) end if isElementWithinMarker ( hitElement, marker2 ) then moveObject ( gate2, 3000, 2567.1005859375, 1484.099609375, 13.7 ) end end addEventHandler ("onPlayerQuit", root, playerQuit ) 78: Bad argument @ `isElementWithinMarker` [Expected element at argument 1, got nil] 82: Bad argument @ `isElementWithinMarker` [Expected element at argument 1, got nil] Link to comment
roaddog Posted March 28, 2015 Share Posted March 28, 2015 function playerQuit () if isElement(source) then 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 end addEventHandler ("onPlayerQuit", root, playerQuit ) Link to comment
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