[HELP] Saving gettime() to INI_WriteInt
#1

Hello, i have problem with saving gettime function to INI_WriteInt or INI_WriteString.

When i use INI_WriteInt it saves strictly "0" to the file...

Код:
//Somewhere in my code
SomeInfo[1][SomeInfoExpire] = gettime + 7 * 86400; // 7 days expire

//Under my saving function
INI_WriteInt("SomeInfoExpire", SomeInfoExpire]);
When i use INI_WriteString it saves some random character (example: L or Й)

Код:
//Somewhere in my code
SomeInfo[1][SomeInfoExpire] = gettime + 7 * 86400;
//Under my saving function
INI_WriteString("SomeInfo", SomeInfoExpire]);
I searched about this problem and i found this thread:

https://sampforum.blast.hk/showthread.php?tid=540603

But this did not help me at all...
If anybody can tell what should i change in y_ini or what to do i be happy.

__________________________________________________ _________________________________________

I have another questions about gettime()

When i store gettime to my ini file, so i can set EXPIRE time on something:

How can i check when it's actually expired?
How the file know that there is 0 instead of 7 * 86400; (7 days expire) after 7 days?
How can i sendclientmessage when it's expired and also send it if player get connected after expire?


__________________________________________________ _________________________________________

Thank you so much for any idea!
Reply
#2

Try to find an include like timestamptodate, or something like.
Or use getdate and gettime.
Reply
#3

Quote:
Originally Posted by Florin48
Посмотреть сообщение
Try to find an include like timestamptodate, or something like.
I don't want to use another include... I need to fix the actual one: y_ini so it can handle gettime.

Quote:
Originally Posted by Florin48
Посмотреть сообщение
Or use getdate and gettime.
That's what i'am trying to do
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
The code in the first post isn't even valid syntax, you need to post your exact code.
Код:
//_____________________TOP_____________________ //

#define MAX_INFOS 50
#define SOMEDIALOG 1000

new SomeInformation[MAX_INFOS][SomeInfo];

enum SomeInfo
{
    SomeExpire
}

//_______________ONGAMEMODEINIT_______________ //

INI_ParseFile("SomeInfoFolder/SI1.ini", "LoadSI1_data", .bPassTag = true);


//_______________ONDIALOGRESPONSE_______________ //

...

case DIALOG_PROPS_1:
{

    if(!response)SetPlayerPos(playerid,0,0,0);
    if(response)

    SomeInformation[1][SomeExpire] = (gettime() + ConvertToSeconds(.months = 0, .days = 7, .hours = 0, .seconds = 0));

    SaveSI1Data();

}

...




//___________________SAVING_____________________//


forward SaveSI1Data();
public SaveSI1Data()
{


	new INI:inisi1o = INI_Open("SomeInfoFolder/SI1.ini");
	INI_WriteInt(inisi1o,"SomeExpire", SomeInformation[1][SomeExpire]);
	INI_Close(inisi1o);

	return 1;
}

//___________________LOADING___________________ //

forward LoadSI1_data(tag[], name[], value[]);
public LoadSI1_data(tag[], name[], value[])
{
	
	INI_Int("SomeExpire", SomeInformation[1][SomeExpire]);
	return 1;

}
//________________ConvertToSeconds________________//

stock ConvertToSeconds(years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0)
{
    new time = 0;
    time += (years * 31536000); 
    time += (months * 2592000);
    time += (days * 86400);
    time += (hours * 3600);
    time += (minutes * 60);
    time += seconds;
    return time;
}

//______________________________________________//


This saves SomeInformation[1][SomeExpire] as 0.
Reply
#5

BUMP
Reply
#6

I understand, but how can this help me to solve my problem with gettime() saving?
Reply
#7

It's just about some lines ...

Set the value:
Код:
SomeInformation[1][SomeExpire] = (gettime() + ConvertToSeconds(.months = 0, .days = 7, .hours = 0, .seconds = 0));
Save the value:
Код:
INI_WriteInt(inisi1o,"SomeExpire", SomeInformation[1][SomeExpire]);
Load the value:
Код:
INI_ParseFile("SomeInfoFolder/SI1.ini", "LoadSI1_data", .bPassTag = true);
Whatever about the tag, it saves and loads everything but it does not save getttime();

__________________________________________________ __________________________________________

https://sampforum.blast.hk/showthread.php?tid=570957

Load a whole file at once:

Код:
forward LoadOneFile(tag[], name[], value[]);
public LoadOneFile(tag[], name[], value[])
{
}
Код:
INI_ParseFile("myini.ini", "LoadOneFile", .bPassTag = true);
__________________________________________________ __________________________________________

EDIT:

I leaved tag at all and tried to save and load without tag. Still does not write gettime() ...
It writes everything right but not gettime()... The value is not 0, the value is not even writed, replaced or anything...
Reply
#8

There must be something wrong with my include ..
Maybe?
Reply
#9

2 pages just for saving a 9 chars function, seriously switch to MySQL for the sake of this forum.

You'll get more problems when your gamemode will be bigger.
Reply
#10

Well, but i still can't get why everything works well but this gettime() does not save ...

The wired thing is that when i try to save gettime(), it stop saving everything else. Nothing saves.
When i remove it, the it work again...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)