Jump to content

Log


dugasz1

Recommended Posts

Posted

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?

Posted

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 xD. 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) 

  • Like 1
Posted

Thank you man :D 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...