Fox261098 Posted January 6, 2016 Share Posted January 6, 2016 How to make an object move by hitting a marker Thanks Link to comment
ViRuZGamiing Posted January 6, 2016 Share Posted January 6, 2016 You'll need these; createMarker onMarkerHit (or onClientMarkerHit) createObject moveObject Link to comment
Fox261098 Posted January 6, 2016 Author Share Posted January 6, 2016 im gonna try alone but anyway can u make Link to comment
ViRuZGamiing Posted January 6, 2016 Share Posted January 6, 2016 Yes I can but you'll have to make it yourself and I'll correct and help. Regards Billy Link to comment
Fox261098 Posted January 6, 2016 Author Share Posted January 6, 2016 This good ? function (createTheMarker) createMarker (x,y,z) end function (createObject) createObject (x,y,z) end function (moveObject) moveObject (x,y,z) end onMarkerHit ( thePlayer ) objectMove function (moveObjectBack) moveObjectBack (x,y,z) end onMarkerHit ( thePlayer ) objectMoveBack Link to comment
ViRuZGamiing Posted January 6, 2016 Share Posted January 6, 2016 onMarkerHit is an event which is used in an addEventHandler, First you write the event name, then the marker name, then the function name mx, my, mz are marker coordinates r, g, b, a (red, green, blue, alpha (alpha is visibility)) x, y, z closed gate coordinates rx, ry, rz rotation of the gate timeInMillisec needs to be a time in milliseconds (1000ms is 1 sec) x2, y2, z2 location of the gate after moving. local markerName = createMarker(mx, my, mz, "cylinder", 1.0, r, g, b, 255) local gateName = createObject(model, x, y, z, rx, ry, rz) function markerHitFunction() moveObject(gateName, timeInMillisec, x2, y2, z2) end addEventHandler("onMarkerHit", markerName, markerHitFunction The gate will only open now not close. Understand this and we'll continue Link to comment
Fox261098 Posted January 6, 2016 Author Share Posted January 6, 2016 local markerName = createMarker(mx, my, mz, "cylinder", 1.0, r, g, b, 255) local gateName = createObject(model, x, y, z, rx, ry, rz) this too tx ry rz ??? function markerHitFunction() moveObject(gateName, timeInMillisec, x2, y2, z2) what means y2 y2 z2? end addEventHandler("onMarkerHit", markerName, markerHitFunction Link to comment
ViRuZGamiing Posted January 6, 2016 Share Posted January 6, 2016 mx, my, mz are marker coordinates r, g, b, a (red, green, blue, alpha (alpha is visibility)) x, y, z closed gate coordinates rx, ry, rz rotation of the gate timeInMillisec needs to be a time in milliseconds (1000ms is 1 sec) x2, y2, z2 location of the gate after moving. I've explained it here, look above. Also try using the LUA tags in the forum. Link to comment
Fox261098 Posted January 6, 2016 Author Share Posted January 6, 2016 i understant now lets go to part 2 close the gate Link to comment
ViRuZGamiing Posted January 6, 2016 Share Posted January 6, 2016 How I like to work is with a state boolean there are other ways tho. local state = false function markerHitFunction() if (state) then moveGate = moveObject(gateName, timeInMillisec, x2, y2, z2) else moveGate = moveObject(gateName, timeInMillisec, x, y, z) -- Original x, y, z coordinates end if (moveGate) then state = not state; end end Didn't test I'm in class atm probably should work. Link to comment
Fox261098 Posted January 6, 2016 Author Share Posted January 6, 2016 i need other part of this to close the gate local markerName = createMarker(mx, my, mz, "cylinder", 1.0, r, g, b, 255) local gateName = createObject(model, x, y, z, rx, ry, rz) function markerHitFunction() moveObject(gateName, 2000, x, y, z) end addEventHandler("onMarkerHit", markerName, markerHitFunction) and can u make it and put the command just for one gang to use gang name TheGhosts Link to comment
ViRuZGamiing Posted January 6, 2016 Share Posted January 6, 2016 local markerName = createMarker(mx, my, mz, "cylinder", 1.0, r, g, b, 255) local gateName = createObject(model, x, y, z, rx, ry, rz) local state = false function markerHitFunction() if (state) then moveGate = moveObject(gateName, timeInMillisec, x2, y2, z2) else moveGate = moveObject(gateName, timeInMillisec, x, y, z) -- Original x, y, z coordinates end if (moveGate) then state = not state; end end addEventHandler("onMarkerHit", markerName, markerHitFunction) You just needed to fill it in the part you had, I suggest you learning LUA first cause all I did was make it for you. https://wiki.multitheftauto.com/wiki/Sc ... troduction Don't start with moving gates, start easy, outputs, set money, etc. Kind regards, Billy 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