AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   FVAULT nullifies saved strings in txt problem (https://forums.alliedmods.net/showthread.php?t=325138)

hellmoss 06-09-2020 12:45

FVAULT nullifies saved strings in txt problem
 
[SOLVED]


Hello, I'm using an identical plugin to this one but instead of using parse i use str_to_num and instead of formatex, num_to_str. The plugin which stores only 1 variable in a txt and uses str to num/num to str hasn't had a problem in 10 years.

Using parse and formatex (I'm not really sure this is where the problem comes from)
Taken from my txt: "4h4" "0 1 1" 1591709213

The sequence becomes "0 0 0" but not at all times mainly when one uses 'retry' or map changes.
Again, a person may retry 10 times and still have no problem. Maps may change 5 times and still no problem. But I'm more prone to believe that something happens on map change.
The default sequence for a newcomer is "1 1 0". Even if they dont touch anything they would get their sequence nullified in some inexplicable occasion.

Tried with 3 people in server, spamming map change and people retrying, changing their sequence, not changing it, you name it. Most times it does save the sequence on loading data but sometimes it doesn't.. What gives???

Code:

#include <amxmodx>
#include <fvault>
#include <zpclass>

new const g_vault[] = "personal"

new g_cdown[33], g_usnd[33], g_wide[33]

public plugin_init()
        register_plugin("save personaliz.", "1.0", "h3LLm0sS")

public client_putinserver(id)
{
        //set_task(0.1, "Load", id)
        Load(id)
        //set_task(300.0, "Save", id, _, _, "b")
}

public Load(id)
{
        if(is_user_hltv(id) || is_user_bot(id) || !is_user_connected(id))
                return

        new data[6], name[32]
        get_user_name(id, name, charsmax(name))

        if(fvault_get_data(g_vault, name, data, charsmax(data)))
        {
                new tempvar1[10], tempvar2[10], tempvar3[10]
                parse(data, tempvar1, charsmax(tempvar1), tempvar2, charsmax(tempvar2), tempvar3, charsmax(tempvar3))

                g_cdown[id]=str_to_num(tempvar1)
                g_usnd[id]=str_to_num(tempvar2)
                g_wide[id]=str_to_num(tempvar3)

                setdata(id)
        }
}

public client_disconnected(id)
{
        getdata(id)

        new data[6], name[32]
        get_user_name(id, name, charsmax(name))

        formatex(data, charsmax(data), "%d %d %d", g_cdown[id], g_usnd[id], g_wide[id])
        fvault_set_data(g_vault, name, data)
}

public getdata(id)
{
        g_cdown[id]=zp_get_cdown1(id)
        g_usnd[id]=zp_get_usound(id)
        g_wide[id]=zp_get_fov(id)
}

public setdata(id)
{
        if(!g_cdown[id])
                zp_toggle_cdown1(id)

        if(!g_usnd[id])
                zp_ultimate_toggle(id)

        if(g_wide[id])
                zp_human_fov(id)
}


OciXCrom 06-09-2020 14:46

Re: FVAULT nullifies saved strings in txt problem
 
Load the data in client_connect() without any tasks.

hellmoss 06-09-2020 18:04

Re: FVAULT nullifies saved strings in txt problem
 
I tried but it doesn't seem to be the case :cry:

condoriano90 06-10-2020 05:34

Re: FVAULT nullifies saved strings in txt problem
 
Try logging (amx_log or something) after fvault_get_data and fvault_set_data and check the log files after a couple days to see when exactly the data becomes "0 0 0" then you can proceed from there

hellmoss 06-11-2020 05:24

Re: FVAULT nullifies saved strings in txt problem
 
Quote:

Originally Posted by condoriano90 (Post 2704918)
Try logging (amx_log or something) after fvault_get_data and fvault_set_data and check the log files after a couple days to see when exactly the data becomes "0 0 0" then you can proceed from there

Orgasm.

Problem was in client_disconnected() which calls a double save sometimes, and the second save has "0 0 0" sequence because it's getting in-game data for a client while he isn't in server so it probably returns 0. Also I would suspect client_disconnected() might be executed more than once to a player when they have to download a server resource on map change even if they're not a newcomer thus causing the problem there too.

OciXCrom 06-11-2020 05:47

Re: FVAULT nullifies saved strings in txt problem
 
Which AMXX version are you using?

hellmoss 06-11-2020 06:15

Re: FVAULT nullifies saved strings in txt problem
 
1.10.5388


All times are GMT -4. The time now is 17:48.

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