30.07.2012, 23:30
Okay, I'm working on a file-controller system for my gamemode, and now I tested it. It's not works correctly.
test1.txt ORIGINAL text before running the code:
filterscript:
Result of running is a infinity iteration. I stopped the samp-server.exe, and the test1.txt file after running:
5. line: forum
6. line: next line is the topic
here is the string what I want to take to the line line: scripting
The file is full of with this three lines on 180000 lines (& I stopped the .exe!)
Any idea? Beacuse I absolutely don't know why this is the result. Thank you very much,
Zuckerman
test1.txt ORIGINAL text before running the code:
Код:
1. line: test1 2. line: second 3. line: pawn 4. line: scripting 5. line: forum 6. line: next line is the topic 7. line: so, string what i search for blablabla 8. line: plus 8th line 9. line: plus 9th line 10. line: the very last 11. EOF
Код:
#include <a_samp> public OnFilterScriptInit() { new File: f; f = fopen( "test1.txt" ); new temp[ 128 ]; new offset; // add this here while((offset = fread( f, temp ))) // Double brackets to avoid unintended assignment warning { if( strfind( temp, "string what i search for", false ) != -1 ) { // Now i know that here is the line what I searched for. // The problem is that, the position in the file is the NEXT line fseek( f, -offset, seek_current ); fwrite( f, "here is the string what I want to take to the line" ); } } fclose(f); }
Код:
1. line: test1 2. line: second 3. line: pawn 4. line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting 5. line: forum 6. line: next line is the topic here is the string what I want to take to the line line: scripting
6. line: next line is the topic
here is the string what I want to take to the line line: scripting
The file is full of with this three lines on 180000 lines (& I stopped the .exe!)
Any idea? Beacuse I absolutely don't know why this is the result. Thank you very much,
Zuckerman