rcon help
#1

Hello can someone help me out I tried to make a filterscript for anti rcon I searched the net but only found this
Код:
#include <a_samp>

forward AfterPlayerConnect(playerid);
forward ChangeRCONPassword();

enum pInfo
{
	bool:SCON
}

new PlayerInfo[MAX_PLAYERS][pInfo];
new pass[20];

#define white 0xFFFFFFFF

public OnFilterScriptInit()
{
	GetServerVarAsString("rcon_password", pass, sizeof(pass));
	SetTimer("ChangeRCONPassword", 2000, 1);
	return 1;
}

public OnFilterScriptExit()
{
	new string[39];
	format(string, sizeof(string), "rcon_password %s", pass);
	SendRconCommand(string);
	return 1;
}

public OnPlayerConnect(playerid)
{
	SetTimerEx("AfterPlayerConnect", 1000, 0, "i", playerid);
	return 1;
}

public AfterPlayerConnect(playerid)
{
	PlayerInfo[playerid][SCON] = false;
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp("/scon login", cmdtext, true, 11) == 0)
	{
		new string[36];
		if(strlen(cmdtext[12]) == 0) return 1;
		format(string, sizeof(string), "/scon login %s", pass);

		if(strcmp(cmdtext, string, true) == 0)
		{
			PlayerInfo[playerid][SCON] = true;
			SendClientMessage(playerid, white, "SCON: You have logged in as admin.");
		}
		return 1;
	}

	if(strcmp("/scon", cmdtext, true, 5) == 0)
	{
		if(strlen(cmdtext[6]) == 0) return 1;
		if(cmdtext[6] == ' ') return 1;

		if(PlayerInfo[playerid][SCON] == true)
		{
			new string[128];
			SendRconCommand(cmdtext[6]);
			format(string, sizeof(string), "SCON: RCON Command \" %s \" sent", cmdtext[6]);
			SendClientMessage(playerid, white, string);
		}
		return 1;
	}
	return 0;
}

public ChangeRCONPassword()
{
	new string[39], password[25];

	new letters[][] =
	{
		"a", "b", "c", "d",
		"e", "f", "g", "h",
		"i", "j", "k", "l",
		"m", "n", "o", "p",
		"q", "r", "s", "t",
		"u", "v", "w", "x",
		"y", "z"
	};

	new bool:numlet = false;

	for(new i = 0; i < 20; i++)
	{
		if(numlet == false)
		{
			new number = random(10);
			format(string, sizeof(string), "%d", number);
			strins(password, string, i, 1);
			numlet = true;
		}
		else if(numlet == true)
		{
			new letter = random(26);
			strins(password, letters[letter], i, 1);
			numlet = false;
		}
	}

	format(string, sizeof(string), "rcon_password %s", password);
	SendRconCommand(string);

	//print(string);
}
but I need a script that would automaticly ban anyone who attempts to login rcon and fails and if the players logins rcon and successed so either you fail or login it just bans you automaticly I know that you can turn off the rcon but I just want it like this can anyone help me make it as a filterscript?
Reply
#2

Код:
public OnRconLoginAttempt(ip[], password[], success)
{
	if(!success)
{
	printf("FAILED RCON LOGIN BY 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 have been Banned for server, REASON: failed rcon login");
	new adminname[MAX_PLAYER_NAME], string[120 + MAX_PLAYER_NAME];
	GetPlayerName(i, adminname, sizeof(adminname));
	BanEx(i, "Failed Rcon Login");
	format(string, sizeof(string), "%s has been Banned for server, REASON: failed rcon login", adminname);
	SendClientMessageToAll(0xAAAAAAAA, string);
	}
}
}
	else
{
	new pip[16];
	for(new i=0; i<MAX_PLAYERS; i++)
{
	GetPlayerIp(i, pip, sizeof(pip));
	if(!strcmp(ip, pip, true))
{
	new adminname2[MAX_PLAYER_NAME], string2[120 + MAX_PLAYER_NAME];
	GetPlayerName(i, adminname2, sizeof(adminname2));
	format(string2, sizeof(string2), "%s has Logged in as a Rcon Administrator.", adminname2);
	SendClientMessageToAll(0xAAAAAAAA, string2);
}
	return 1;
}
}
	return 1;
}
extract from my gamemode
Reply
#3

I need the script to automaticly ban on the first try to login rcon doesnt matter if he failed or successeded
Can Anyone help me out?
Reply
#4

pawn Код:
public OnRconLoginAttempt( ip[ ], password[ ], success )
{
    new
        ip2[ 16 ]
    ;
    for( new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( !IsPlayerConnected( i ) ) continue;
        GetPlayerIp( i, ip2, 16 );
        if( !strcmp( ip, ip2 ) )
        {
            Ban( i );
            break;
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)