Playing time keeps resetting on connect.
#1

Hi, I am using Y_INI for this and follow the 2nd post in this topic https://sampforum.blast.hk/showthread.php?tid=284740
I just have no idea where to put the saving and loading function, everytime I do that, the minutes,hours and seconds reset on connect, can I have some help please

I am using this
forward TimeOnServer(playerid);
public TimeOnServer(playerid)
{
PlayerInfo[playerid][Sec] ++;
if(PlayerInfo[playerid][Sec]>=60)
{
PlayerInfo[playerid][Min]++;
PlayerInfo[playerid][Sec]=0;
}
if(PlayerInfo[playerid][Min]>=60)
{
PlayerInfo[playerid][Min]=0;
PlayerInfo[playerid][Hour]++;
}
}

I have no idea where to put
PlayerInfo[playerid][Min] = GetPVarInt(playerid, "Min");
PlayerInfo[playerid][Hour] = GetPVarInt(playerid, "Hour");
PlayerInfo[playerid][Sec] = GetPVarInt(playerid, "Sec");


INI_WriteInt(File,"Min",PlayerInfo[playerid][Min]);
INI_WriteInt(File,"Hour",PlayerInfo[playerid][Hour]);
INI_WriteInt(File,"Sec",PlayerInfo[playerid][Sec]);
Reply
#2

Have you tried to the real Y INI tutorial? (but read all and you will understand what you doing wrong.)
https://sampforum.blast.hk/showthread.php?tid=175565
Reply
#3

I actually have, I understand how to use Y_INI for everything else, its just that when I put the saving and loading areas in the correct areas its just that when the player reconnects all the values on the time return to 0 everything else loads correctly., im asking on how to fix that so that it loads back up on the player connecting.
Reply
#4

Show me the public LoadUser_%s...
Show me your save public/stock

P.S: I use in my server with Y_INI and it works perfect.
Reply
#5

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Score",PlayerInfo[playerid][pScore]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Team",pTeam[playerid]);
INI_Int("Job",pJob[playerid]);
PlayerInfo[playerid][Min] = GetPVarInt(playerid, "Min");
PlayerInfo[playerid][Hour] = GetPVarInt(playerid, "Hour");
PlayerInfo[playerid][Sec] = GetPVarInt(playerid, "Sec");
return 1;
}

INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)) ;
INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Team",pTeam[playerid]);
INI_WriteInt(File,"Job",pJob[playerid]);
INI_WriteInt(File,"Min",PlayerInfo[playerid][Min]);
INI_WriteInt(File,"Hour",PlayerInfo[playerid][Hour]);
INI_WriteInt(File,"Sec",PlayerInfo[playerid][Sec]);
INI_Close(File);

^^^^^ This is set under OnPlayerDisconnect
Reply
#6

Lol, PVars was my problem too a few weeks ago

Just do this public LoadUser_data

Код:
INI_Int("Min",PlayerInfo[playerid][Min]);
INI_Int("Hour",PlayerInfo[playerid][Hour]);
INI_Int("Sec",PlayerInfo[playerid][Sec]);
OnPlayerDisconnect:

Код:
PlayerInfo[playerid][Min] = GetPVarInt(playerid, "Min");
PlayerInfo[playerid][Hour] = GetPVarInt(playerid, "Hour");
PlayerInfo[playerid][Sec] = GetPVarInt(playerid, "Sec");
INI_WriteInt(File,"Min",PlayerInfo[playerid][Min]);
INI_WriteInt(File,"Hour",PlayerInfo[playerid][Hour]);
INI_WriteInt(File,"Sec",PlayerInfo[playerid][Sec]);
Almost exactly the opposite :P
Reply
#7

What should I do now if the minutes,seconds,hours do not go up in the UserFiles?They all just stay 0 now.
Reply
#8

Quote:
Originally Posted by gtasarules14
Посмотреть сообщение
What should I do now if the minutes,seconds,hours do not go up in the UserFiles?They all just stay 0 now.
public TimeOnServer - are you using PVars on this public?
Reply
#9

No, I am sorry, How would I do the PVars on this public? It would be greatly appreciated
Reply
#10

I figured it out now , thank you very much, Repped +1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)