Raised This Month: $ Target: $400
 0% 

How do you read something from a file. Ini?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CsIosefin
Senior Member
Join Date: Aug 2009
Old 05-04-2010 , 10:16   Re: How do you read something from a file. Ini?
Reply With Quote #1

This method is unique? Why so much stuff that I want to remove something from a text file, that's all ... nothing else, but if so, better leave directly. Sma ...
CsIosefin is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2010 , 17:34   Re: How do you read something from a file. Ini?
Reply With Quote #2

Quote:
Originally Posted by CsIosefin View Post
Why so much stuff that I want to remove something from a text file, that's all
Because that's the way it is. It's different for different uses. You will never find a "one command does it all for you".
__________________
fysiks is offline
CsIosefin
Senior Member
Join Date: Aug 2009
Old 05-05-2010 , 12:54   Re: How do you read something from a file. Ini?
Reply With Quote #3

Should look like this? Or should include, depending? I think it's so pretty ... or at least, I do not give any erroare, I did not test him.
One question, if well, one must put the text in another? I do not want to read everything, but line by line ...
Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    register_plugin("Auto-Messages", "1.0", "Team")

    set_task(7.5, "Hud", _, _, _, "b")
    set_task(15.0, "Chat", _, _, _, "b")
}

public func()
{
	new path[128], fh, cache[128]
	get_configsdir(path, 127)
	format(path, 127, "%s%s", path, "/messages.ini")

	if(!file_exists(path))
	{
	log_amx("Error: file does not exist (%s).", path)
	return
	}

	fh = fopen(path, "rt")
	if(!fh)
	{
	log_amx("Error: Could not open file (%s).", path)
	return
	}

	new example_counter
	while(!feof(fh))
	{
	fgets(fh, cache, 127)
	example_counter++
	log_amx("loaded line number %d: %s", example_counter, cache)
	}

	fclose(fh)
}

public Chat(id)
{
	client_print(0, print_chat, "%s", "path")
}
public Hud(id)
{
	set_hudmessage(random(255), random(255), random(255), -1.0, 0.08, random_num(0, 2), 0.02, 6.0, 0.01, 0.1, 2)
	show_hudmessage(0, "%s", "path")
}
CsIosefin 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 03:35.


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