[Plugin] [REL] Hash File Loader
#12

It's realy works FAST ! Just tested.

"create" example (tested) :

Quote:

HLoad( "test", "test_hash_file.txt" );
HAdd( "test", "textValue", "textExample" );
HAddInt( "test", "integerValue", 123456 );
HAddFloat( "test", "floatValue", 1.23456 );
HSave( "test" );
HClose( "test" );

output file format (tested) :

Quote:
textValue
textExample
integerValue
123456
floatValue
1.23456
usage example (not tested) :

Код:
#include <a_samp>
#include <hashloader>




#define HASH_FILE_NAME			"test"
#define HASH_FILE_PATH			"test_hash_file.txt"
#define HASH_FILE_SAVE_INTERVAL		20000

stock hash_save_timer;

forward save_hash_file ();
public save_hash_file ()
{
	// writing all hash file changes to file
	HSave( HASH_FILE_NAME );
}




public OnGameModeInit ()
{
	// opening hash file
	HLoad( HASH_FILE_NAME, HASH_FILE_PATH );

	// save hash file every 20 seconds
	hash_save_timer = SetTimer( "save_hash_file", HASH_FILE_SAVE_INTERVAL, 1 );
}

public OnGameModeExit ()
{
	// kill save timer
	KillTimer( hash_save_timer );

	// writing all hash file changes to file
	HSave( HASH_FILE_NAME );

	// closing hash file
	HClose( HASH_FILE_NAME );
}

public OnPlayerCommandText ( playerid, cmdtext[] )
{
	if ( strcmp( cmdtext, "/hash_writing_test", true ) == 0 )
	{
		new
			textValue[20],
			floatValueStr[20];

		format( textValue, 20, "newText_%d", random(999999) );
		format( floatValueStr, 20, "%d.%d", random(999999), random(999999) );

		// writing hash data to server's memory
		HAdd( HASH_FILE_NAME, "textValue", textValue );
		HAddInt( HASH_FILE_NAME, "integerValue", GetTickCount() );
		HAddFloat( HASH_FILE_NAME, "floatValue", floatstr( floatValueStr );

		SendClientMessage( playerid, 0xAAAAAAAA, " * hash_writing_test:  type /hash_reading_test to see new hash values" );

		return 1;
	}

	if ( strcmp( cmdtext, "/hash_reading_test", true ) == 0 )
	{
		new
			textValue[20], integerValue, Float:floatValue,
			message[120];

		// reading hash data from server's memory
		HGet( HASH_FILE_NAME, "textValue", textValue );
		HGetInt( HASH_FILE_NAME, "integerValue", integerValue );
		HGetFloat( HASH_FILE_NAME, "floatValue", floatValue );

		format (
			message, 120,
			" * hash_reading_test:  textValue = %s , integerValue = %d , floatValue = %f",
			textValue, integerValue, floatValue );

		SendClientMessage( playerid, 0xAAAAAAAA, message );

		return 1;
	}

	return 0;
}
Reply


Messages In This Thread
[REL] Hash File Loader - by VRocker - 07.10.2009, 10:38
Re: [REL] Hash File Loader - by gijsmin - 07.10.2009, 15:49
Re: [REL] Hash File Loader - by Westie - 07.10.2009, 16:14
Re: [REL] Hash File Loader - by Correlli - 07.10.2009, 16:16
Re: [REL] Hash File Loader - by Jay_ - 07.10.2009, 16:50
Re: [REL] Hash File Loader - by MenaceX^ - 07.10.2009, 17:51
Re: [REL] Hash File Loader - by Dresden - 07.10.2009, 23:14
Re: [REL] Hash File Loader - by joemomma53 - 08.10.2009, 01:45
Re: [REL] Hash File Loader - by Jay_ - 16.10.2009, 21:10
Re: [REL] Hash File Loader - by Jamesy - 17.10.2009, 16:13
Re: [REL] Hash File Loader - by Creed - 31.10.2009, 22:51
Re: [REL] Hash File Loader - by MX_Master - 06.11.2009, 21:30
REL Hash File Loader - by D.duabe - 09.11.2009, 11:27
Re: [REL] Hash File Loader - by cyber_punk - 09.11.2009, 14:36
Re: [REL] Hash File Loader - by DaftWerk - 10.11.2009, 16:25
Re: [REL] Hash File Loader - by Angelhj - 18.11.2009, 07:59
Re: [REL] Hash File Loader - by Aleron - 18.11.2009, 11:44
Re: [REL] Hash File Loader - by Raphinity - 02.12.2009, 21:12
Re: [REL] Hash File Loader - by VRocker - 03.12.2009, 14:18
Re: [REL] Hash File Loader - by Raphinity - 04.12.2009, 10:42
Re: [REL] Hash File Loader - by Angelhj - 05.12.2009, 00:06
Re: [REL] Hash File Loader - by Dresden - 06.12.2009, 17:30
Re: [REL] Hash File Loader - by gotenks918 - 06.12.2009, 18:34
Re: [REL] Hash File Loader - by VRocker - 11.12.2009, 10:27
Re: [REL] Hash File Loader - by Deat_Itself - 11.12.2009, 12:59

Forum Jump:


Users browsing this thread: 5 Guest(s)