Admin log.
#1

Is there something I can add to my script so that whenever an admin does a certain command it saves it to a file with the name and date?. So if an admin did /setmoney 100 it would log something like:

01/01/09 - Admin_Name - /setmoney name 100
etc
Reply
#2

pawn Код:
#include <a_samp>

new
  File:adminlogfile,
  logstring[160],
  Name[MAX_PLAYER_NAME],
    day, month, year;
 
public OnFilterScriptInit()
{
    if(!fexist("adminlog.txt"))
    {
      adminlogfile=fopen("adminlog.txt", io_write);
      fwrite(adminlogfile, "Admin Checker:\r\n");
      fclose(adminlogfile);
    }
    else
    {
      adminlogfile=fopen("adminlog.txt", io_write);
      fclose(adminlogfile);
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(IsPlayerAdmin(playerid))
    {
      SaveStuff(cmdtext, playerid);
    }
    return 0;
}


stock SaveStuff(string[], playerid)
{
    GetPlayerName(playerid, Name, sizeof(Name));
    getdate(year, month, day);
  format(logstring,sizeof(logstring),"%d/%d/%d - %s - %s\r\n", day, month, year, Name, string);
  fopen("adminlog.txt",io_append);
  fwrite(adminlogfile,logstring);
  fclose(adminlogfile);
}
Try that, modified from a compltains script I made for somebody a while back.
Reply
#3

How would I add that to an command like this for example:

Код:
if(strcmp(cmd, "/givemoney", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /givemoney [playerid/PartOfName] [money]");
				return 1;
			}
			new playa;
			new money;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			money = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 1337)
			{
			  if(IsPlayerConnected(playa))
			  {
			    if(playa != INVALID_PLAYER_ID)
			    {
			      //ConsumingMoney[playa] = 1;
						SafeGivePlayerMoney(playa, money);
						GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						format(string, 256, "AdmWarning: %s has admin-given %s $%d.", sendername,giveplayer,money);
						ABroadCast(COLOR_YELLOW,string,1);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
			}
		}
		return 1;
	}
Reply
#4

Insert that log saving system in that FS into your gamemode.
And then use:
pawn Код:
if(strcmp(cmd,"/mycommand",true)==0)
{
    SaveStuff(cmdtext,playerid);
    return 1;
}
Reply
#5

The script I sent you records every command an admin makes. If you want it for specific commands, just use the SaveStuff line elsewhere.

As long as it contains the playerid and command text, it will save the command they use.
Reply
#6

Quote:

C:\Documents and Settings\Martin\Desktop\samp022server.win32\filter scripts\adminlog.pwn(39) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.

Reply
#7

i use the underworld script and I tried to add that script the one posted by weirdosport. So I added the .amx file to filterscripts and the name to filterscripts in the server.cfg and started the server and began to play. I used admin commands as admin and then I leave the server and check the adminlog.txt but it was empty. Please help
Reply
#8

@DrDeath - you were probably using an admin system which doesn't use rcon login but its own login, therefore IsPlayerAdmin would not tell the gamemode that you were an admin and wouldn't log it...

@meegan1 - that's just a loose indentation warning, you need to get the ifs and elses and whatnot to line up, it won't actually have an effect on the functionality of the code though.
Reply
#9

Yes, it's an admin script based in the script. I go to the filterscript and do admin=1337 or admin=4 etc. Only I know the rcon password. But how can I get it to recognize the admin system thats in the script.
Perhaps make it recognize something like if admin= >0 then save

Edit: I tried it with loggin in to rcon and then it works. But I would like to have it working without rcon admin
Reply
#10

Don't know 100% what you're asking but if I understand correctly then there's no easy way you can do that. You would need to incorporate the admin system into your gamemode or access the adminlist file when players connect to your server to see if they are admins. You'd then have to assign a variable to them saying if they were admins or not and use this to ask it to log admin commands. Alternatively, you could manually enter your admins' names into your gamemode; so if PlayerName is the same as the admin name then log.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)