Monthly Target: $400 Donations: $344
 86% 

[INC] SQLVault


Post New Thread Reply   
 
Thread Tools Display Modes
Exolent[jNr]
AMX Mod X Moderator
Join Date: Feb 2007
Location: Tennessee
Old 04-05-2012 , 13:43   Re: [INC] SQLVault
Reply With Quote #51

NVault has that problem if you keep the vault open the whole map.
This is because NVault doesn't save any data to the file until it is closed.
While it is open, all of the data is stored in memory to be more efficient when grabbing/setting.
When the vault isn't closed due to for example a server crash, all the unsaved data is lost.

With SQLVault, it is stored in the database directly and not in memory, so you will not have this problem.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
funfel
Member
Join Date: Apr 2011
Old 04-05-2012 , 18:49   Re: [INC] SQLVault
Reply With Quote #52

First of all - thanks you! Creating Tops or Ranks, etc. with nvault and arrays - slowly work, and I can't use SQL because I don't know how (I know, know, but a bit), but now - easy to do and moreover - it is SQL
But I have one question, this code:
PHP Code:
sqlv_read_exg_hVault0szKey1charsmax(szKey1), "level"6szDatacharsmax(szData), iTimeStamp"""`data` DESC"); 
Is the same like this:
PHP Code:
sqlv_read_exg_hVault0szKey1charsmax(szKey1), ""0szDatacharsmax(szData), iTimeStamp"`key2` = 'level'""`data` DESC"); 
I don't know, because u saved blank szKey2 in second code and you wrote key2 in szWhere. I checked it on my server for test, result is the same, but Is there a difference?


Sorry for my bad english, i am just from country, where english isn't on good level (POLAND).

@EDIT: Sorry, now I checked .inc and I analyzed it thoroughly, first code is wrong

Last edited by funfel; 04-05-2012 at 20:23.
funfel is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-06-2012 , 16:40   Re: [INC] SQLVault
Reply With Quote #53

Would this be a simple way for converting

Nvault:
PHP Code:
public LoadTimeid 
{
    new 
vault nvault_open("Played_Time")
    
    new 
szAuthID[33];
    new 
vaultkey[64], vaultdata[64];
    
    
get_user_authid(idszAuthIDcharsmax(szAuthID));
    
    
format(vaultkey63"PLAYEDTIME%s"szAuthID);
    
    
nvault_get(vaultvaultkeyvaultdata63);
    
nvault_close(vault);
    
    return 
str_to_num(vaultdata);
}
 
public 
SaveTime(id,PlayedTime)
{
    new 
vault nvault_open("Played_Time")
    
    if(
vault == INVALID_HANDLE)
        
set_fail_state("nvault returned invalid handle")
    
    new 
szAuthID[33];
    new 
vaultkey[64], vaultdata[64];
    
    
get_user_authid(idszAuthIDcharsmax(AuthID))
    
    
format(vaultkey63"PLAYEDTIME%s"szAuthID); 
    
format(vaultdata63"%d"PlayedTime); 
    
    
nvault_set(vaultvaultkeyvaultdata);
    
nvault_close(vault);

to sqlvault
PHP Code:
public SaveTime(id,PlayedTime)
{
    
g_hVault sqlv_open_local("test")
    
    new 
szAuthID[33];
    new 
szKey[64], szData[64];
    
    
get_user_authid(idszAuthIDcharsmax(szAuthID))
    
    
format(szKeycharsmax(szKey), "PT%s"szAuthID); 
    
format(szDatacharsmax(szData), "%d"PlayedTime); 
    
    
sqlv_set_data(g_hVaultszKeyszData)
    
sqlv_close(g_hVault)
}
 
public 
LoadTime(id
{
    
g_hVault sqlv_open_local("test")
    
sqlv_connect(g_hVault);
    
    new 
szAuthID[33];
    new 
szKey[64], szData[64];
    
    
get_user_authid(idszAuthIDcharsmax(szAuthID));
    
    
format(szKeycharsmax(szKey), "PT%s"szAuthID);
    
    
sqlv_get_data(g_hVaultszKeyszDatacharsmax(szData))
    
    
sqlv_close(g_hVault)
    return 
str_to_num(szData);

Just testing it on Alka Played time plugin

Last edited by EpicMonkey; 04-06-2012 at 16:42.
EpicMonkey is offline
Exolent[jNr]
AMX Mod X Moderator
Join Date: Feb 2007
Location: Tennessee
Old 04-06-2012 , 17:30   Re: [INC] SQLVault
Reply With Quote #54

You don't want to open multiple times with SQLVault.
Open it on plugin start and close on plugin end.
Since you are doing 1 save at a time, you don't even need to manually connect.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-06-2012 , 19:56   Re: [INC] SQLVault
Reply With Quote #55

Quote:
Originally Posted by Exolent[jNr] View Post
You don't want to open multiple times with SQLVault.
Open it on plugin start and close on plugin end.
Since you are doing 1 save at a time, you don't even need to manually connect.
would it be safe to open it on plugin start and close it on plugin end?

Last edited by EpicMonkey; 04-06-2012 at 19:57.
EpicMonkey is offline
Exolent[jNr]
AMX Mod X Moderator
Join Date: Feb 2007
Location: Tennessee
Old 04-06-2012 , 20:40   Re: [INC] SQLVault
Reply With Quote #56

Yes.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-07-2012 , 04:16   Re: [INC] SQLVault
Reply With Quote #57

is there a way to make a top15 rank system with sqlvault?
EpicMonkey is offline
Exolent[jNr]
AMX Mod X Moderator
Join Date: Feb 2007
Location: Tennessee
Old 04-07-2012 , 13:45   Re: [INC] SQLVault
Reply With Quote #58

Use the sqlv_read_set() and sort by value.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-07-2012 , 15:15   Re: [INC] SQLVault
Reply With Quote #59

Quote:
Originally Posted by Exolent[jNr] View Post
Use the sqlv_read_set() and sort by value.
i see , ok ill do my end of the job and see if it works , thanks anyways
EpicMonkey is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-29-2012 , 13:27   Re: [INC] SQLVault
Reply With Quote #60

would this be the right way to save and load?
Just an ex :
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlvault>

#define PLUGIN "Random"
#define VERSION "1.0"
#define AUTHOR "Epic"

new randomdata[33], SQLVault:g_hVault;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_hVault sqlv_open_local("Test")
}

public 
plugin_end()
{
    
sqlv_close(g_hVault)
}

public 
client_disconnect(id)
{
    
Save(id)
}

public 
client_putinserver(id)
{
    
Load(id)
}

public 
Save(id)
{    
    new 
szAuthID[35], szKey[64],szData[256];
    
get_user_authid(idszAuthIDcharsmax(szAuthID))
    
    
format(szKeycharsmax(szKey), "R%s"szAuthID); 
    
format(szDatacharsmax(szData), "%d"randomdata[id]);
    
    
sqlv_set_data(g_hVaultszKeyszData)
    
    return 
PLUGIN_CONTINUE
}

public 
Load(id)
{    
    new 
szAuthID[35], szKey[64],szData[256];
    
get_user_authid(idszAuthIDcharsmax(szAuthID))
    
    
format(szKeycharsmax(szKey), "R%s"szAuthID);
    
sqlv_get_data(g_hVaultszKeyszDatacharsmax(szData))
    
    return 
str_to_num(szData);


Last edited by EpicMonkey; 04-29-2012 at 13:28.
EpicMonkey is offline
Reply


Thread Tools
Display Modes

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 03:57.


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