File reading function
#1

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.
Reply
#2

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.
Reply
#3

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

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

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

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)
Reply
#7

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
Reply
#8

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^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)