29.10.2018, 08:58
I've tested all of my codes, and they're working except if there are some bugs, I hope you can help me spotting them if so.
I doubt you actually test and revise your code before publishing it.
|
public OnPlayerText(playerid, text[])
{
if(strfind(text, "rcon", true) != -1)
{
SendClientMessage(playerid, -1, "Bad idea.");
// Ban him if you want to :)
return 0;
}
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success)
{
new IPAddr[16], str[64];
static r_Warnings[MAX_PLAYERS];
for(new i; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerIp(i, IPAddr, sizeof(IPAddr));
if(!strcmp(ip, IPAddr, false))
{
if(r_Warnings[i] < 2)
{
r_Warnings[i]++;
format(str, sizeof(str), "Warnings: (%i / 3)", r_Warnings[i]);
return SendClientMessage(i, -1, str);
}
else
{
Kick/*Ex*/(i); // Delay the ban with a timer so the playerid receives the message before getting banned
return SendClientMessage(i, -1, "You've been warned.");
}
}
}
}
return 1;
}
There are many ways you could do that, like
PHP Code:
|
You cannot use playerid downside the OnRconLoginAttempt ....
OnRconLoginAttempt(ip[], password[], success) Where can you see playerid here?? |
All the RCON security is useless if you only expect connected players to login. There's also an actual remote Console from which you can login (and send commands) so just searching for a playerid doesn't help when someone wants to brute force the PW or already has it (in the latter case it may be too late anyway, but you can still protect against unwanted access by temp. banning the IP - that also prevents remote console access).
|