Master_11 Posted March 3, 2017 Share Posted March 3, 2017 (edited) path = createMarker ( 0,0,-50, "arrow", 1.3, 0, 60, 255 ) path1 = createMarker ( 0,0,-50, "arrow", 1.3, 0, 60, 255 ) path2 = createMarker ( 0,0,-50, "arrow", 1.3, 0, 60, 255 ) function pathMarker ( thePlayer, command ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then x, y, z = getElementPosition ( thePlayer ) setElementPosition ( path, x, y-2, z+1 ) setElementDimension ( path, 336 ) setElementInterior ( path, 0 ) outputChatBox ( "Path Marker Created", thePlayer, 60, 255, 60, true ) else outputChatBox ( "Error", thePlayer, 200, 10, 10, true ) end end addCommandHandler ("pmr", pathMarker) function pathMarkerA ( thePlayer, command ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then x, y, z = getElementPosition ( thePlayer ) setElementPosition ( path1, x, y-2, z+1 ) setElementDimension ( path1, 336 ) setElementInterior ( path1, 0 ) outputChatBox ( "Path Marker Created", thePlayer, 60, 255, 60, true ) else outputChatBox ( "Error", thePlayer, 200, 10, 10, true ) end end addCommandHandler ("pmr1", pathMarkerA) function pathMarkerB ( thePlayer, command ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then x, y, z = getElementPosition ( thePlayer ) setElementPosition ( path2, x, y-2, z+1 ) setElementDimension ( path2, 336 ) setElementInterior ( path2, 0 ) outputChatBox ( "Path Marker Created", thePlayer, 60, 255, 60, true ) else outputChatBox ( "Error", thePlayer, 200, 10, 10, true ) end end addCommandHandler ("pmr2", pathMarkerB) Can anyone help me making this code in a table, I want to make the script loop instead of using multiple functions is it possible to make it only on 1 function. for example: Using the command "pmr" to create multiple markers not only 1 marker, Same goes with the other two markers. Edited March 3, 2017 by Master_11 Link to comment
3aGl3 Posted March 3, 2017 Share Posted March 3, 2017 I assume this is what you want, it'll create a new marker each time you use the pmr command. local pathMarkers = {} function pathMarker( thePlayer ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then x, y, z = getElementPosition ( thePlayer ) local path = createMarker ( x, y-2, z+1, "arrow", 1.3, 0, 60, 255 ) setElementDimension ( path, 336 ) setElementInterior ( path, 0 ) pathMarkers[#pathMarkers+1] = path outputChatBox ( "Path Marker Created", thePlayer, 60, 255, 60, true ) else outputChatBox ( "Error", thePlayer, 200, 10, 10, true ) end end addCommandHandler( "pmr", pathMarker ) Link to comment
Master_11 Posted March 3, 2017 Author Share Posted March 3, 2017 Thanks, your code is working fine but, can you make it so when the player hit the marker, the player will be teleported to the given x y z by the command like /pmr x y z > Where x y z are the coordinates where the player will be teleported. Also, a command to delete all the markers together and also delete them 1 by 1 local pathMarkers = {} function pathMarker( thePlayer ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then x, y, z = getElementPosition ( thePlayer ) local path = createMarker ( x, y-2, z+1, "arrow", 1.3, 0, 60, 255 ) setElementDimension ( path, 336 ) setElementInterior ( path, 0 ) pathMarkers[#pathMarkers+1] = path outputChatBox ( "Path Marker Created", thePlayer, 60, 255, 60, true ) else outputChatBox ( "Error", thePlayer, 200, 10, 10, true ) end end addCommandHandler( "pmr", pathMarker ) -------------------------------------------------------------------- function setArna ( thePlayer ) if (getElementDimension (thePlayer) ~= 336) then return false end x, y, z = getElementPosition(path) setElementPosition ( thePlayer, x+80, y-20, z+100 ) end addEventHandler ("onMarkerHit", path, setArna) function setArnaA ( thePlayer ) if (getElementDimension (thePlayer) ~= 336) then return false end x, y, z = getElementPosition(path) setElementPosition ( thePlayer, x-200, y, z+1 ) end addEventHandler ("onMarkerHit", path1, setArnaA) function setArnaB ( thePlayer ) if (getElementDimension (thePlayer) ~= 336) then return false end x, y, z = getElementPosition(path) setElementPosition ( thePlayer, x-90, y-90, z+100 ) end addEventHandler ("onMarkerHit", path2, setArnaB) ---------------------------------------------------------------------------------- function delMarkerall ( thePlayer, command ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then setElementPosition (path, 0,0,-50) setElementPosition (path1, 0,0,-50) setElementPosition (path2, 0,0,-50) outputChatBox ( "Markers deleted", thePlayer, 10, 255, 255, true ) else outputChatBox ( "WTF are you up to?", thePlayer, 10, 255, 255, true ) end end addCommandHandler("dallpmr", delMarkerall) function delpmr ( thePlayer, command ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then setElementPosition (path, 0,0,-50) outputChatBox ( "Path marker '1' deleted", thePlayer, 10, 255, 255, true ) else outputChatBox ( "WTF are you up to?", thePlayer, 10, 255, 255, true ) end end addCommandHandler("delpmr", delpmr) function delpmrA ( thePlayer, command ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then setElementPosition (path1, 0,0,-50) outputChatBox ( "Path marker '2' deleted", thePlayer, 10, 255, 255, true ) else outputChatBox ( "WTF are you up to?", thePlayer, 10, 255, 255, true ) end end addCommandHandler("delpmr1", delpmrA) function delpmrB ( thePlayer, command ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then setElementPosition (path2, 0,0,-50) outputChatBox ( "Path marker '3' deleted", thePlayer, 10, 255, 255, true ) else outputChatBox ( "WTF are you up to?", thePlayer, 10, 255, 255, true ) end end addCommandHandler("delpmr2", delpmrB) Here is the full code! 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