Dzsozi (h03)

[SHOW] Vehicles Get Dirty

Recommended Posts

txeWhLw.png

 

 Hello! 

I would like to show you my current project I am working on. This is about vehicles getting dirtier while you are driving them (something you can see in GTA IV and GTA V). It is currently in beta, I may release if after I finished it!

 

Here you can see some pictures of the current features of the script:

3rCbXLZ.jpg

Every vehicle that has the vehiclegrunge256 texture on it is compatible with this script (you can add your own textures in the script you would like to change, for example if the modded vehicle doesn't have the vehiclegrunge256 texture, but has a texture named only grunge, you can add this in a table, so it will work with that one as well).

replaceTextures = {
	{"vehiclegrunge256"},
	{"grunge"},
}

 

EdlPfN9.png

The script contains car washes (you go into a car wash --> your vehicle gets cleaned).

 

0psQ9VK.png

You can enable/disable custom car wash garage maps via script when adding a new car wash.

carwashes = {
	-- x, y, z, rotation (for garage only), garage
	{2454.51343, -1461.01477, 24.00000, 0, false},
	{1911.29041, -1776.22644, 13.38281, 0, false},
	{1017.74756, -917.59283, 42.17969, 0, false},
	{1574.125, -2350, 13.56247, 90, true},
}

 

tXt5v88.jpg

When the weather is rainy or you go into water with your vehicle it gets cleaner over time. Every vehicle is affected in this case, for example if there are vehicles parked around on the map with dirt on it and it is raining, they will get cleaner slowly.

There are 5 states of dirt level, 1 is fully clean and 5 is the dirtiest. The script currently has 2 export functions which with you can change and get the dirt level of a vehicle (you can also get the dirt level of a vehicle with getElementData, but can't change it with setElementData, I will add dirt level changing with setElementData in further updates).

 

Vehicles will get dirty faster if you drive on grass, sand, dirt, etc. They will get dirty anyways, but it is faster on materials that is not concrete or something similar.

 

I will upload a video soon of the script so you can see it in progress. As I mentioned before, I might release it after it's done. Not much to add/improve, this means it will more likely to happen sooner than later.

 

 VIDEO: 

This is still a beta version!
The video doesn't show real values of time and other intervals, everything is because of testing and showing a pre-version of the script.
Work is currently in progress regarding this script / project!

 

 TO DO: 

[GREEN] = Done 
[ORANGE] = In progress 
[RED] = Need to be done 

- Fix any appearing bugs, requires a few more testing to make sure there are none  [ * ] 

- Make it compatible with car paint shaders (I don't know yet if it is possible, I will try to do it)  [ * ] 

- Add useful custom events (on[Client]VehicleDirtLevelChange, on[Client]VehicleWashed, etc. everything that is useful for further scripting and for developers)
 [ * ] 

- Make a better handler for getting vehicle dirty, right now the script uses onClientRender, there might be another solution that is more client friendly, I don't know, I will play around with possibilities  [ * ] 

 

 WHAT'S NEW: 

* 2017. 10. 13. 

- Custom dirt textures

- Vehicle streaming optimization

- Useful, dynamic debug panel, outputs and values for testing - You can switch between debug mode in game

- Fixed syncing bugs / errors between client and server (some things still need to be fixed)

- Improved car washes (far from done, still needs improving and adding some extras)

- Improved "dirt-add-handling-progress" (can't say it better :lol:)

* 2017. 10. 14. 

- Fixed various present bugs (a few of them can be seen in the video)

- Vehicles now store the current dirt progress when they are streamed out and streamed in

- Rewritten dirt progress handling, more dynamic and 0 (didn't found any yet) bugs, depending on conditions (is it raining, is vehicle in water, etc.)

- Client side event now triggers when server side event is triggered but not the opposite way

- Improved debug display

- Shortened and more optimized script

Client side is about 350 lines (with debug) and server side is about 50 lines (with debug and commands) of code.

* 2017. 10. 26.

- Fixed a bug where the vehicles' dirt progress wasn't synchronized between players.

- More optimized script

- Custom functions: 

 * getVehicleDirtLevel (shared) * setVehicleDirtLevel (server) * 
 * getVehicleDirtProgress (shared) * setVehicleDirtProgress (server) * 
 * getNextDirtTime (shared) * setVehicleDirtTime (server) * 

- Custom events:

 * onClientVehicleDirtLevelChange (client) * onVehicleDirtLevelChange (server) * 

 

I always like to read suggestions, so feel free to comment your thoughts and what should I add/remove!

Thank you for reading, hope you like it!

 

 Part of the Advanced Vehicle System project. 
advanced-vehicle-system.gif

 

 EDIT I would appreciate if somebody could tell me a simple but interesting name for the resource, that is not "Vehicles Get Dirty" (it is too long).  :lol: I was thinking about VGD, but this is not good enough, nobody will know what does that mean if it gets uploaded to the community.

 

 Download: 

https://community.mtasa.com/?p=resources&s=details&id=14960

Note that you will have to give up on car paint shaders if you would like to use this resource, unless you know how to make both work, since I couldn't figure it out. :D But if you know, please let me know as well and I will fix this problem with a quick update on this resource!

Edited by Dzsozi (h03)
Added video + a few changes
  • Like 5
  • Thanks 1

Share this post


Link to post

Truly amazing work! Makes the game look completely different!

Keep it up

  • Thanks 1

Share this post


Link to post
4 hours ago, xeon17 said:

Truly amazing work! Makes the game look completely different!

Keep it up

Thank you! And thanks for your feedback!

Share this post


Link to post

Should make it slowly build dirt instead of sudden changes to different textures.

Share this post


Link to post
1 hour ago, CodyJ(L) said:

Should make it slowly build dirt instead of sudden changes to different textures.

After the base system is done it could be done easily by adding more textures and lowering the time values.

-- current

local grungeTextures = {}
grungeTextures[1] = dxCreateTexture("files/images/nogrunge.png")
grungeTextures[2] = dxCreateTexture("files/images/lowgrunge.png")
grungeTextures[3] = dxCreateTexture("files/images/defaultgrunge.png")
grungeTextures[4] = dxCreateTexture("files/images/biggrunge.png")
grungeTextures[5] = dxCreateTexture("files/images/megagrunge.png")

You can add as many textures as you want. But I don't know how adding more textures would affect the performance. Right now this is the only way I could think of a solution for what you wrote.

Edited by Dzsozi (h03)

Share this post


Link to post

I did one before that slowly faded in and moved a dirt texture (Then layered a variety of dirt textures depending on how dirty it is) wish I still had files for it though lost it along with my latest server build.

Share this post


Link to post
3 minutes ago, CodyJ(L) said:

I did one before that slowly faded in and moved a dirt texture (Then layered a variety of dirt textures depending on how dirty it is) wish I still had files for it though lost it along with my latest server build.

If you can remember and explain how it must be done, I might remake it.

Share this post


Link to post

I had WIP dynamic dirt system meaning only the bits of the car that should get dirt on them got dirt and going through water washed the car up to the point where the water submerged it.

Share this post


Link to post
6 hours ago, CodyJ(L) said:

I had WIP dynamic dirt system meaning only the bits of the car that should get dirt on them got dirt and going through water washed the car up to the point where the water submerged it.

From my perspective, it requires more shader knowledge than I have, I wouldn't be able to do it by myself yet. Maybe later, when I get more experienced with shaders, for now I stick to the method that can be seen here.

Share this post


Link to post

THATS PRETTY GOOD 

1c860d225d5cb874dc86812fa55af0a8.png

  • Haha 1

Share this post


Link to post

New update! This resource is almost done, I will do a few more testing and improvements and I might release it, don't know for sure yet, first of all I would like to make sure it's flawless.

 Note that I don't spend my whole days sitting in front of my PC, scripting MTA. Don't expect me to finish this / any other project(s) I have posted in 2 days. 

Edited by Dzsozi (h03)
  • Sad 1

Share this post


Link to post

 Released! 

Check the post for download link!

Sorry for making it that long, I didn't have enough energy to work with MTA in the last few days. Anyways, enjoy the resource, hope you like it!

Note that it might contain bugs or glitches, if that's the case please report them and I will try to fix it as soon as possible!

You can edit the resource based on your needs, all I ask for is to leave the credits for me!

 Have fun! 

  • Like 1

Share this post


Link to post

 Information for the resource: 

Shared custom functions:

int getVehicleDirtLevel(element vehicle) - Returns a number representing the dirt level of the vehicle. 1 is the lowest (fully clean) and 5 is the highest (most dirty).

int getVehicleDirtProgress(element vehicle) - Returns a number representing the dirt progress of the vehicle. See the script files for better understanding!

int getNextDirtTime(element vehicle) - Returns a number representing the time limit when the vehicle gets dirty again. See the script files for better understanding!

bool setVehicleDirtLevel(element vehicle, int level) - Returns true if set succesfully, false otherwise.  IMPORTANT:  Using this on client side won't make the vehicle "globally" dirty, only for the client, use this on server side mostly, since this is where other things like dirt progress and other datas are being set. Also, it will only work for other clients (by that I mean that they will see the effects of the shader) if you use this function on server side.

Server side custom functions:

bool setVehicleDirtProgress(element vehicle, int progress) - Returns true if set succesfully, false otherwise. Sets the dirt progress of a vehicle. See the script files for better understanding!

bool setVehicleDirtTime(element vehicle, int time) - Returns true if set succesfully, false otherwise. Sets the dirt time of a vehicle. This is a limit which checks if a vehicle has to get a dirt level or not. See the script files for better understanding!

Server side custom events:

onVehicleDirtLevelChange - Parameters: int oldLevel int newLevel

oldLevel: The old dirt level of the vehicle, before the event was triggered.

newLevel: The new dirt level of the vehicle, after the event was triggered.

The source of this event is the vehicle that got its dirt level changed.

This event is called when a vehicle got its dirt level changed. For example a vehicle was washed in a carwash.

Client side custom events:

onClientVehicleDirtLevelChange - Parameters: int oldLevel int newLevel

oldLevel: The old dirt level of the vehicle, before the event was triggered.

newLevel: The new dirt level of the vehicle, after the event was triggered.

The source of this event is the vehicle that got its dirt level changed.

This event is called when a vehicle got its dirt level changed. For example a vehicle was washed in a carwash.

Share this post


Link to post
On 14/10/2017 at 15:33, Dzsozi (h03) said:

Depois que o sistema base for feito, pode ser feito facilmente adicionando mais texturas e diminuindo os valores de tempo.




 
  
  
  
  
  

Você pode adicionar tantas texturas quanto desejar. Mas eu não sei como a adição de mais texturas afetaria o desempenho. Agora, esta é a única maneira de pensar uma solução para o que você escreveu.

use this feature to do this you can increase the level of dirt by "changing the textures according to which greater distance traveled".
 

 

Share this post


Link to post
On 2017. 12. 28. at 18:45, maximumdrive said:

The other way to use your great idea is to let vehicles become rusty :D

Yes I agree and I was also thinking about it. :D

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.