Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin
Archive › Old Forum Threads › Help › Scripting Help › [SOLVED] using dynamic name on log_to_file
5 posts, 2 people · 1,118 views Thread Rating: ★★★★★
closed[SOLVED] using dynamic name on log_to_file
Started by Tank on 07-30-2010, 03:36 PM
Tank
started this thread
Posts: 581
Threads: 59
Joined: Jan 2007
07-30-2010, 03:36 PM #1

Im working on a plugin which logs information to a file. Now it logs to a file like:rnrnlog_to_file("test.log","i am a test line")rnrnIs it possible to add a dynamic date to the name of the file? For example like you see with the amxx and server logs? I've been trying to find some plugins which do that but the plugins I found just use log_amx. Thanks in advanced.rnrnEDIT: Ok, I think I am on the right path....rnrn

rn	new currentdate[7]rn	new Y,m,jrn	get_time("%Y%m%j",currentdate,6)rn	rn	log_to_file("%stest.log",currentdate,"i am a test line")
rnrnIt posts the log file as: %stest.log

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
07-31-2010, 01:35 AM #2

Tank i dont even have the compiler on this PC. But does this script help ya? I think it will..rnrnElse write again..rnrnrn- Cheers

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
07-31-2010, 01:37 AM #3

What the hell is this for ???rnrn

new Y,m,j
rnrn(you dont have to answer :D )

Tank
started this thread
Posts: 581
Threads: 59
Joined: Jan 2007
08-01-2010, 08:29 AM #4

Thanks for posting up that plugin. Im sorry to say that that plugin didn't really help me on the log_to_file part, prolly lack of knowledge on my side. Thanks anyways. At the moment the problem is solved thanks to Synthetic.nnThe plugin did provide me with other usefull information. I was always interested to see how a SQL was hooked through a plugin. Something I've been trying for a while, so Im gonna see how it goes with the plugin next to mine.nnFor the people interested in what the code looks like when it does should work (havent tested it yet, not home for the weekend).nn

nnew currentdate[32]nget_time("%Y%m%j",currentdate,31)nadd(currentdate,31,"test.log" )nlog_to_file(currentdate,"%s","test line")n
nn
nnew Y,m,j n
nnSince you ask this question I assume this is quite the noob-mistake. I put it there because when I tried to compile my plugin I received a compiling error saying that y,m and j were unknown something something, so I added that and the compiling error went away. Ok, the dynamic log name part not working of course, but that is the reason. Let's keep it at that I havent been fiddling around with plugins for a while :D

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
08-02-2010, 05:55 AM #5

hehe btw log_to_file(.., .., ..) makes a time stamp by default when you run it. The code above will make the file name %Y%m%jtest.log . But i guess you found out already =) If you get weird long lines use trim(...) before using the array. But i think its only a windows thingy =)nnThe SQL stuff isnt that hard to get running, that code should help you alot. Notice the do_Connection stock, use the same method if you dont want you server to hang. It just tests the connection before running the query, if you dont do so, and just fire the query and u dont have the connection right, your server will take a break =)

Archive › Old Forum Threads › Help › Scripting Help › [SOLVED] using dynamic name on log_to_file
DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC