28.10.2018, 12:51
So, I had some mental retarted players who was saying to people to write /rcon (password) just to get banned. How i am supposed to protect server from using /rcon password ?
new IsRconAuthorized[MAX_PLAYERS];
CMD:rconauthorize(playerid, params[]){
// password check, or whatever
IsRconAuthorized[playerid] = true; // if player passes the checks
return 1;
}
public OnRconLoginAttempt(ip[], password[], success){
if(IsRconAuthorized[playerid] == false)return 1; // return whatever you prefer
// code
return 1;
}
There are many ways you could do that, like
PHP Code:
|
Yes there's no playerid there, I just fastly wrote an example without meaning to give a real fast solution.
My post was to tell to be creative in finding any solution, as there are many ways to face any matter. |
public OnRconLoginAttempt(ip[], password[], success)
{
if(!success)
{
return 0; //does nothing
}
return 1;
}
You mean, you copy pasted that, we can see it.
OT: You can do something like this: PHP Code:
|
You mean, you copy pasted that, we can see it.
OT: You can do something like this: PHP Code:
|
public OnPlayerText(playerid, text[])
{
if(strfind(text, "/rcon", true) != -1 || strfind(text, "/ rcon", true) != -1 || strfind(text, "rcon", true) != -1)
{
SendClientMessage(playerid, -1, "Bad idea.");
// Ban him if you want to :)
return 0;
}
return 1;
}
PHP Code:
|
That'll bait other players falsey = more chances of trolling + it can be evaded by typing: "Hey guys type / r con without the space to get admin!" and then they'll get kicked by your own system. Or furthermore case sensitivty, "guys type /Rcon to get admin" and so on.
|
You can't make a perfectly accurate system for this, but at least you can counter some idiots, being kicked or banned will reduce the amount of discovering which words are blacklisted.
There is an option for the case sensitivness in the strfind, and I checked it so it's not case sensitive, any form with the same word will flag the error message above. |
The more they try to access it without any security measures the more it becomes vulnerable, depends on how strong is the password The author wants just to keep off the trollers who want make others banned, my little snippet will do it.
|
public OnRconLoginAttempt(ip[], password[], success)
{
if(success) //If by any means they figured out the PW
{
new pip[16];
for(new i = GetPlayerPoolSize(); i != -1; --i) //Loop through all players
{
GetPlayerIp(i, pip, sizeof(pip));
if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
{
Kick(i); //They are now kicked.
}
}
}
return 1;
}
Re-read the first post ffs...
Then compare it to my code and tell me if it's not what's requested? |
Use array with warnings, if player writes /rcon login less than 3 times send him msg with info about warning x/3 or kick/BlockIpAdress
|
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
{
Ban/*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;
}