Raised This Month: $ Target: $400
 0% 

Retrieve txt file content in console


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-18-2013 , 14:55   Re: Retrieve txt file content in console
Reply With Quote #1

There's no difference between a .ini file and a .txt other than the assumed contents. Why do you need to copy it? There are functions created in the Code Snippets/Tutorials forum to do this.

Anyways, there were many things wrong with the code that you created, too many for me to write up right now. Here is a quick fix that I did for you. It's untested and with no guarantees.

Code:
#include <amxmodx>
#include <amxmisc>

new szFDataBuffer[1000][512]
new iLineCount = 0
new iPrintCount[33]

public plugin_init()
{
	register_plugin("Print File to Console", "0.1", "Hello World")
	register_clcmd("amx_evs", "evs")
}

public plugin_cfg()
{
	new szFilename[128]
	get_datadir(szFilename, charsmax(szFilename))
	format(szFilename, sizeof (szFilename), "%s/hihi.txt", szFilename)
	
	new file = fopen(szFilename, "rt")
	while(!feof(file))
	{
		fgets(file, szFDataBuffer[iLineCount], charsmax(szFDataBuffer[]))
		trim(szFDataBuffer[iLineCount])
		iLineCount++
	}
	fclose(file)
}

public evs(id)
{    
	iPrintCount[id] = 0
	client_print(id, print_console, "===========================")
	set_task(0.1, "evs_print", id, _, _, "a", iLineCount)
	return PLUGIN_CONTINUE
}

public evs_print(id)
{	
	client_print(id, print_console, "%d) %s", iPrintCount[id] + 1, szFDataBuffer[iPrintCount[id]])
	iPrintCount[id]++
}
__________________
fysiks is offline
Reply



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 20:27.


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