SA-MP Forums Archive
[FilterScript] zSave - Save Data in any custom format - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] zSave - Save Data in any custom format (/showthread.php?tid=647715)



zSave - Save Data in any custom format - NaS - 09.01.2018

- zSave v1.0 by NaS -

What does it do?

Are you tired of spamming /save a hundred times for a bunch of spawns and copy out the coords one by one afterwards?
Or do you want to save a lot more data than just positions, CreateVehicle lines etc.?
Then take a look at this! It will certainly make your life easier.

This Filterscript lets you save your current position/rotation/velocity/camera position and more, in any format you can define yourself.

Instead of copying around line for line from savedpositions.txt into your script, you can just create a new format type and select an output file to write to.
After that you can simply use /z to save the current state.

I created this a longer time ago but thought it might be useful for someone.
The /z command isn't done super efficient but it works perfectly fine.


Advantages over /Save:

- Fast - Adding a new Format Type as well as the saving process is a lot faster than extracting x, y, z out of the AddPlayerClass line or writing a FS to do the job for you.
- Dynamic and easy - You can quickly add or edit any desired output format and also switch between formats instantly.

The only thing /Save is better at is, that the output is saved client-side. In this case it is only saved in the scriptfiles directory of the server.


Example:

Assume you have an Array for Random Spawns, and each entry consists of the position, the facing angle and the name for the Spawn.

To save the data in this format (including array brackets and the comma), you can add a new format type:

Code:
{&x, &y, &z, &rz, "&c"},
After that you can type "/z Four Dragons Casino" and the following will get appended to the selected file.

Code:
{2033.4517, 1009.9388, 10.8203, 190.0721, "Four Dragons Casino"},
After saving a couple of locations you can then copy the whole array into your script in one piece - and done!
No need to waste time copying around coordinates.


This is just a very simple example. A more complex example would be

Code:
{&s, &x, &y, &z, &rz, &cpx, &cpy, &cpz, &cvx, &cvy, &cvz, "&c"},
which saves the current Skin ID, Position, Facing Angle, Camera Position, Camera Vector and the Name.
This can be used to save an Array of Class Selection Positions - instead of copying around coords for Player Position, Camera Position and Camera Look At you can just use /z.

Each of these Format Types can be added and managed ingame.


Screenshots:

Here are some screenshots of the dialogs and how to add a new format type, select a file and save a position.

https://imgur.com/a/0ylhy

After that the selected file contained the following line:

Quote:
Originally Posted by random_spawns.txt
{1958.347290, 1342.999023, 15.374607, 270.339508, "High Roller"},
Commands:

/zfile (filename) - Selects a File to write to. Leave empty to view the currently selected file (per-player).
Default: "zsave_default_output.txt" (see define FILE_DEFAULT_OUTPUT).

/zformat (id) - Opens the Format Type Dialog. Here you can select the current Format Type, edit existing types or add new ones (per-player). Optional: specify an ID to quick-select a format type.

/z (comment) - Saves your current State. The comment can be used as specifier (optional).
Requires at least /zformat to select a format type first.


Download & Installation:

You can download the FilterScript from GitHUB:

CLICK

Download zsave.pwn and place it into your filterscipts folder.

After that add it to the filterscripts line in your server.cfg and start up your server (or load it via RCON).


ColAndreas Support:

If you are running ColAndreas, you can enable it by setting the define ENABLE_CA to true. This will enable &gx, &gy, &gz as well as the &grx, &gry and &grz specifiers which allow saving the current terrain height and angle.

It is disabled by default.


Granting Permissions by PVar:

To be able to use any of the zSave Features you must be logged into RCON and/or enable the PVar Admin Level.

To enable the PVar Admin Level, your game mode or admin script must use PVars to save Admin Levels for Players.
If it does, set the define USE_ADMIN_PVAR to true, adjust ADMIN_PVAR_NAME to the Name of your Level PVar (eg. "AdminLevel") and finally adjust ADMIN_PVAR_LEVEL to the minimum required level.


Restricting file output to a specific folder:

To disallow esacping a specified directory, you can set the define LOCK_TO_FOLDER to true and set LOCK_PATH to the desired path. This will prevent users from escaping the selected directory using /zfile


Suggestions for new Specifiers:

If you have more ideas for useful specifiers, just suggest them here. I'll gladly add them!


Credits:

- ZCMD
- ColAndreas


Re: zSave - Save Data in any custom format - SonnyGamer - 09.01.2018

You've done a good job dude.

Just one thing I wanna say is that this is indeed useful script but I also like old school /save which is not gonna be replaced for me with any system.

+REP for hardwork you did over here


Re: zSave - Save Data in any custom format - Trucksamp - 09.01.2018

good joob


Re: zSave - Save Data in any custom format - Castiel17 - 10.01.2018

Nice work