JAY.ANN Posted January 25, 2022 Share Posted January 25, 2022 (edited) I'd like to replace vehicle door sounds with my own. I tried to start script that stuff, but I can't finish it. I tried to implement the buffer system, but, I guess, I still don't know what that even means lmao. I'd be very grateful for any help! Here's my code: function doorSoundCheckBuffer(vehicle, previousRatioTable, currentRatioTable) if type(previousRatioTable) == "table" and type(currentRatioTable) == "table" then end end previousDoorRatio = {} currentDoorRatio = {} function doorSoundBufferSystem(vehicle, door, value) if currentDoorRatio[vehicle] == nil then currentDoorRatio[vehicle] = {door, value} else previousDoorRatio[vehicle] = currentDoorRatio[vehicle] currentDoorRatio[vehicle] = {door, value} doorSoundCheckBuffer(vehicle, previousDoorRatio[vehicle], currentDoorRatio[vehicle]) end end addEventHandler("onClientRender", getRootElement(), function() for i, v in ipairs(getElementsByType("vehicle")) do if isElementStreamedIn(v) then for i = 0, 5 do local ratio = getVehicleDoorOpenRatio(v, i) doorSoundBufferSystem(v, i, ratio) end end end end) Edited January 25, 2022 by J-N Link to comment
The_GTA Posted January 26, 2022 Share Posted January 26, 2022 (edited) Hello J-N, in case you need a script to detect the door-open-and-close event clientside I have scripted a little something for you. meta.xml <meta> <script src="doorevents_client.lua" type="client" /> <script src="doors_test.lua" type="client" /> </meta> doorevents_client.lua local veh_doorInfos = {}; local valid_veh_doors = { 0, 1, 2, 3, 4, 5 }; local function getVehicleDoorInfo(veh) local info = veh_doorInfos[veh]; if (info) then return info; end; info = {}; for m,n in ipairs(valid_veh_doors) do info[n] = not ( getVehicleDoorOpenRatio(veh, n) == 0 ); end veh_doorInfos[veh] = info; return info; end addEventHandler("onClientElementDestroy", root, function() if not (getElementType(source) == "vehicle") then return; end; veh_doorInfos[source] = nil; end ); addEvent("onClientVehicleDoorOpenChange"); addEventHandler("onClientRender", root, function() for m,veh in ipairs(getElementsByType("vehicle")) do local vdi = getVehicleDoorInfo(veh); for m,n in ipairs(valid_veh_doors) do local isNotClosed = not ( getVehicleDoorOpenRatio(veh, n) == 0 ); if not (vdi[n] == isNotClosed) then vdi[n] = isNotClosed; triggerEvent("onClientVehicleDoorOpenChange", veh, n, isNotClosed); end end end end ); doors_test.lua addEventHandler("onClientVehicleDoorOpenChange", root, function(doorIndex, isNotClosed) outputChatBox("door nr. " .. doorIndex .. " is open: " .. tostring(isNotClosed)); end ); Hopefully this can come in handy for you! Edited January 26, 2022 by The_GTA 1 Link to comment
JAY.ANN Posted January 26, 2022 Author Share Posted January 26, 2022 Thanks a lot for your help! I'll try to use it a bit later, after I get some rest. ty again! Link to comment
The_GTA Posted January 26, 2022 Share Posted January 26, 2022 1 minute ago, J-N said: Thanks a lot for your help! I'll try to use it a bit later, after I get some rest. ty again! You're welcome! I felt a tad generous today because I had a good day. The next step is making use of the "onClientVehicleDoorOpenChange" event, with the source variable being the vehicle whose doors have been manipulated, to create a 3D sound at the location of the door. Link to comment
JAY.ANN Posted January 26, 2022 Author Share Posted January 26, 2022 Frankly speaking, I don't have any idea how does it work! That's a brilliant script, dude. I wish I could script like you 1 minute ago, The_GTA said: You're welcome! I felt a tad generous today because I had a good day. The next step is making use of the "onClientVehicleDoorOpenChange" event, with the source variable being the vehicle whose doors have been manipulated, to create a 3D sound at the location of the door. Yup, I got that, thank ya! 1 Link to comment
JAY.ANN Posted January 26, 2022 Author Share Posted January 26, 2022 It works, thank you! 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