SA-MP Forums Archive
Wont save money - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wont save money (/showthread.php?tid=287784)



Wont save money - cruising - 04.10.2011

I cant figure this out why the script doesnt save the money, its the same principle to save admin lvls and that works fine, so why dont the money?

Code:
pawn Код:
enum pInfo
{
    Money,
    Admin,
};

public OnPlayerConnect(playerid)
{
    format(file, sizeof(file), "/Users/%s.ini", playername3);
    if (dini_Exists(file))
    {
        PlayerInfo[playerid][Admin] = dini_Int(file, "Admin");
        PlayerInfo[playerid][Money] = dini_Int(file, "Money");
    }
    return 1;
}

public OnPlayerRegister(playerid, password[])
{
     dini_IntSet(file, "Admin", PlayerInfo[playerid][Admin]);
     dini_IntSet(file, "Money", PlayerInfo[playerid][Money]);
}
    return 1;
}

public OnPlayerLogin(playerid,password[])
{
   PlayerInfo[playerid][Admin] = dini_Int(file, "Admin");
   PlayerInfo[playerid][Money] = dini_Int(file, "Money");
}
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(dini_Exists(file))
    {
        dini_IntSet(file, "Admin", PlayerInfo[playerid][Admin]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][Money]);
    }
    return 1;
}



Re: Wont save money - Tigerkiller - 04.10.2011

you load it correct but you forgot to set the money


Re: Wont save money - Scenario - 04.10.2011

You need to OBTAIN their money value before saving, otherwise you are saving whatever value the money variable holds if that makes sense...


Re : Wont save money - Naruto_Emilio - 04.10.2011

Why don't you use y_ini it's much better and faster to use...


Re: Re : Wont save money - Tigerkiller - 04.10.2011

Quote:
Originally Posted by Naruto_Emilio
Посмотреть сообщение
Why don't you use y_ini it's much better and faster to use...
why you dont use mysql ? its the fastes


Re: Re : Wont save money - Scenario - 04.10.2011

Quote:
Originally Posted by Tigerkiller
Посмотреть сообщение
why you dont use mysql ? its the fastes
No, MySQL is actually really slow compared to many other systems (including y_ini). As of right now, y_ini is the fastest INI-based system. File-functions are always faster than anything, but they don't offer as many features without slowing the system down.


Re : Re: Re : Wont save money - Naruto_Emilio - 04.10.2011

Quote:
Originally Posted by Tigerkiller
Посмотреть сообщение
why you dont use mysql ? its the fastes
You are wrong sir, it's not he fatest, it's the slowest* compared to y_ini.


Re: Wont save money - Tigerkiller - 04.10.2011

hmm ok never used y ini but i will try it

BACK TO TOPIC


Re: Re : Wont save money - Kush - 05.10.2011

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
No, MySQL is actually really slow compared to many other systems (including y_ini). As of right now, y_ini is the fastest INI-based system. File-functions are always faster than anything, but they don't offer as many features without slowing the system down.
As these file based systems (y_ini, dini, dof2) derive from the native file functions, this is true. The point of these INI Systems are merely for simplicity. Comparison in speed does play a major factor, as y_ini takes less time to do these 'operations' should I say.


Re: Wont save money - Steven82 - 05.10.2011

This is a REALLY easy fix..

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(dini_Exists(file))
    {
        dini_IntSet(file, "Admin", PlayerInfo[playerid][Admin]);
        dini_IntSet(file, "Money", GetPlayerMoney(playerid)); // Changed PlayerInfo[playerid][Money] to GetPlayerMoney(playerid);
    }
    return 1;
}