SA-MP Forums Archive
File reading function - 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: File reading function (/showthread.php?tid=180221)



File reading function - wups - 30.09.2010

I can't manage to make a function, that finds "[]=" in the file and removes that line. Can somebody help me? Bcz my people script files are bugged, and i don't want to fix 20k files by hand thanks.


Re: File reading function - Scenario - 30.09.2010

You could use CTRL+H if you open the files in PAWNO... Although, you said you didn't want to do it manually. Another reason MySQL is 10x better.


Re: File reading function - wups - 30.09.2010

Yes, im converting my files to MySQL this weekend. But i still need to fix this.


Re: File reading function - Scenario - 30.09.2010

Why spend time to fix this, if you're already converting? Think about it.


Re: File reading function - wups - 30.09.2010

I will make
pawn Код:
if(fexist(file) && mysql_num_rows == 0) INSERT .....
Because the reader is not reading the file if it finds "[]="


Re: File reading function - Mauzen - 30.09.2010

Use this, just wrote it, java rulez

Usage: download, unzip, use cmd to go to the folder you downloaded it to and run:

Код:
java LineRemover "full path to the directory" "start of the line to remove" "only short info=1/0"
(with the "", only 1 or 0 for the last param
it checks all files in the specified directory for lines starting with the specified string and removes them


BUGS ARE POSSIBLE, JUST WROTE IT IN A FEW MINUTES. SO COPY THE DIRECTORY FIRST AND USE THE PROGRAM ON THE COPY ONLY TO PREVENT LOSS OF DATA IF SOMETHING FAILS. I DO NOT GUARANTEE FOR BUGLESS FUNCTION.


So, i hope it helps you, pawn would be too slow to do this for thousands of files. You can only use this, if you have direct access to the files/server of course.
And at last: no problem if you do not need it/cant use it, i was just bored and wanted to code something with java again, and it might help someone else then

(no trojan, check my join date and posts if you do not trust me)


Re: File reading function - wups - 30.09.2010

Thanks a lot! So, i copy this to my scriptfiles on linux, and on putty i write this?
Код:
 java LineRemover "/root/samp03svr/scriptfiles/user/" "[]=" "1"
Btw. i planned to do this on player connect
Dah, i have no java


Re: File reading function - Mauzen - 30.09.2010

Oops, i twisted the "detail info", it should be called "short info", so 1 turns the additional info off.
You cant really use it in a pawn script, would only be possible to embed it in a plugin
it is just a small standalone tool, that you run by hand from the linux/windows console.

Linux without java? But ok, it isnt really needed for a normal server^^