Raised This Month: $51 Target: $400
 12% 

upload vault content to mysql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 01-27-2019 , 11:49   upload vault content to mysql
Reply With Quote #1

Hello, is it possible to somehow extract content from file .vault into mysql db? Just for reading (every day for example)

Last edited by TheBladerX; 01-27-2019 at 11:50.
TheBladerX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-27-2019 , 12:50   Re: upload vault content to mysql
Reply With Quote #2

Yes, use nVault Utility to read the vault and SQL statements to insert into the DB.
__________________
Bugsy is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 01-27-2019 , 15:12   Re: upload vault content to mysql
Reply With Quote #3

Thank you! But which sql statements do you exactly mean?
TheBladerX is offline
PTE
Junior Member
Join Date: Aug 2018
Location: localhost
Old 01-27-2019 , 15:19   Re: upload vault content to mysql
Reply With Quote #4

Insert into ?
PTE is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-27-2019 , 16:31   Re: upload vault content to mysql
Reply With Quote #5

Yes, INSERT INTO [table] ([fields]) VALUES ([values])
__________________
Bugsy is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-03-2019 , 08:16   Re: upload vault content to mysql
Reply With Quote #6

Okay, thank you. But now I have this problem:
I have one vault entry like this:

Code:
josey-10-cod470524#98#100#100#100#100#50#3112#50
, which is

Code:
[1307 of 1322] Key=josey-10-cod Val=470524#98#100#100#100#100#50#3112#50 Timestamp=1547216339
Is it possible to extract name josey-10-cod with those values assigned to something? For example val 470524 would be assigned to $doswiadczenie_gracza[id], val 98 would be assigned to $poziom_gracza[id], which I can later use to insert into database?

Also this is the vault:
Code:
format(vaultkey,63,"%s-%i-cod", nazwa_gracza[id], klasa_gracza[id]);
	format(vaultdata,255,"%i#%i#%i#%i#%i#%i#%i#%i#%i", doswiadczenie_gracza[id], poziom_gracza[id], inteligencja_gracza[id], zdrowie_gracza[id], wytrzymalosc_gracza[id], kondycja_gracza[id], bonus_gracza[id], monety[id], ochrona_gracza[id]);

Last edited by TheBladerX; 02-03-2019 at 08:17.
TheBladerX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-03-2019 , 11:41   Re: upload vault content to mysql
Reply With Quote #7

PHP Code:
#include <amxmodx>
#include <nvault>

const MaxNumberLength 6;

enum VaultValues
{
    
doswiadczenie
    
poziom
    
inteligencja,
    
zdrowie
    
wytrzymalosc
    
kondycja,
    
bonus,
    
monety
    
ochrona
}

new 
iPlayerDataMAX_PLAYERS ][ VaultValues ];

public 
Testid )
{
    new 
szKey32 ] , szData64 ] , iVault;
    
    new 
iLen nvault_getiVault szKey szData charsmaxszData ) );
    
ParsePlayerDataid szData iLen );
}

public 
ParsePlayerDataid szVaultData[] , iLen 
{
    new 
szNumbersVaultValues ][ MaxNumberLength ] , VaultValues:vvIndex VaultValues:-iPos 0;
    
    
replace_allszVaultData iLen "#" " " );
    
    while ( ( 
iPos > -) && ( ++vvIndex VaultValues:sizeofszNumbers ) ) )
    {
        
iPos argparseszVaultData iPos szNumbersvvIndex ] , charsmaxszNumbers[] ) );
        
        
iPlayerDataid ][ VaultValues:vvIndex ] = str_to_numszNumbersvvIndex ] );
        
        
server_print"Found [%d]" iPlayerDataid ][ VaultValues:vvIndex ] );
    }

__________________
Bugsy is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-03-2019 , 12:42   Re: upload vault content to mysql
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
PHP Code:
#include <amxmodx>
#include <nvault>

const MaxNumberLength 6;

enum VaultValues
{
    
doswiadczenie
    
poziom
    
inteligencja,
    
zdrowie
    
wytrzymalosc
    
kondycja,
    
bonus,
    
monety
    
ochrona
}

new 
iPlayerDataMAX_PLAYERS ][ VaultValues ];

public 
Testid )
{
    new 
szKey32 ] , szData64 ] , iVault;
    
    new 
iLen nvault_getiVault szKey szData charsmaxszData ) );
    
ParsePlayerDataid szData iLen );
}

public 
ParsePlayerDataid szVaultData[] , iLen 
{
    new 
szNumbersVaultValues ][ MaxNumberLength ] , VaultValues:vvIndex VaultValues:-iPos 0;
    
    
replace_allszVaultData iLen "#" " " );
    
    while ( ( 
iPos > -) && ( ++vvIndex VaultValues:sizeofszNumbers ) ) )
    {
        
iPos argparseszVaultData iPos szNumbersvvIndex ] , charsmaxszNumbers[] ) );
        
        
iPlayerDataid ][ VaultValues:vvIndex ] = str_to_numszNumbersvvIndex ] );
        
        
server_print"Found [%d]" iPlayerDataid ][ VaultValues:vvIndex ] );
    }

Found [0]
also had to change argparse to parse, it did not want to compile.

Last edited by TheBladerX; 02-03-2019 at 12:44.
TheBladerX is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 02-03-2019 , 12:55   Re: upload vault content to mysql
Reply With Quote #9

From AES:
PHP Code:
mysql_escape_string(dest[],len)
{
    
//copy(dest, len, source);
    
replace_all(dest,len,"\\","\\\\");
    
replace_all(dest,len,"\0","\\0");
    
replace_all(dest,len,"\n","\\n");
    
replace_all(dest,len,"\r","\\r");
    
replace_all(dest,len,"\x1a","\Z");
    
replace_all(dest,len,"'","''");
    
replace_all(dest,len,"^"","^"^"");

__________________
eat1k is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-03-2019 , 14:28   Re: upload vault content to mysql
Reply With Quote #10

Quote:
Originally Posted by eat1k View Post
From AES:
PHP Code:
mysql_escape_string(dest[],len)
{
    
//copy(dest, len, source);
    
replace_all(dest,len,"\\","\\\\");
    
replace_all(dest,len,"\0","\\0");
    
replace_all(dest,len,"\n","\\n");
    
replace_all(dest,len,"\r","\\r");
    
replace_all(dest,len,"\x1a","\Z");
    
replace_all(dest,len,"'","''");
    
replace_all(dest,len,"^"","^"^"");

That is for what?
TheBladerX is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:21.


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