[HELP] How to log IP addresses

GTA V version? Up to date
Legit or Pirate copy? Legit
Windows version? 10

Hi,
I have a quick, probably simple, question.
How do I log IP adresses of people who join my server? I already searched around on the forum, but I didn’t find a useful answer. I host the FiveM server on a pc.

I already want to thank you guys

Hello, this is a friendly reminder because this is your first time creating a topic (or it has been a while since your last topic) in this category.

Please note that most of the support is provided by the FiveM community on a voluntary basis. We ask you to be patient; there is no guarantee we have a solution to your problem(s). To avoid unnecessary/duplicate topics, please browse the forums before creating a topic.

To improve your chances of your issue(s) being solved, please provide as much information as possible about the issue(s) you are having. Also —whenever possible— please use the template given to you when creating a topic.

Thanks for keeping these forums tidy!
:mascot:

3 Likes

Get the IP identifier from the player (upon connect or when you want it to happen).

Thx for your reply, but I don’t understand what you mean. Im quite new to this😅

Or, GetPlayerEndpoint(playerServerId) (here)

If you just want to log all IP’s to a simple log file, you could do something like this as a server script:

AddEventHandler("playerConnecting", function(source)
    local file = LoadResourceFile(GetCurrentResourceName(), "ips.log")
    SaveResourceFile(GetCurrentResourceName(), "ips.log", file .. GetPlayerName(source) .. " " .. GetPlayerEndpoint(source) .. "\n", -1)
end)
2 Likes

Also, remember, it is trivial to change (or, rather, mask) IP addresses nowadays. VPN providers have wide ranges that you can jump between even on free providers. If you’re wanting to ban anything half way meaningful, do the license identifier.

5 Likes

Thank you so much. Do you have a website where you can find those “parts” of the scripts, if you understand what I mean

1 Like

I did not ask this :sweat_smile::sweat_smile:

1 Like

I have one more question, where can I find the log?

1 Like

Mainly the scripting sections on http://docs.fivem.net/

Also, it’s perfectly fine to ask these questions, we don’t mind unless it are super obvious things :slight_smile:

3 Likes

That log would be saved in the folder of whatever resource you put that script in.

I can’t find it.

I made a new resource folder called “log”.
In there I putted a __resource.lua which contains the following: server_script “server.lua”

Then I made a server.lua, which contains your code. But I still can’t find it.
Did I do something wrong?

Did you join the server?

yes, and some of my friends did too

Probably crashes if the file is nil, try creating an empty file (ips.log) in that resource folder

I tried, but it doesn’t work

1 Like

I’ll look into this later.

Ok, this version should work, I’ve tested it.

logs.zip (840 Bytes)

4 Likes

Thank you, I will test it tomorrow. Have to fix some other problems first.

1 Like

Thank you, it works (((20chars)))

1 Like