[Y-INI] My function aint working how it should :S - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Y-INI] My function aint working how it should :S (
/showthread.php?tid=211940)
[Y-INI] My function aint working how it should :S -
Lorenc_ - 16.01.2011
Hey i made a function that adds lines and basicly it loggs files though its not really doing what it should do..
pawn Код:
stock AddLogLine(playername[], filename[], input[])
{
new
string[128]
;
new
INI:ini = INI_Open(filename)
;
format(string, sizeof(string), "%s\n\n", input);
INI_WriteString(ini, playername, string);
INI_Close(ini);
}
So basicly when i use this function on a command it writes the stuff but it usally replaces the current string inside the file wtf lol..
E.G
I done /bug apples...
Prints:
Lorenc = apples
After, retype the cmd /bug, i put a different word.
/bug cool, it replaces apples with cool, anyway i can just create a new line and keep writing the strings like a normal one does, thx.
Re: [Y-INI] My function aint working how it should :S -
JamesC - 16.01.2011
Thats how INI files work... Key=Value.
If the Key already exists, it replaces the value with the new value.
Re: [Y-INI] My function aint working how it should :S -
Lorenc_ - 16.01.2011
And, how do i prevent that?
Re: [Y-INI] My function aint working how it should :S -
Finn - 16.01.2011
What's the point of using y_ini for logs?
Re: [Y-INI] My function aint working how it should :S -
JamesC - 16.01.2011
This is pretty simple to do with native file functions, you don't need y_ini for it.
pawn Код:
stock AddLogLine( player[ ], file[ ], input[ ] )
{
new
File: fhandle, // Create a file handler
tmpstring[ 128 ] // Temperory string to format data.
;
if( !fexist( file ) ) // If the file doesn't exist
{
print( "Serv: File did not exist and has been created." ); // Send a friendly message
}
fhandle = fopen( file, io_write ); // Open the file
format( tmpstring, sizeof( tmpstring ), "%s:%s\r\n", player, input ); // Format the data
fwrite( fhandle, tmpstring ); // Write the data to the file
fclose( fhandle ); // Close the file
return 1;
}
Untested.
Re: [Y-INI] My function aint working how it should :S -
Lorenc_ - 16.01.2011
ooh lol, I thought why not yini? its a fast file system anyway, ill make it my self thanks