Raised This Month: $ Target: $400
 0% 

How do you read something from a file. Ini?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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 #9

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
 



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