dugasz1 Posted July 19, 2016 Share Posted July 19, 2016 Hello! I would like to log a lot of things (damage, money transfer, how kills how etc.) So a lot.(Only for a weak or two after it would be deleted) What would be the fastes way to log which don't use much performance? Link to comment
shaio Posted July 21, 2016 Share Posted July 21, 2016 To be frank with you, I've never worked with file opening, closing, editing or anthing like that.. But I pieced together this. I have no idea if it works or not, but it does make sense . Good luck bro. (You need to name the resource "logs" - without quotes - or else it wont work) function logStart() if fileExists((":%s/%s"):format("logs","log.txt")) then for _,plr in ipairs(getElementsByType("player")) do local file = fileOpen("log.txt") fileWrite(file,getPlayerName(plr).." - Health: "..getElementHealth(plr).."\n\r") fileClose(file) end else local file = fileCreate("log.txt") end setTimer(logStart,5000,0) end addEventHandler("onResourceStart",getRootElement(),logStart) 1 Link to comment
dugasz1 Posted July 22, 2016 Author Share Posted July 22, 2016 Thank you man But my question was which way request the minimum preformance? But i guess if i write it to files, and sometimes load them to mysql. It has to be in mysql beacause i need to search in them and gathering data from them. But if i log them with mysql i guess it's slowes down the server Link to comment
shaio Posted July 23, 2016 Share Posted July 23, 2016 u can gather data from local files as well Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now