Quote:
Originally Posted by HamletEagle
Work with timestamps. Read the date from file and use parse_time on it, this will return the corresponding timestamp. Then, use get_systime to get the current time stamp and compare this two.
|
Let me try real quick
Edit: It still doesn't work.
Here is the full plugin:
Code:
#include <amxmodx>
new GatherData[3][17]
new GatherOra[3][17]
public plugin_init()
{
register_plugin("Test", "0.1", "ATudor");
set_task(0.3,"CheckFile",5000)
set_task(1.0,"CheckDateAndTime",7000)
}
public CheckFile()
{
new dir[33]
get_configsdir(dir,charsmax(dir))
new FILE[65]
format(FILE,charsmax(FILE),"%s/LaLeaganeGather.txt",dir)
if(!file_exists(FILE))
{
write_file(FILE,"; Exemplu adaugare data: 08/01/2019",0)
write_file(FILE,"; Pentru a adauga un interval orar, scrie doar ora inceperii gather-ului.",1)
write_file(FILE,"; Exemplu: Linia 1 08/01/2019 Linia 2 19:30",2)
write_file(FILE,"; Echipa LaLeagane va ureaza distractie placuta tuturor!")
log_amx("Nu am gasit fisierul pentru Gather, asa ca am creat noi unul!")
return PLUGIN_HANDLED
}
new ReadData = 0
new Dataitem = 0
new Houritem = 0
new f = fopen(FILE,"r")
while(!feof(f))
{
new szLine[17]
fgets(f,szLine,charsmax(szLine))
if(!szLine[0] || szLine[0] == ';')
{
continue;
}
if(Dataitem >= 3 || Houritem >= 3)
{
log_amx("Ai introdus mai mult de 3 dati in fisierul LaLeaganeGather")
break;
}
if(ReadData == 0)
{
parse_time(szLine,"%d/%m/%Y",-1)
format(GatherData[Dataitem],16,"%d",szLine)
Dataitem += 1
ReadData = 1
}
else
{
format(GatherOra[Houritem],16,"%s",szLine)
Houritem += 1
ReadData = 0
}
}
fclose(f)
return PLUGIN_HANDLED
}
public CheckDateAndTime()
{
new Datacurenta[17]
format(Datacurenta,16,"%d",get_systime(0))
//get_time("%d/%m/%Y",DataCurenta,charsmax(DataCurenta))
log_amx("%d - systime",get_systime(0))
log_amx("%s - Datacurenta",Datacurenta)
for(new i = 0; i < 3; i++)
{
log_amx("%s - %d",GatherData[i],i)
if(strcmp(GatherData[i],Datacurenta) == 0)
{
log_amx("Datile corespund!")
}
else
{
log_amx("Datile nu corespund!")
}
}
}