mtasa-blue
mtasa-blue copied to clipboard
Add resetElements argument to resetWaterLevel
Resolves #2695
Adds a new argument to resetWaterLevel, resetElements
, allowing you to reset the level of one or more water elements
-
nil
(default value) orfalse
: only the GTA world water level will be reset (previous/existing behaviour) -
true
: all water elements created via createWater will have their level reset. -
water-element
: specific water element level reset. -
table{water-elements}
: table of water element level reset
Note: the GTA world water level is unaffected except for values of nil
or false
The default level for a water element, is defined as the average of initial Z vertex positions upon creation.
Upon starting it spawns 2 small water squares next to each other (one on client, one on server) and teleports you to their position.
Use /slevel <num>
(for server) or /clevel <num>
(for client) to set the water level.
Use /sreset <type>
or /creset <type>
to reset the water level for server or client.
The <type>
controls the arguments passed to resetWaterLevel
- 0: nil/none
- 1: true
- 2: single water element
- 3: table of all water elements
Feel free to add more water positions in the waterPositions
table, the script works with it.
The only caveat (with this test resource) is that when using /creset
it will also reset the water level for server created water elements too (since water only has a "true" representation on the client regardless if created on server). But not vice versa (so using /sreset
won't reset client created water elements). You can obviously work around this in your own script by storing a list of the client specific water elements.
On second thoughts, it may be nice if you could also pass a specific element (maybe even a table of elements too) instead of just true
to reset all water elements. See no reason not to do this.
I've implemented the above and updated the test resource.
Nice! Code is ready now?
As a note for the "caveat" mentioned in the initial PR message, this can be easily worked around by maintaining your own list/table of client water elements; so it's really a non-issue.