Akenture Posted September 29, 2016 Share Posted September 29, 2016 (edited) i'm searching a tool for record movement of vehicle or ped and output the movement to lua like Awesome Movement Recorder(I'm not saying the lines, if not the car movement) i'm doing the car movements like this and can only make a movement in line example Object = createObject(...) --Object route(point 1) Vehicle = CreateVehicle(...) --Vehicle attachElements(Vehicle, Object, ....) moveObject(Object, ...) --(point 2)[/CODE] i want to record the route in vehicle and output in lua(if possible don't using attachelement) like thishttps://www.youtube.com/watch?v=R034tCENhYk min 0:34 anyone know tool like this? please post if exists Edited September 29, 2016 by Akenture Link to comment
Captain Cody Posted September 29, 2016 Share Posted September 29, 2016 setTimer table.insert getElementPosition getElementRotation And you could save it to an xml file or something when you stop the recorder. Link to comment
Dealman Posted October 1, 2016 Share Posted October 1, 2016 (edited) You'll probably want to save the data to a text file rather than XML, since for optimal results you would record the vehicle's data with every frame - using setTimer you're limited to a minimum of delay of 50ms which will look rather choppy. XML is pretty slow compared, so I'd stick with good old fileRead. I was working on a kill cam about 2 years ago, it's far from finished and not optimized - but you can use it for inspiration if you'd like. It's dependent on the race resource, so make sure you have it running.Meta.xml Spoiler <meta> <min_mta_version server="1.4.0" client="1.4.0"/> <script src="Server.lua" type="server"/> <script src="Client.lua" type="client"/> </meta> Server.lua Spoiler function updateRaceState_Handler(newState, oldState) if(newState == "Running") then local allPlayers = getElementsByType("player") for k, v in pairs(allPlayers) do if(isPedDead(v) == false) then triggerClientEvent(v, "updateClientRaceState", resourceRoot, "Running") end end end end addEvent("onRaceStateChanging", true) addEventHandler("onRaceStateChanging", root, updateRaceState_Handler) Client.lua Spoiler -- Variables local mapState = false local recordIndex = 0 -- Tables local log_VehiclePositionData = {} local log_VehicleRotationData = {} local log_VehicleVelocityData = {} function updateClientRaceState_Handler(newState) if(newState == "Running") then outputChatBox("Starting Recording") mapState = "Running" startTick = getTickCount() addEventHandler("onClientRender", root, log_LocalVehicleData_Handler) --collectgarbage("restart") end end addEvent("updateClientRaceState", true) addEventHandler("updateClientRaceState", root, updateClientRaceState_Handler) function log_LocalVehicleData_Handler() local currentTime = getTickCount() if((currentTime-startTick) <= 15000) then if(isPedDead(localPlayer) == false) then if(isPedInVehicle(localPlayer) == true) then -- Empty The Tables -- Start Recording local theVehicle = getPedOccupiedVehicle(localPlayer) local pX, pY, pZ = getElementPosition(theVehicle);table.insert(log_VehiclePositionData, {pX, pY, pZ}) local rX, rY, rZ = getElementRotation(theVehicle);table.insert(log_VehicleRotationData, {rX, rY, rZ}) local vX, vY, vZ = getElementVelocity(theVehicle);table.insert(log_VehicleVelocityData, {vX, vY, vZ}) end end else outputChatBox("Recording Finished!") removeEventHandler("onClientRender", root, log_LocalVehicleData_Handler) --collectgarbage("collect") --collectgarbage("count") --outputChatBox(tostring(gcinfo())) end end function renderReplay_CMD() theReplayVehicle = createVehicle(568, 0, 0, 0) theReplayPed = createPed(0, 0, 0, 0) warpPedIntoVehicle(theReplayPed, theReplayVehicle, 0) replayFrame = 1 addEventHandler("onClientRender", root, renderReplay_Handler) end addCommandHandler("startreplay", renderReplay_CMD) function renderReplay_Handler() setElementPosition(theReplayVehicle, log_VehiclePositionData[replayFrame][1], log_VehiclePositionData[replayFrame][2], log_VehiclePositionData[replayFrame][3]) setElementRotation(theReplayVehicle, log_VehicleRotationData[replayFrame][1], log_VehicleRotationData[replayFrame][2], log_VehicleRotationData[replayFrame][3]) setElementVelocity(theReplayVehicle, log_VehicleVelocityData[replayFrame][1], log_VehicleVelocityData[replayFrame][2], log_VehicleVelocityData[replayFrame][3]) replayFrame = replayFrame+1 end And as I said, this code is from 2 years ago - it's nowhere near complete and not at all optimized and is merely to serve as a test.How to use;1. Make a new resource and add the above files.2. Make sure "race" is running.3. Start the resource you just made.4. Start a new map(the script will start recording when a new map has started)5. It will record for 15 seconds, after 15 seconds have passed - type /startreplay to watch the replay. Edited October 1, 2016 by Dealman 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