Raised This Month: $32 Target: $400
 8% 

save data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-23-2020 , 05:14   save data
Reply With Quote #1

can I get an example of save & load player data in nvault
PHP Code:
gXP[32];
gLevel[32];
gClass[32]; 
LoadData(id)
SaveData(id)
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-23-2020 , 05:32   Re: save data
Reply With Quote #2

Here's an example, also check this out: https://forums.alliedmods.net/showthread.php?t=91503

PHP Code:
public client_disconnect(id)
{
    new 
szAuth[35], szTemp[60]; 
    
get_user_authid(idszAuthcharsmax(szAuth));
    
    
formatex(szTempcharsmax(szTemp), "%i %i %i"iPoints[id], iTsKilled[id], iCtKilled[id]);
    
    
nvault_set(szVaultNameszAuthszTemp);
}

public 
client_authorized(id)
{
    new 
szAuth[35], szTemp[20], szTsKills[5], szCtKills[5], szPoints[10];
    
get_user_authid(idszAuthcharsmax(szAuth));
    
    
nvault_get(szVaultNameszAuthszTempcharsmax(szTemp));
    
    
parse(szTempszPointscharsmax(szPoints), szTsKillscharsmax(szTsKills), szCtKillscharsmax(szCtKills));
    
    
iPoints[id] = str_to_num(szPoints);
    
iTsKilled[id] = str_to_num(szTsKills);
    
iCtKilled[id] = str_to_num(szCtKills);

__________________

Last edited by Napoleon_be; 01-23-2020 at 05:33.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-23-2020 , 09:11   Re: save data
Reply With Quote #3

Do i need to do formatex ? when loading data?
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-23-2020 , 09:41   Re: save data
Reply With Quote #4

Not if u do it this way, bugsy & ocixcrom have been helping me with this method and i would recomend using it
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 01-23-2020 , 11:19   Re: save data
Reply With Quote #5

I think it works like that too, I haven't tested it.

PHP Code:
#include <nvault_array>

enum _:Data
{
    
iPoints,
    
iTsKilled,
    
iCtKilled
}

new 
iData[33][Data]

public 
client_disconnect(id)
{
        new 
szAuth[35]
        
get_user_authid(idszAuthcharsmax(szAuth));
    
        
nvault_set_array(NameVaultszAuthiData[id][Data:0], sizeof(iData[]));
}

public 
client_authorized(id)
{
        new 
szAuth[35]
        
get_user_authid(idszAuthcharsmax(szAuth));
    
        
nvault_get_array(NameVaultszAuthiData[id][Data:0], sizeof(iData[]));

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 01-25-2020 at 15:08.
iceeedr is offline
Send a message via Skype™ to iceeedr
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-23-2020 , 18:29   Re: save data
Reply With Quote #6

Quote:
Originally Posted by Sanjay Singh View Post
Do i need to do formatex ? when loading data?
Think about it. Why would you format a string when loading it? Loading a string gets the data from the vault file and puts it into a string. So now you have a string with values that you want to put into variables so they can be used in your plugin.

It's when you save that you need format, because you have variables with data that you need to put into a string so it can be saved into a single vault record...which can later be loaded back into variables.

Data to be saved (each in their own variable): 1 , 2 , 3
Formatted so it can be saved into the vault "1 2 3"

Data loaded from vault "1 2 3"
Parse values back into variables: 1 , 2 , 3

I recommend you study some plugins and code that is posted on the forums to help you better understand.
__________________

Last edited by Bugsy; 01-23-2020 at 18:30.
Bugsy is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-24-2020 , 03:11   Re: save data
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
Think about it. Why would you format a string when loading it? Loading a string gets the data from the vault file and puts it into a string. So now you have a string with values that you want to put into variables so they can be used in your plugin.

It's when you save that you need format, because you have variables with data that you need to put into a string so it can be saved into a single vault record...which can later be loaded back into variables.

Data to be saved (each in their own variable): 1 , 2 , 3
Formatted so it can be saved into the vault "1 2 3"

Data loaded from vault "1 2 3"
Parse values back into variables: 1 , 2 , 3

I recommend you study some plugins and code that is posted on the forums to help you better understand.
Yea i never used nvault before but now I am using it and working fine without errors.
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
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 17:49.


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