ID:1641593
 
Keywords: aid, bleach, game, gm, gmlog, help, log, naruto, ranks, tab
(See the best response by SuperAntx.)
Can anyone help me? I want to code a GM Log, so like, if any GM does something it records the action (In Game Name, GM's key, Time the verb was used, the date the verb was used and the verb that was used and if possible the person it was used on).
I want the GM Log to be like a verb, "View GM Log" and it displays everything every GM did (as displayed above) in a week (or more) and the GM Log should also be downloadable (if possible).

Also, I would like a Ranks tab that displays all the ranks in my game (One for Naruto and one for Bleach) Eg: Hokage, Kazekage, Amekage, Otokage, etc. Once i give someone a rank it should display the rank, if someone leaves the rank, it should make the rank blank.

I'm sorry I'm asking for too much.

Very basic.

mob
var
rank = ""
Stat()
statpanel("Ranks")
stat("([src.rank]) [src]")


Just for starters for your rank crap.


Secondly.
#define write2gmlog(string) write2log(string, "logs/gmlog.txt")
proc/write2log(var/string, var/file)
text2file(string,file)


then to test it:

mob/verb/Test()
write2gmlog("Hello Log!")




i didnt compile so yeah. anywho :)
Best response
There are many ways you can do this, but I would recommend using text files to store everything. You could use a nice looking xml format to keep things clean and organized, or you could use html logs to do the same, or you could simply dump text to a log file and be done with it.

To dump text to a log file you would do this:
var/GM_LOG //This is our log.
world/New()
GM_LOG = file("GM_log.txt") //This makes the log a text file.
..()
mob/verb/LogTest()
world << "This is a test."
GM_LOG << "The test has been logged." //This adds messages to the text file.


The idea here is to add those messages to GM commands, keeping track of what they do.
mob/GMCOMMANDS/verb/Teleport(var/mob/m in world)
src.loc = m.loc
src << "You teleported to [m]!"
GM_LOG << "[src] teleported to [m]." //The use of a GM command has now been logged.


It's also helpful to add timestamps to your log files so you know when commands were used.
mob/GMCOMMANDS/verb/TeleportTimestamp(var/mob/m in world)
src.loc = m.loc
src << "You teleported to [m]!"
GM_LOG << "([time2text(world.realtime,"hh:mm:ss")]) [src] teleported to [m]." //The logged GM command now has the time it was used logged as well.



You could also use log files to store runtime errors by using the world.log variable.
var/RUNTIME_LOG
world/New()
RUNTIME_LOG = file("runtime_log.txt")
world.log = RUNTIME_LOG //It's the same as before, only now runtime errors are automatically added to the text file.
..()
Thanks SSJjustdale for the ranks tab :D
SuperAntx, thanks A LOT for your help, that was really good.