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

nVault weird saving


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 03-25-2020 , 08:39   nVault weird saving
Reply With Quote #1

Hello,
I made a plugin which is supposed to saving/loading players data from nVault (name saving data).
Code for saving data:
PHP Code:
SaveDATAid 

    new 
szName32 
    
get_user_nameidszNamecharsmaxszName ) ) 
    
    new 
szVaultKey128 ], szVaultData512 
    
    
formatexszVaultKey127"%s-/"szName 
    
formatexszVaultData511"%i %i %i %i %i %i %i %i"Data[id],Kills[id],Deaths[id],Shots[id],Damage[id],Hits[id],Rank[id], Skill[id]) 
    
nvault_setg_nVaultszVaultKeyszVaultData 

Code for loading data:
PHP Code:
LoadDATAid 

    new 
szName32 
    
get_user_nameidszNamecharsmaxszName ) ) 

    new 
szVaultKey128 ], szVaultData512 

    
formatexszVaultKey127"%s-/"szName 
    
formatexszVaultData511"%i %i %i %i %i %i %i %i"Data[id],Kills[id],Deaths[id],Shots[id],Damage[id],Hits[id],Rank[id], Skill[id]) 

    
nvault_getg_nVaultszVaultKeyszVaultData511 

    new 
did[32],dkills[32],ddeaths[32],dshots[32],ddamage[32],dhits[32],drank[32],dskill[32]

    
parseszVaultDatadid31,dkills31,ddeaths31dshots31ddamage31dhits31 ,drank31dskill31

    
Dataid ] = str_to_numdid)
    
Killsid ] = str_to_numdkills
    
Deaths[id] = str_to_numddeaths)
    
Shots[id] = str_to_numdshots)
    
Damage[id] = str_to_numddamage)
    
Hits[id] = str_to_numdhits)
    
Rank[id] = str_to_numdrank)
    
Skill[id] = str_to_numdskill)
    

The problem is that these data keep switching between players.
If I make saving on authid, it's everything ok, but I want to keep this name saving.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-25-2020 , 08:42   Re: nVault weird saving
Reply With Quote #2

What's the point of the "%s-/" ?

What do you mean by "switching between players"? If it doesn't save them correctly, you're passing in the wrong id. Show the full function calls.
__________________

Last edited by OciXCrom; 03-25-2020 at 08:42.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 03-25-2020 , 10:08   Re: nVault weird saving
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
What's the point of the "%s-/" ?

What do you mean by "switching between players"? If it doesn't save them correctly, you're passing in the wrong id. Show the full function calls.
The "%s-/" is the name stored in the vault.
The data is stored correctly for about 4 days, then it is going crazy.
Ex:
Player Adi has 5 kills and 3 deaths.
Player Random has 2 kills and 10 deaths.
After about 4 days, the player Adi have 2 kills and 10 deaths, and the player Random have 5 kills and 3 deaths.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 03-25-2020 at 10:11.
Shadows Adi is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 03-25-2020 , 10:16   Re: nVault weird saving
Reply With Quote #4

Quote:
Originally Posted by Shadows Adi View Post
The "%s-/" is the name stored in the vault.
The data is stored correctly for about 4 days, then it is going crazy.
Ex:
Player Adi has 5 kills and 3 deaths.
Player Random has 2 kills and 10 deaths.
After about 4 days, the player Adi have 2 kills and 10 deaths, and the player Random have 5 kills and 3 deaths.
show the full code
__________________
JusTGo is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-25-2020 , 11:52   Re: nVault weird saving
Reply With Quote #5

This is a working example i made a few months ago, this has been posted before on the forums by myself and could easily been searched for. Here's the example you can use

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);

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 03-25-2020 , 12:50   Re: nVault weird saving
Reply With Quote #6

PHP Code:
enum _:enData
{
    
Data,
    
Kills,
    
Deaths,
    
Shots,
    
Damage,
    
Hits,
    
Rank,
    
Skill
    PlayerName
[MAX_NAME_LENGTH],
}
new 
szVault
new GetAuth[MAX_PLAYERS 1][MAX_AUTHID_LENGTH]
new 
iData[MAX_PLAYERS 1][enData]

public 
plugin_init()
{
    
register_forward(FM_ClientUserInfoChanged"ClientUserInfoChanged")
}

public 
plugin_cfg()
{
    
szVault nvault_open("Mission_VAULT")
}

public 
plugin_end()
{
    
nvault_close(szVault)
}

public 
ClientUserInfoChanged(id)
{
    new 
szOldName[MAX_PLAYERS]
    
get_user_name(idszOldNamecharsmax(szOldName))

    if(
szOldName[0])
    {                   
        new 
szNewName[MAX_PLAYERS]
        
get_user_info(id"name"szNewNamecharsmax(szNewName))

        
set_user_info(id"name"szNewName)

        
copy(iData[id][PlayerName], charsmax(iData[]), szNewName)
        
SaveData(id)
    }
    
    return 
FMRES_SUPERCEDE
}

public 
client_authorized(id, const authid[])
{
    
get_user_authid(idGetAuth[id], MAX_AUTHID_LENGTH 1)
    
get_user_name(idiData[id][PlayerName], MAX_NAME_LENGTH 1)
    
LoadData(id)
}

public 
client_disconnected(id)
{
    
SaveData(id)
}

public 
example(id)
{
    
iData[id][Kills]++
}

public 
SaveData(const index)
{
    
nvault_set_array(szVault GetAuth[index], iDataindex ][enData:0], sizeofiData[] ) )
}

public 
LoadData(const index)
{
    
nvault_get_arrayszVault GetAuth[index] , iDataindex ][enData:0] , sizeofiData[] ))

__________________


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; 03-25-2020 at 13:56.
iceeedr is offline
Send a message via Skype™ to iceeedr
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 03-25-2020 , 13:04   Re: nVault weird saving
Reply With Quote #7

I got it, but on authid it is working very well, when I change Vaul saving / loading on name it get bugged.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 03-25-2020 , 13:06   Re: nVault weird saving
Reply With Quote #8

Quote:
Originally Posted by Shadows Adi View Post
I got it, but on authid it is working very well, when I change Vaul saving / loading on name it get bugged.
It's a simple problem, use authid.
__________________


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/
iceeedr is offline
Send a message via Skype™ to iceeedr
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 03-25-2020 , 13:48   Re: nVault weird saving
Reply With Quote #9

Quote:
Originally Posted by iceeedr View Post
It's a simple problem, use authid.
I want to make it saving on name, because it's a top plugin, and players uses different names on the server.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 03-25-2020 at 13:55.
Shadows Adi is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 03-25-2020 , 13:56   Re: nVault weird saving
Reply With Quote #10

Updated previous script, not tested.
__________________


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/
iceeedr is offline
Send a message via Skype™ to iceeedr
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 10:38.


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