SA-MP Forums Archive
logging connections ip - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: logging connections ip (/showthread.php?tid=185874)



logging connections ip - Face9000 - 26.10.2010

Hai,i need help with logging ip of players that connect to server.

Example: I connect to server and he write my ip in ip_log.txt file with : Connected IP: XX.XX.XX.XX | Nick: blabla | Date: 02/10/1990

Thanks D:


Re: logging connections ip - Sascha - 26.10.2010

Code:
OnPlayerConnect(playerid)
{
  new name[MAX_PLAYER_NAME], ip[40], string[200], day, month, year;
  GetPlayerName(playerid, name, sizeof(name));
  GetPlayerIp(playerid, ip, sizeof(ip));
  getdate(year, month, day);
  format(string, sizeof(string), "Connected IP: %s | Nick: %s | Date: %d/%d/%d \r\n", ip, name, day, month, year);
  if(fexist(ip_log.txt)){
    new File:log = fopen("ip_log.txt", io_append);
    fwrite(log, string);
    fclose(log);
  }
  return 1;
}
I hope it works :P.. if not contact me and I'll overwork it again (just wrote it up)..