[Release] Simple server side Logs

The logs get saved into the server-folder like you can see in the pictures above. I guess it get’ s saved into a .txt file or something like that.
@Erkan_005015

Does this include kick and ban logs.

You can add that by doing something like this

If PlayerDropped blablabla then
Log Trigger
end

The same with bans.

Ok I found an example above, just read the description of the resource.

Thanks. :slight_smile:

Im a pretty big idiot and so if you can just explain to me how maybe I could add a players steam ID next to their name when they join, if thats even possible. If you dont want to explain to me all good lol!

You can get the steam name with GetPlayerName(ID) in server.lua,
If you want to get all Steam names, then you would need a for function. Or use GetPlayerName(source) this will only work If there’s something that can call the source.
Example:
Server.lua and client.lua possible: (in example of a command)

RegisterCommand("mySteamName", function(source, args) --args to get what the player wrote.

local steam = GetPlayerName(source)
local args = table.concat(args, " ")

if args ~= "" then --checks If the Input is empty and will only send message If not

TriggerClientEvent("chatMessage", -1,  steam.. ": "..args)
end
end)

It would give a Output Like this:

hamburger: I like hamburger’s

Hope I could help, have a nice day! :slight_smile:

Just replace

RegisterCommand

With

AddEventhandler("playerSpawned", function(source)

And replace args with the join Message.
If you want that only the person that is joined get the message Change -1 with source.

Awesome! Do you know if there is a way to get a players steam ID? like the one that has the numbers and letters etc, in the format of steam:11111111sdngfhh or something. Thanks again!

yes with GetPlayerIdentifier. I can’t exactly say how but I’ll paste something from other code in here:

GetPlayerIdentifiers(source)[1])

This might work, but I only used it in a for function yet so it calls all Identifiers, like this:

        for i=args, GetNumPlayerIdentifiers(args) do
	        print(" ", GetPlayerIdentifiers(args)[i])
        end	
1 Like

So if I took this,

	local pname = GetPlayerName(source)
	TriggerEvent("serverlog", pname.. " joined ")
end)

how would I add the GetPlayerIdentifiers into it? I would just want it to have it next to the name or next to "pname… " Thanks for all the help, Cheers!

like I showed above just go there and do:

local id = GetPlayerIdentifiers(source)[1]
local pname = GetPlayerName(source)
   
     TriggerEvent('serverlog', id..":"..pname.. " joined")
end)
1 Like

Thanks! Sorry for being dumb lol

1 Like

no problem! :smiley:

thanks for asking, hope you could learn out of it.
:hamburger: :mascot:

(write back if local id does not work, didn’t tested it lol)

1 Like

Worked flawlessly! legend. Yea This taught me a little bit lol, thank you, my appreciation is immeasurable!

1 Like

Got this on consol when trying to log client script: event serverlog was not safe for net

I put this a the top of the script: local pname = GetPlayerName(source)
and the code:

AddEventHandler('esx_society:openBossMenu', function(society, close, options)
  OpenBossMenu(society, close, options)
  TriggerServerEvent("serverlog", pname.. " opened the boss menu from:("..society..") society")
end)

You’ve forgot to add:

RegisterNetEvent('Eventname')

Above of your code.

Normally the eventname should be serverlog? Am I right?

EDIT: nevermind lol

Hello. IS possible to add date? I would realy appreciate it.

In the file that the report is generated, it appears 4 times, how can I accommodate this?

Captura de pantalla 2021-07-06 235052