reload script didn't save the data after rejoin

Started by Nihongo^, Sep 01, 2023, 06:37 PM

Previous topic - Next topic

Nihongo^

Hi, i just tried this function to reload my script https://forum.vc-mp.org/index.php?topic=9251.msg53101#msg53101

but the problem is its wont save the data after the player rejoin
In this pic i killed my self after reload the script but it didn't save the data "death" in the database
 


P.S I only add onPlayerCommand, getOnlinePlayers,getPlayer(object)  and ignore the rest

"In main.nut"



Mohamed Boubekri

You need to explain more about your problem, and show us your onplayerdeath & onplayerpart functions.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

2b2ttianxiu

u can try use me reload script code(not raw reload)

VEGETAZ

I do Not recommand to use that function. It will cause bug.
Manually restarting would be best.
ps. Are you Japanese?

2b2ttianxiu

I have question. Do you change your content?

if maybe
please take your code to me
i need check it

PSL

I'll try to fix his instructions, see if I can help you. I added the onPlayerPart event to simulate the player quitting.
if (cmd == "reload") {
    local loaded = []
    foreach (v in getOnlinePlayers())
   {
        if (getPlayer(v.ID) != null && getPlayer(v.ID).Spawned)
        {
                 loaded.append(getPlayer(v.ID))
        }
    }
    for(local i=0;i<100;i++)
    {
        local plr=FindPlayer(i);
        if(plr)
        {
            onPlayerPart(plr,1);
        }
    }
    onServerStop();
    dofile("main.nut") // your main script.
    onScriptLoad()
    foreach (b in getOnlinePlayers()) {
        onPlayerJoin(getPlayer(b.ID))
    }
    foreach (plr in loaded) {
        onPlayerRequestClass(plr, plr.Class, plr.Team, plr.Skin)
        if (plr.IsSpawned) onPlayerSpawn(plr)
    }
    AnnounceAll("Reloaded.", 0)
    return 1;
}