Raised This Month: $ Target: $400
 0% 

Retrieve txt file content in console


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Ev1scerator
Junior Member
Join Date: Mar 2011
Old 12-18-2013 , 10:47   Retrieve txt file content in console
Reply With Quote #1

Hello guys , i need help with a plugin to retrieve the content of a txt file to the console instead of using motd.

Say for example i have the following plugin :
Code:
#include <amxmodx>
#include <amxmisc>

public say_motd(id)
{
    show_motd(id, "motd.txt", "Message of the Day")
    return PLUGIN_HANDLED
}

public say_admins(id)
{
    new szFileDir[64]
    get_configsdir( szFileDir, 63 )
    format( szFileDir, 63, "%s/admin.txt", szFileDir )
    show_motd(id, szFileDir, "All Admins")
    return PLUGIN_HANDLED
}

public plugin_init()
{
    register_plugin("say /motd", "0.2", "Nightscream")
    register_clcmd("say /motd", "say_motd")
    register_clcmd("say /admins", "say_admins")
}
It displays the content of admin.txt using MOTD.

All is good, but is there a way to write it to console , just as you use rcon motdfile name then rcon motd ??
I need a plugin in the form of one command (ex: amx_retrieve , without any other argument) that will write a certain txt file to my console (even if it has over 100 lines and takes longer).
The txt file that will be displayed is to be specified in the plugin body.


And i have one more question ....can an .ini file be dumped as output to a .txt file ?
Plugin reads .ini file and copies all , creates .txt file and pastes.
Maybe i'm asking too much , i dunno



LE : After some searching , found and tried to create the plugin i wanted from another plugin's code :
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Blabla"
#define VERSION "2.0"
#define AUTHOR "Evs"

new szFDataBuffer[3000][512], tmpi


public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("amx_evs", "evs")
}

public evs_p(id)
{	
	client_print(id,print_console, "%d) %s", tmpi + 1, szFDataBuffer[tmpi])
	tmpi++
}


public evs(id)
{    
	new szDataDir[128], szData[200]
	client_print(id,print_console,"===========================")
	get_datadir(szDataDir, sizeof (szDataDir) - 1)
	format(szDataDir, sizeof (szDataDir), "%s/hihi.txt", szDataDir)
	
	new i = 0
	tmpi = 0
	
	new file = fopen(szDataDir, "rt")
	while(!feof(file))
	{				
	fgets(file, szData, sizeof(szData) -1)
	///////////////////////////////////////
	
	
	i++
	}
	formatex(szFDataBuffer[i - 1], 512 - 1, szFDataBuffer)

	fclose(file)
	
	set_task(0.01, "evs_p", id, _, _, "a", i)
	
	return 0
}
I get error 048: array dimensions do not match on the red line

Last edited by Ev1scerator; 12-18-2013 at 12:58.
Ev1scerator 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 20:27.


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