Log in to reply
 

[SCRIPT] Script to SLOW DOWN dirt accumulation on vehicles



  • Vehicles get dirty after driving a just a few hundred meters. Can anyone please write a script that slows down dirt accumulation on vehicles?



  • I can, is it possible to contact you on Discord for further information?



  • @Hood-Krazz why not share with the community?



  • @JohnFromGWN It wouldn't bother me, not even a bit. It would just be easier to speak with him on Discord (To Prevent Unnecessary Delay) so I can make sure everything he wanted is done and within reasonable time. 9 times out of 10, it will be released on this "forum" when it's completed.



  • @Armouredivision said in [SCRIPT] Script to SLOW DOWN dirt accumulation on vehicles:

    Vehicles get dirty after driving a just a few hundred meters. Can anyone please write a script that slows down dirt accumulation on vehicles?

    Done (Requires JM36 Lua Plugin), Multiplier is 0.25 (keeps only 25% of the change) by default:

    JM36.CreateThread(function()
    	local GetVehicleDirtLevel = GetVehicleDirtLevel
    	local SetVehicleDirtLevel = SetVehicleDirtLevel
    	
    	local math_min = math.min
    	
    	local Multiplier
    	do
    		local config = configFileRead("VehicleDirtLevelMultiplier.ini")
    		local _Multiplier = tonumber(config.Multiplier or 0)
    		Multiplier = (_Multiplier > 0 and _Multiplier) or 0.25
    	end
    	
    	local Vehicle = Info.Player.Vehicle
    	
    	local LastVehicleId, LastVehicleDirtLevel
    	
    	local yield = JM36.yield
    	while true do
    		if Vehicle.IsIn then
    			local Vehicle_Id = Vehicle.Id
    			local VehicleDirtLevel = GetVehicleDirtLevel(Vehicle_Id)
    			if Vehicle_Id ~= LastVehicleId then
    				LastVehicleId = Vehicle_Id
    				LastVehicleDirtLevel = VehicleDirtLevel
    			end
    			if VehicleDirtLevel > LastVehicleDirtLevel then
    				VehicleDirtLevel = (VehicleDirtLevel - LastVehicleDirtLevel) * Multiplier
    				LastVehicleDirtLevel = math_min(LastVehicleDirtLevel + VehicleDirtLevel, 15.0)
    				SetVehicleDirtLevel(Vehicle_Id, LastVehicleDirtLevel)
    			end
    		end
    		yield()
    	end
    end)
    

    Repo: https://github.com/JayMontana36/JM36_GTAV_LP_Script-VehicleDirtLevelMultiplier


  • MODERATOR

    Nice, hoping someone posts a C++ solution in a editable cs file



  • @ReNNie said in [SCRIPT] Script to SLOW DOWN dirt accumulation on vehicles:

    Nice, hoping someone posts a C++ solution in a editable cs file

    I prefer not to have any dirt if I'm driving an exotic car.
    So i remove the dirt with
    void SET_VEHICLE_DIRT_LEVEL(Vehicle vehicle, float dirtLevel)



  • @JayMontana36 Very simple solution, easy to follow, customizable, and I understand you want to promote your plugin, but maybe you can consider @ReNNie's comment, that writing this, with same natives, in C#, would be easy and it doesn't even need to be compiled, just saved as a text file and placed in scripts. Doesn't need ini file either, just edit the multiplier in the text itself and save.

    What you did is great, very few programmers are offering support here and you provided a complete solution, but, yes here comes the but, SP is not GMOD or FiveM, it's a C community with C# dot net having replaced C++, and 99.9% of users already having SHVDN installed. And I do realize there are vehicle scripts using Lua.

    Not saying there isn't a place for Lua or that it isn't good, just saying the currency for SP isn't Lua.

    Either way, gg.



  • @JohnFromGWN thing is, I am extremely proficient when it comes to Lua, and/but that pretty much is where that ends; I don't know (understand writing in) C# nor C++ and have pretty much never been successful at getting anything to work no matter what I've done or tried, whether it is because of strange/weird/unexplainable errors that have no solution (it's solution is to open up a bing search for the problem and yield zero results for actually fixing it), overall though compared to Lua is just a complete pain to deal with, for me at least; it also generally is much more of a pain to get various "random" mods to work well together (more so when the majority of people don't ever provide any source) in an efficient manner when compared to if they were done in Lua.

    Although, something that I will say is that the old/legacy Lua Plugin stuff, like pretty much everything about it, is completely abysmal, atrocious to say the least, but I have pretty much gutted out the entire thing, every part of it that I could, and have rebuilt the entire thing from the ground up from scratch, just with support for existing scripts; if someone wants to take something that I make in Lua and rewrite it in any other language though, they are pretty free to do so, I also made sure that everything was pretty simple and easy to understand, especially since I figured that there was bound to be someone asking for it to be in C# or C++ for whatever reason (so it should be pretty easy for them to understand and convert if they want), I really don't get/understand what's so bad about Lua when it basically pretty much just works no matter what (as long as you don't syntax error your script and whatnot), especially after what I've been doing with it, compared to what it was.

    And I wish I could improve things even further, but I just can't be bothered with trying to get things to work in C# or C++; maybe sometime eventually, though likely not, I just don't have the competence like I do in Lua for C# or C++. The best that I can do pretty much is to either somehow come up with a good/decent amount of money to pay someone to do/write it for me or just continue to improve the Lua working/development environment like I have been doing, and being pretty efficient with very close attention to detail; most older/existing scripts even run a lot smoother/better now than they did before, and lots of bugs/issues that I've seen or been told about are non existent now, especially since the updates that I've made this year, and will be continuing to make over time.


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.