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

Solved fvault lost data problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 07-20-2021 , 08:48   fvault lost data problem
Reply With Quote #1

Example: I have 50 lives and my password is "red". Player B has 15 lives and his password is "green".
I don't know why, but sometimes when player B enters the server he will have 50 lives and his password will be "red". But the SETINFO_PASSWORD is "green" and therefore he can't login in his account. In the FVAULT the information changed so he lost all his data.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fvault>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new SZ_Password192 ]
new 
SZ_Password_T33 ][ 192 ]

new 
Registered33 ]
new 
BadPassword33 ]

new 
g_lifes[33]

new const 
Vault[] = "_datos"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /account""CMDRegister");
    
register_clcmd"EnterPassword""CMDIntroducirContrasenia" )
}

public 
client_putinserverid ){
 
Registered[id] = 0
BadPassword
[id] = 0
set_task
(2.0"Load"id)
}

public 
client_disconnectid ) {
        
    
Save(id);
}

public 
CMDRegister(id){
       
    if( 
Registeredid] == || BadPassword[id] == 1){
        return 
PLUGIN_HANDLED;
    }
    else{
        
client_cmdid"messagemode EnterPassword" )
    }
    return 
PLUGIN_CONTINUE;
}


public 
CMDIntroducirContraseniaid ){
    
    
read_argsSZ_Password191 )
    
remove_quotesSZ_Password )
    
trimSZ_Password )
    
    if( 
equalSZ_Password"" ) || containSZ_Password" ") != -1){
        return 
PLUGIN_HANDLED;
    }
    
    else { 
    
        
client_cmdid"setinfo _password ^"%s^""SZ_Password )
        
Registeredid ] = 1
        
static SZ_Name32 ], SZ_Data512 ]
        
get_user_nameidSZ_Name31 )
        
formatexSZ_DatacharsmaxSZ_Data ), "%s %d"SZ_Passwordg_lifes[id])
        
fvault_set_dataVaultSZ_NameSZ_Data )
        
SZ_Password_Tid ] = SZ_Password

        
return PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}

public 
Saveid ){
    
    if(
Registeredid ] == || BadPasswordid ] == 1){
        return 
PLUGIN_HANDLED;
    }

    else{
        static 
SZ_Data512 ], SZ_Name32 ]
    
        
formatexSZ_DatacharsmaxSZ_Data ), "%s %d"SZ_Password_Tid ], g_lifes[id])
        
get_user_nameidSZ_Name31 )
    
        
fvault_set_dataVaultSZ_NameSZ_Data )
    }
    return 
PLUGIN_CONTINUE;
}

public 
Loadid ){
    
    static 
SZ_Data512 ], SZ_Name32 ], SETINFO_Password191 ], VAULT_Password191 ], lifes[32]
    
    
get_user_nameidSZ_Name31 )
    
get_user_infoid"_password"SETINFO_Password190 )
    
    if( !
fvault_get_dataVaultSZ_NameSZ_DatacharsmaxSZ_Data ) ) ){
        return 
0;
    }
    
    
Registered[id] = 1
    parse
SZ_DataVAULT_Password190lifes31)
    
    if( 
equalSETINFO_PasswordVAULT_Password ) ){
        
        
SZ_Password_T[id] = SETINFO_Password
    
        g_lifes
[id] = str_to_num(lifes)
    
        return 
2;
    }
    else{ 
        
BadPasswordid ] = 1
    
}
    return 
1;


Last edited by The overrated maniac; 07-24-2021 at 18:59. Reason: Solved
The overrated maniac is offline
Dragos
Senior Member
Join Date: Oct 2018
Location: Romania
Old 07-20-2021 , 12:57   Re: fvault lost data problem
Reply With Quote #2

You don't have any specifications to load and save functions that determine who has what and how much. Like...
Save data with Name/SteamID/IP | password and life.
That's why everyone that will join your server will have the first line of saved data. meaning, everyone will have "red" as the password and 50 life.
__________________
sup

Last edited by Dragos; 07-20-2021 at 12:58.
Dragos is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 07-20-2021 , 13:26   Re: fvault lost data problem
Reply With Quote #3

Quote:
Originally Posted by Dragos View Post
You don't have any specifications to load and save functions that determine who has what and how much. Like...
Save data with Name/SteamID/IP | password and life.
That's why everyone that will join your server will have the first line of saved data. meaning, everyone will have "red" as the password and 50 life.
No, its not the first line, its like someone on random line will have the same things that someone on another random line. I can post when I save and load the data if you are talking about that.
Also I think the key is the name.

Last edited by The overrated maniac; 07-20-2021 at 13:29.
The overrated maniac is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 07-20-2021 , 14:29   Re: fvault lost data problem
Reply With Quote #4

Probably will not solve the prob, but you missing here charsmax:

Code:
parse( SZ_Data, VAULT_Password, 190, lifes)
    
->

parse( SZ_Data, VAULT_Password, 190, lifes, charsmax( lifes ) )
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 07-20-2021 , 14:44   Re: fvault lost data problem
Reply With Quote #5

Quote:
Originally Posted by JocAnis View Post
Probably will not solve the prob, but you missing here charsmax:

Code:
parse( SZ_Data, VAULT_Password, 190, lifes)
    
->

parse( SZ_Data, VAULT_Password, 190, lifes, charsmax( lifes ) )
Everything helps, thanks. The charsmax is 31 and I have it in the original code, I just copyed it bad when posting here.

Last edited by The overrated maniac; 07-20-2021 at 20:55.
The overrated maniac is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 07-22-2021 , 05:40   Re: fvault lost data problem
Reply With Quote #6

Okay I got the problem, but I dont know how to fix it:

When a player leave, the next player who join have their account stats. (It dosnt happens everytime, only sometimes)

Last edited by The overrated maniac; 07-22-2021 at 08:30.
The overrated maniac is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-22-2021 , 08:57   Re: fvault lost data problem
Reply With Quote #7

You should reset g_lifes(for example set g_lifes[id] = 0 or another appropriate value) in a place like client_connect.
__________________
HamletEagle is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 07-22-2021 , 09:00   Re: fvault lost data problem
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
You should reset g_lifes(for example set g_lifes[id] = 0 or another appropriate value) in a place like client_connect.
Thanks that was really dumb, my bad.

If everything works okay I'll close the thread.

Last edited by The overrated maniac; 07-22-2021 at 09:09.
The overrated maniac 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 14:19.


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