How to log this?
#1

How can i log this in a text file saved in the script files folder? instead of in the server logs.


pawn Код:
public OnRconLoginAttempt(ip[], password[], success)
{
  if(!success)
  {
    printf("RCON LOGIN FAILED IP %s USING PASSWORD %s",ip, password);
    new pip[16];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      GetPlayerIp(i, pip, sizeof(pip));
      if(!strcmp(ip, pip, true))
      {
        SendClientMessage(i, 0xFFFFFFFF, "You typed the wrong password, DON'T DO IT AGAIN!");
        Kick(i);
      }
    }
  }
  return 1;
}
Reply
#2

Try this. http://pastebin.com/cwYehxny You don't have to have all of that code but it will record the month, day, and year and also the hour, minute, and second the player typed it plus his ip and the password he attempted to use. Just be sure to have a file called RconLog.txt or whatever you change it to in your scriptfiles directory.
Reply
#3

Quote:
Originally Posted by Baked-Banana
Try this. http://pastebin.com/cwYehxny You don't have to have all of that code but it will record the month, day, and year and also the hour, minute, and second the player typed it plus his ip and the password he attempted to use. Just be sure to have a file called RconLog.txt or whatever you change it to in your scriptfiles directory.
Thank you Baked-Banana, But it has a problem, It logs it like 50 times when the person types it once. Also, The IP isn't added in the log.


I tried logging in with the wrong password, and this is what happend.

I typed, /rcon login fuckyermama (LOL for testing purposes...)

And this is how the log turned out, except it was x50..

Код:
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
[05-19-2010 @ 18:36:11][BAD LOGIN]:53 - Fuckyermama
Reply
#4

http://pastebin.com/zrcB6tnL

Try that. That should have fixed the ip problem and maybe the repeating problem. If not, get back to me and we can fix it.
Reply
#5

Quote:
Originally Posted by Baked-Banana
http://pastebin.com/zrcB6tnL

Try that. That should have fixed the ip problem and maybe the repeating problem. If not, get back to me and we can fix it.
It fixed the IP, and the repeated problem!!!

Can you help me add so it displays the name as well?

Thanks a lot man, you always fix my problems
Reply
#6

Here this will display name i just made it

Код:
public OnRconLoginAttempt(ip[], password[], success)
{
  if(!success)
  {
    printf("RCON LOGIN FAILED IP %s USING PASSWORD %s",ip, password);
    new pip[16];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      GetPlayerIp(i, pip, sizeof(pip));
      new Year,Month,Day,Hour,Minute,Second,namee[MAX_PLAYER_NAME];
      Getdate(Year,Month,Day);
      Gettime(Hour,Minute,Second);
      GetPlayerName(playerid,namee,sizeof(namee));
      format(string,sizeof(string),"[%02d-%02d-%02d @ %02d:%02d:%02d] %s[IP:%s] - Failed password: %s",Year,Month,Day,Hour,Minute,Second,namee,pip,password);
			new File: badattemptfile=fopen("Bad_Attempts.txt",io_append);
			if(!badattemptfile)
			{
			  fcreate("Bad_Attempts.txt");
			}
			fwrite(badattemptfile,string);
			fclose(badattemptfile);
			if(!strcmp(ip, pip, true))
      {
        SendClientMessage(i, 0xFFFFFFFF, "You typed the wrong password, DON'T DO IT AGAIN!");
        Kick(i);
      }
    }
  }
  return 1;
}
Reply
#7

That causes many errors.



Also, one of the errors include "Undefined symbol playerid"
Reply
#8

Change playerid to i O.o
Reply
#9

Here yah go. http://pastebin.com/sv9ETgeG
Quote:
Originally Posted by Coole210
Here this will display name i just made it

Код:
public OnRconLoginAttempt(ip[], password[], success)
{
  if(!success)
  {
    printf("RCON LOGIN FAILED IP %s USING PASSWORD %s",ip, password);
    new pip[16];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      GetPlayerIp(i, pip, sizeof(pip));
      new Year,Month,Day,Hour,Minute,Second,namee[MAX_PLAYER_NAME];
      Getdate(Year,Month,Day);
      Gettime(Hour,Minute,Second);
      GetPlayerName(playerid,namee,sizeof(namee));
      format(string,sizeof(string),"[%02d-%02d-%02d @ %02d:%02d:%02d] %s[IP:%s] - Failed password: %s",Year,Month,Day,Hour,Minute,Second,namee,pip,password);
			new File: badattemptfile=fopen("Bad_Attempts.txt",io_append);
			if(!badattemptfile)
			{
			  fcreate("Bad_Attempts.txt");
			}
			fwrite(badattemptfile,string);
			fclose(badattemptfile);
			if(!strcmp(ip, pip, true))
      {
        SendClientMessage(i, 0xFFFFFFFF, "You typed the wrong password, DON'T DO IT AGAIN!");
        Kick(i);
      }
    }
  }
  return 1;
}
The reason I didn't do it like that, is because you shouldn't declare all those variables and get the time and get the date every single time. MAX_PLAYERS is equal to 500, meaning you would declare those variables and call those functions 500 times when you could just do it once.
Reply
#10

It doesn't display the name.


It just displays how it would regularly,

Код:
[05-19-2010 @ 20:12:18][BAD LOGIN]:(5.29.79.72) - apple
I looked at it, and i'm not sure whats wrong


Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)