PDA

View Full Version : Gettime


SpaceRP
20/12/2016, 10:05 PM
Hey guys

How to save gettime() in the format Y_ini?

INI_WriteInt - does not work

new time = gettime() + (month*2592000);

PlayerInfo[giveplayerid][pATime] = time;

...

INI_WriteInt(File, "ATime", PlayerInfo[playerid][pATime]);

Does not work

JaKe Elite
20/12/2016, 10:26 PM
It should work since gettime() returns the Unix Timestamp which is an integer, Unless you are saving it wrong.

Try this perhaps?


INI_WriteInt(File, "ATime", PlayerInfo[giveplayerid][pATime]);


You are saving it to playerid not to giveplayerid?

SpaceRP
20/12/2016, 10:31 PM
This is in command

new time = gettime() + (month*2592000);

PlayerInfo[giveplayerid][pATime] = time;

and this under public SaveAcc(playerid)

INI_WriteInt(File, "ATime", PlayerInfo[playerid][pATime]);

JaKe Elite
20/12/2016, 10:35 PM
This is in command

new time = gettime() + (month*2592000);

PlayerInfo[giveplayerid][pATime] = time;

and this under public SaveAcc(playerid)

INI_WriteInt(File, "ATime", PlayerInfo[playerid][pATime]);

Maybe SaveAcc isn't being called? Try saving the player's account after using that command perhaps like for example


new time = gettime() + (month*2592000);
// Your codes here
PlayerInfo[giveplayerid][pATime] = time;
SaveAcc(giveplayerid);


Try debugging SaveAcc and see if it really works (Printing out, etc)

SpaceRP
20/12/2016, 10:38 PM
I tried but it does not work, do not invite the saveacc as if crash to y_ini

JaKe Elite
20/12/2016, 10:43 PM
I tried but it does not work, do not invite the saveacc as if crash to y_ini

Well that explains it, If you places SaveAcc on the command and it crashes then that means SaveAcc isn't working? Can you show us how you scripted SaveAcc?

SpaceRP
20/12/2016, 10:47 PM
public SaveAcc(playerid)
{
if(Logged[playerid] == 1)
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"ATime",PlayerInfo[playerid][pATime]);

...

INI_Close(File);
}
return 1;
}

Konstantinos
20/12/2016, 10:47 PM
Update to YSI 4 (http://forum.sa-mp.com/showpost.php?p=3709099&postcount=2). Native valstr crashes the server for high values.

SpaceRP
20/12/2016, 11:12 PM
I put all this now and again does not save GetTime

Hayden_Almeida
21/12/2016, 04:04 AM
I put all this now and again does not save GetTime

Do you want to save TIMESTAMP, right?

SpaceRP
21/12/2016, 11:16 AM
Yes timestamp

Hayden_Almeida
21/12/2016, 09:24 PM
Yes timestamp

new Hour, Minute, Second, Timestamp;
Timestamp = gettime(Hour, Minute, Second);

PlayerInfo[playerid][pTIME] = Timestamp;