AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nvault to fvault (https://forums.alliedmods.net/showthread.php?t=241907)

Gasa 06-11-2014 06:12

nvault to fvault
 
Hi guys, is it possible to convert nvault file to fvault(txt) file, because u have some levels from users in that file! And reason is fvault making txt file easy to edit! Thanks in advance

One 06-11-2014 11:16

Re: nvault to fvault
 
Nop.

!Morte 06-11-2014 11:22

Re: nvault to fvault
 
Well, you can use the nVault editor who bugsy upload to edit the .vault file and you will not have to use fvault
https://forums.alliedmods.net/showth...81917?p=581917

Black Rose 06-11-2014 16:22

Re: nvault to fvault
 
Of course you can.

I don't know the official format of the file, but you can definitely find it out by looking at the source of the module.

I just took the file in Bugsy's post and read it in a hex edit plugin for NP++. Here's what I got from that...

Some starting values:
54 4c 56 6e 00 02 (Empty file)
54 4c 56 6e 00 02 05 00 00 00 (Bugsy's file with 5 entries)
Don't know the meaning of the first six bytes. Some sort of header or perhaps version code. The 7th byte is obviously the number of entries. Most likely it's a long value, so the last 4 of those bytes.

51 bf a8 47 07 1d 00
This is the index for the first entry.
Starts of with a long containing the timestamp in UNIX time format.
Then it is most likely a byte that tells you the length of the key string.
After that either a byte or a short telling you the length of the value. To find out which just try storing a string longer than 255 characters. I'm putting my money on short.
This translates into:
47a8bf51: 1*202*241*361 (2008-02-05, 20:56:01 in european format)
07: 7
1d (or 001d): 29

Then the data...
45 6e 74 72 79 20 31 54 68 69 73 20 69 73 20 74 68 65 20 76 61 6c 75 65 20 66 6f 72 20 65 6e 74 72 79 20 31
This translates into:
"Entry1This is the value for entry 1"
"Entry1" contains 7 characters.
"This is the value for entry 1" contains 29 characters.
By using the values from the index you know exactly where to split this string and where to end it.

Then the pattern starts over with a new index.
53 bf a8 47 07 1d 00
and so on...

So basically, you can read it like any file. Interpret these values using some basic code and just save them in the new fvault. 100% doable directly in PAWN if not familiar with other programming languages. And it's not even that hard.

If someone doesn't beat me to it, I'll definitely write a code for you this weekend. (Perhaps it has already been made?)

Gasa 06-11-2014 17:54

Re: nvault to fvault
 
Quote:

Originally Posted by Black Rose (Post 2150048)
Of course you can.

I don't know the official format of the file, but you can definitely find it out by looking at the source of the module.

I just took the file in Bugsy's post and read it in a hex edit plugin for NP++. Here's what I got from that...

Some starting values:
54 4c 56 6e 00 02 (Empty file)
54 4c 56 6e 00 02 05 00 00 00 (Bugsy's file with 5 entries)
Don't know the meaning of the first six bytes. Some sort of header or perhaps version code. The 7th byte is obviously the number of entries. Most likely it's a long value, so the last 4 of those bytes.

51 bf a8 47 07 1d 00
This is the index for the first entry.
Starts of with a long containing the timestamp in UNIX time format.
Then it is most likely a byte that tells you the length of the key string.
After that either a byte or a short telling you the length of the value. To find out which just try storing a string longer than 255 characters. I'm putting my money on short.
This translates into:
47a8bf51: 1*202*241*361 (2008-02-05, 20:56:01 in european format)
07: 7
1d (or 001d): 29

Then the data...
45 6e 74 72 79 20 31 54 68 69 73 20 69 73 20 74 68 65 20 76 61 6c 75 65 20 66 6f 72 20 65 6e 74 72 79 20 31
This translates into:
"Entry1This is the value for entry 1"
"Entry1" contains 7 characters.
"This is the value for entry 1" contains 29 characters.
By using the values from the index you know exactly where to split this string and where to end it.

Then the pattern starts over with a new index.
53 bf a8 47 07 1d 00
and so on...

So basically, you can read it like any file. Interpret these values using some basic code and just save them in the new fvault. 100% doable directly in PAWN if not familiar with other programming languages. And it's not even that hard.

If someone doesn't beat me to it, I'll definitely write a code for you this weekend. (Perhaps it has already been made?)

Omg thanks in advance! P.S. I searched all forum and cant find someone maked somthing likethat!

SpeeDeeR 06-11-2014 20:52

Re: nvault to fvault
 
@Black Rose, can't you just use nvault_util and loop through all entries?

Black Rose 06-12-2014 00:07

Re: nvault to fvault
 
Never used it. Didn't think of it.
Yes you can.

SpeeDeeR 06-12-2014 05:47

Re: nvault to fvault
 
Here ya go. It would need some time to convert, so the server will hang for some time depending on your vault size. It's normal.
Code:
#include <amxmodx> #include <nvault_util> #include <fvault> #define PLUGIN "Nvault To Fvault" #define VERSION "1.2" #define AUTHOR "SpeeDeeR@alliedmods" #define NVAULT_PERM_TIMESTAMP    0 #define FVAULT_PERM_TIMESTAMP   -1 new const VaultName[] = "vaultname"; new const FvaultName[] = "vaultname"; public plugin_init() {     new iVault = nvault_util_open(VaultName);         new iData[ 3 ] = { 8 , 18 , 32 };         nvault_util_readall( iVault , "nvault_util_readall_fwd" , iData , sizeof( iData ) );         nvault_util_close( iVault ); } public nvault_util_readall_fwd( iCurrent , iTotal , const szKey[] , const szVal[] , iTimeStamp , const Data[] , iSize ) {     _fvault_set_data(FvaultName, szKey, szVal, iTimeStamp == NVAULT_PERM_TIMESTAMP ? FVAULT_PERM_TIMESTAMP : iTimeStamp); }

Gasa 06-12-2014 06:34

Re: nvault to fvault
 
Lol this working perfect thx a lot guys :D!

Black Rose 06-12-2014 10:36

Re: nvault to fvault
 
Note that this will not transfer the timestamp.


All times are GMT -4. The time now is 18:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.