Pierce Posted November 24, 2013 Share Posted November 24, 2013 hi i dont know a single thing about lua i just copy lines from wiki and i want to ask does this work(i think not) please help me fix bug(i am very noob at lua like a baby who just learned to say first word) function marker() local myMarker = createMarker(-2596.625, 579.358, 15.626, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) outputChatBox( elementType.." test", getRootElement(), 255, 255, 0 ) -- i dont know if this correct fadeCamera(player, true, 0.5) setTimer ( fadeCameraDelayed, 500, 1, source ) --i think this wrong too end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) Link to comment
glowdemon1 Posted November 24, 2013 Share Posted November 24, 2013 local myMarker = createMarker(-2596.625, 579.358, 15.626, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) outputChatBox( elementType.." test", hitElement, 255, 255, 0 ) -- Change this to hitElement so it outputs for hitElement fadeCamera(player, true, 0.5) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) The timer and function above myMarker was incorrect. IT looks good like this, didn't test yet. Link to comment
Pierce Posted November 24, 2013 Author Share Posted November 24, 2013 local myMarker = createMarker(-2596.625, 579.358, 15.626, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) outputChatBox( elementType.." test", hitElement, 255, 255, 0 ) -- Change this to hitElement so it outputs for hitElement fadeCamera(player, true, 0.5) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) The timer and function above myMarker was incorrect. IT looks good like this, didn't test yet. It outputs "test" but however, it doesn't fade my camera. in console it says bad argument 'fadeCamera' Link to comment
glowdemon1 Posted November 24, 2013 Share Posted November 24, 2013 Change player to hitElement at line 7, however if you hit the marker with a vehicle for instance, it will try and fade the vehicle's camera. You'll need to check what hit the element and so on. Link to comment
Blaawee Posted November 24, 2013 Share Posted November 24, 2013 local myMarker = createMarker(-2596.625, 579.358, 15.626, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) if hitElement and getElementType( hitElement ) == 'player' then fadeCamera( hitElement, true, 0.5 ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) Link to comment
Pierce Posted November 24, 2013 Author Share Posted November 24, 2013 Change player to hitElement at line 7, however if you hit the marker with a vehicle for instance, it will try and fade the vehicle's camera. You'll need to check what hit the element and so on. in meanwhile i've changed coordinates to try something else(just to let you know) however now it doesn't even say test in chat,and it doesn't fade my camera. local myMarker = createMarker(2472.2741699219, -1667.9583740234, 13.313663482666, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) outputChatBox( elementType.." test", hitElement, 255, 255, 0 ) -- Change this to hitElement so it outputs for hitElement fadeCamera(hitElement, true, 0.5) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) and in meta it's server side(idk will this help) i don't get any error in debugscript or console edit 2 local myMarker = createMarker(-2596.625, 579.358, 15.626, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) if hitElement and getElementType( hitElement ) == 'player' then fadeCamera( hitElement, true, 0.5 ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) also doesn't work Link to comment
glowdemon1 Posted November 24, 2013 Share Posted November 24, 2013 You should try blauwee's function, it does what I suggested you to do, check if the hit element is a player. If you use it, please go to the marker ON FOOT, not when you're in a vehicle. Post your meta incase you think it's the meta file's fault. Link to comment
Pierce Posted November 24, 2013 Author Share Posted November 24, 2013 (edited) You should try blauwee's function, it does what I suggested you to do, check if the hit element is a player. If you use it, please go to the marker ON FOOT, not when you're in a vehicle. Post your meta incase you think it's the meta file's fault. his didn't work i've always tried on foot maybe meta is wrong "Pierce" description="Marker Test" type="script" version="1.0.0" /> Edited December 12, 2015 by Guest Link to comment
glowdemon1 Posted November 24, 2013 Share Posted November 24, 2013 local myMarker = createMarker(0,0,3, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) if hitElement and getElementType( hitElement ) == 'player' then fadeCamera( hitElement, true, 0.5 ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) This worked for me, are you sure that the file name you put this function is is called marker.lua and check the server console, did it give any errors there? Has the resource been restarted correctly? Link to comment
glowdemon1 Posted November 24, 2013 Share Posted November 24, 2013 What exactly doesn't work? Does the marker appear at all? Does the camera not fade out? Because if you want the camera to be black, you'll have to set fadeCamera() to false instead of true. Link to comment
Pierce Posted November 24, 2013 Author Share Posted November 24, 2013 What exactly doesn't work?Does the marker appear at all? Does the camera not fade out? Because if you want the camera to be black, you'll have to set fadeCamera() to false instead of true. it outputs "test" but it doesn't fade the camera and it says bad argument fadeCamera Link to comment
TAPL Posted November 24, 2013 Share Posted November 24, 2013 Post last code you used where it say bad argument, and try to explain what you are trying to do exactly. Link to comment
Pierce Posted November 29, 2013 Author Share Posted November 29, 2013 Post last code you used where it say bad argument, and try to explain what you are trying to do exactly. local myMarker = createMarker(2472.2741699219, -1667.9583740234, 13.313663482666, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) outputChatBox( elementType.." test", hitElement, 255, 255, 0 ) -- Change this to hitElement so it outputs for hitElement fadeCamera(player, true, 0.5) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) Isn't it obvious that i want to fade camera when a player reaches this marker? Link to comment
TAPL Posted November 29, 2013 Share Posted November 29, 2013 local myMarker = createMarker(2472.2741699219, -1667.9583740234, 13.313663482666, 'corona', 2.0, 255, 0, 0, 150) -- i make marker function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) outputChatBox( elementType.." test", hitElement, 255, 255, 0 ) -- Change this to hitElement so it outputs for hitElement fadeCamera(hitElement, false, 0.5) setTimer(fadeCamera, 1000, 1, hitElement, true) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) Link to comment
Pierce Posted November 29, 2013 Author Share Posted November 29, 2013 Thanks TAPL,It works! 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