AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved fvault lost data problem (https://forums.alliedmods.net/showthread.php?t=333538)

The overrated maniac 07-20-2021 08:48

fvault lost data problem
 
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;



Dragos 07-20-2021 12:57

Re: fvault lost data problem
 
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.

The overrated maniac 07-20-2021 13:26

Re: fvault lost data problem
 
Quote:

Originally Posted by Dragos (Post 2753238)
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.

JocAnis 07-20-2021 14:29

Re: fvault lost data problem
 
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 ) )


The overrated maniac 07-20-2021 14:44

Re: fvault lost data problem
 
Quote:

Originally Posted by JocAnis (Post 2753241)
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.

The overrated maniac 07-22-2021 05:40

Re: fvault lost data problem
 
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)

HamletEagle 07-22-2021 08:57

Re: fvault lost data problem
 
You should reset g_lifes(for example set g_lifes[id] = 0 or another appropriate value) in a place like client_connect.

The overrated maniac 07-22-2021 09:00

Re: fvault lost data problem
 
Quote:

Originally Posted by HamletEagle (Post 2753362)
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.


All times are GMT -4. The time now is 02:38.

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