itHyperoX Posted May 31, 2018 Share Posted May 31, 2018 Hi, in the table there is an outside positons (x y z, dim, int) and inside pos's (inx y, z, dim, int). But when player hit the second marker , nothing happen, but when player hit the first marker it's work. local Markers = { -- outX, outY, outZ, outInt, outDim, inX, inY, inZ, inInt, inDim {1852.8375244141, -1752.1379394531, 13.3828125, 0, 0, 1839.7073974609, -1745.7852783203, 13.546875, 0, 0}, {1825.2690429688, -1758.576171875, 13.3828125, 0, 0, 1815.5324707031, -1769.6801757813, 13.546875, 0, 0}, } addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() for k, v in pairs(Markers) do local outX, outY, outZ, outDim, outInt, inX, inY, inZ, inDim, inInt = v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10] insideMarker = createMarker(inX, inY, inZ, "cylinder", 1, 0, 255, 0, 180) outsideMarker = createMarker(outX, outY, outZ, "cylinder", 1, 255, 0, 0, 150) end addEventHandler( "onMarkerHit", outsideMarker, function ( hitElement, matchingDimension ) setElementPosition(hitElement, inX, inY, inZ) end) addEventHandler( "onMarkerHit", insideMarker, function ( hitElement, matchingDimension ) setElementPosition(hitElement, outX, outY + 3, outZ) end) end) Link to comment
_Evo_ Posted May 31, 2018 Share Posted May 31, 2018 well, this is for what? for detect an marker when hit player? Link to comment
itHyperoX Posted May 31, 2018 Author Share Posted May 31, 2018 So this is something for teleporting from one position to another. The problem is the second marker doesn't do anything for some reason. local Markers = { -- outX, outY, outZ, outInt, outDim, inX, inY, inZ, inInt, inDim {--[[ From here the inside marker]] 1852.8375244141, -1752.1379394531, 13.3828125, 0, 0, --[[ From here the outside marker]] 1839.7073974609, -1745.7852783203, 13.546875, 0, 0}, -- Marker 1 [IN / OUT] {--[[ From here the inside marker]] 1825.2690429688, -1758.576171875, 13.3828125, 0, 0, --[[ From here the outside marker]] 1815.5324707031, -1769.6801757813, 13.546875, 0, 0}, -- Marker 2 [IN / OUT] } Link to comment
DNL291 Posted May 31, 2018 Share Posted May 31, 2018 (edited) Because the variable will be assigned to only one marker. An easy solution is storing the markers in a table: local teleportMarkers = {} teleportMarkers[k] = { createMarker(inX, inY, inZ, "cylinder", 1, 0, 255, 0, 180), -- inside createMarker(outX, outY, outZ, "cylinder", 1, 255, 0, 0, 150) -- outside } addEventHandler( "onMarkerHit", teleportMarkers[k][1], function ( hitElement, matchingDimension ) setElementPosition(hitElement, outX, outY + 3, outZ) end) addEventHandler( "onMarkerHit", teleportMarkers[k][2], function ( hitElement, matchingDimension ) setElementPosition(hitElement, inX, inY, inZ) end) -- * everything except the table inside the loop * -- Edited May 31, 2018 by DNL291 1 Link to comment
itHyperoX Posted June 1, 2018 Author Share Posted June 1, 2018 Thank you, one more question. How can i make that, when the player came out of the interior, it's spawning inside the marker, and the marker instead teleporting back the player.. Any idea? addEventHandler( "onMarkerHit", teleportMarkers[k][1], function ( hitElement, matchingDimension ) setElementPosition(hitElement, outX, outY + 2, outZ) setElementDimension(hitElement, v[4]) setElementInterior(hitElement, v[5]) end) addEventHandler( "onMarkerHit", teleportMarkers[k][2], function ( hitElement, matchingDimension ) setElementPosition(hitElement, inX, inY + 2, inZ) setElementDimension(hitElement, v[9]) setElementInterior(hitElement, v[10]) end) Link to comment
DNL291 Posted June 1, 2018 Share Posted June 1, 2018 Add to the table the player coordinates of entrance/exit: local Markers = { -- outX, outY, outZ, outInt, outDim, inX, inY, inZ, inInt, inDim {1852.8375244141, -1752.1379394531, 13.3828125, 0, 0, 1839.7073974609, -1745.7852783203, 13.546875, 0, 0, entrancePos = { x, y, z, rot }, exitPos = { x, y, z, rot } }, {1825.2690429688, -1758.576171875, 13.3828125, 0, 0, 1815.5324707031, -1769.6801757813, 13.546875, 0, 0 entrancePos = { x, y, z, rot }, exitPos = { x, y, z, rot } } } local teleportMarkers = {} addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function() for k, v in pairs(Markers) do local outX, outY, outZ, outDim, outInt, inX, inY, inZ, inDim, inInt = v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10] teleportMarkers[k] = { createMarker(inX, inY, inZ, "cylinder", 1, 0, 255, 0, 180), -- inside createMarker(outX, outY, outZ, "cylinder", 1, 255, 0, 0, 150) -- outside } setElementInterior( teleportMarkers[k][1], inDim ) setElementPosition( teleportMarkers[k][1], inInt ) addEventHandler( "onMarkerHit", teleportMarkers[k][2], function ( hitElement, matchingDimension ) if getElementType(hitElement) == "player" and matchingDimension then local px,py,pz,rot = unpack( Markers[k].entrancePos ) setElementPosition( hitElement, px, py, pz+1 ) setElementRotation( hitElement, 0, 0, rot ) setElementDimension( hitElement, Markers[k][10] ) setElementInterior( hitElement, Markers[k][9] ) end end) addEventHandler( "onMarkerHit", teleportMarkers[k][1], function ( hitElement, matchingDimension ) if getElementType(hitElement) == "player" and matchingDimension then local px,py,pz,rot = unpack( Markers[k].exitPos ) setElementPosition( hitElement, px, py, pz+1 ) setElementRotation( hitElement, 0, 0, rot ) setElementDimension( hitElement, Markers[k][5] ) setElementInterior( hitElement, Markers[k][4] ) end end) end) 1 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