AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   upload vault content to mysql (https://forums.alliedmods.net/showthread.php?t=313909)

TheBladerX 01-27-2019 11:49

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

Bugsy 01-27-2019 12:50

Re: upload vault content to mysql
 
Yes, use nVault Utility to read the vault and SQL statements to insert into the DB.

TheBladerX 01-27-2019 15:12

Re: upload vault content to mysql
 
Thank you! But which sql statements do you exactly mean?

PTE 01-27-2019 15:19

Re: upload vault content to mysql
 
Insert into ?

Bugsy 01-27-2019 16:31

Re: upload vault content to mysql
 
Yes, INSERT INTO [table] ([fields]) VALUES ([values])

TheBladerX 02-03-2019 08:16

Re: upload vault content to mysql
 
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]);


Bugsy 02-03-2019 11:41

Re: upload vault content to mysql
 
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 ] );
    }



TheBladerX 02-03-2019 12:42

Re: upload vault content to mysql
 
Quote:

Originally Posted by Bugsy (Post 2637976)
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.

eat1k 02-03-2019 12:55

Re: upload vault content to mysql
 
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,"^"","^"^"");



TheBladerX 02-03-2019 14:28

Re: upload vault content to mysql
 
Quote:

Originally Posted by eat1k (Post 2637990)
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?


All times are GMT -4. The time now is 07:39.

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