Raised This Month: $ Target: $400
 0% 

Help reading file and date


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
TudorLaLeagane
Junior Member
Join Date: Mar 2018
Old 01-07-2019 , 16:07   Re: Help reading file and date
Reply With Quote #5

Code:
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 > 2 || Houritem > 2)
		{
			log_amx("Ai introdus mai mult de 3 dati in fisierul LaLeaganeGather")
		}
		if(ReadData == 0)
		{
			format(GatherData[Dataitem],16,"%s",szLine)
			Dataitem += 1
			ReadData = 1
		}
		else
		{
			format(GatherOra[Houritem],16,"%s",szLine)
			Houritem += 1
			ReadData = 0
		}
	}
	// DEBUG
	for(new i = 0; i < 3; i++)
	{
		log_amx("%s - Data",GatherData[i])
		log_amx("%s - Ora",GatherOra[i])
	}
	return PLUGIN_HANDLED
}

here is the File i have, this part works, but i don't know how to take current server date...

EDIT: Here is the code that is checking the dates, but, somehow, it says that the strings don't match...
Code:
public CheckDateAndTime()
{
	new DataCurenta[16] 
	get_time("%d/%m/%Y",DataCurenta,charsmax(DataCurenta))
	log_amx("%s",DataCurenta)
	for(new i = 0; i < 3; i++)
	{
		log_amx("%s - %d",GatherData[i],i)
		if(strcmp(GatherData[i],DataCurenta) == 0)
		{
			log_amx("1")
		}
		else
		{
			log_amx("0")
		}
	}
}
Here is the file:
Code:
07/01/2019
5995:4000
09/01/2019
6000

Last edited by TudorLaLeagane; 01-07-2019 at 16:46.
TudorLaLeagane is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode