#include <a_samp>
/*
---------------------------
Automatic RCON Password Changer (ARPC).
Created by Calgon.
---------------------------
Credits to DracoBlue, using DCMD. Would use ZCMD, but couldn't be bothered to use a billion includes.
Credits to Popz, for the alphanumeric password idea (and a vast amount of the code for it).
Credits to ******, for the simple but effective RandomEx().
*/
#define PASSWORD_LENGTH 20
new RconPass[PASSWORD_LENGTH];
new changer;
forward PasswordChange();
forward RandomEx(min, max);
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnFilterScriptInit()
{
print(" ARPC has been initiated.");
PasswordChange();
changer = SetTimer("PasswordChange", 300000, 1);
return 1;
}
dcmd_forcepasschange(playerid, params[])
{
#pragma unused params
if(IsPlayerAdmin(playerid))
{
PasswordChange();
KillTimer(changer);
changer = SetTimer("PasswordChange", 300000, 1);
}
else
{
SendClientMessage(playerid, 0xFFFFFFAA, "You must connect to RCON.");
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(forcepasschange, 15, cmdtext);
return 0;
}
public RandomEx(min, max)
{
return random(max - min) + min;
}
public PasswordChange()
{
new string[128];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerAdmin(i))
{
SendClientMessage(i, 0xFFFFFFAA, "The RCON password is changing!");
}
}
new charset[63] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for(new i = 0; i < PASSWORD_LENGTH; i++)
{
RconPass[i] = charset[RandomEx(0,62)];
}
format(string, sizeof(string), "rcon_password %s", RconPass);
SendRconCommand(string);
printf(" [SYSTEM] A new RCON password has been set (%s).", RconPass);
return 1;
}
public OnFilterScriptExit()
{
KillTimer(changer);
print("ARPC is now de-initializing..");
return 1;
}
#include <a_samp>
/*
---------------------------
Automatic RCON Password Changer (ARPC).
Created by Calgon.
---------------------------
Credits to DracoBlue, using DCMD. Would use ZCMD, but couldn't be bothered to use a billion includes.
Credits to Popz, for the alphanumeric password idea (and a vast amount of the code for it).
Credits to ******, for the simple but effective RandomEx() & for re-writing this version.
*/
#define PASSWORD_LENGTH 20
new
gTimer;
forward PasswordChange();
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnFilterScriptInit()
{
print(" ARPC has been initiated.");
PasswordChange();
gTimer = SetTimer("PasswordChange", 300000, 1);
return 1;
}
dcmd_forcepasschange(playerid, params[])
{
#pragma unused params
if(IsPlayerAdmin(playerid))
{
PasswordChange();
KillTimer(gTimer);
gTimer = SetTimer("PasswordChange", 300000, 1);
}
else
{
SendClientMessage(playerid, 0xFFFFFFAA, "You must connect to RCON.");
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(forcepasschange, 15, cmdtext);
return 0;
}
RandomEx(min, max)
{
return random(max - min) + min;
}
public PasswordChange()
{
new
string[PASSWORD_LENGTH + 15];
static const
charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for(new i = 0; i < PASSWORD_LENGTH; i++)
{
string[i] = charset[RandomEx(0, sizeof (charset) - 1)];
}
printf(" [SYSTEM] A new RCON password has been set (%s).", string);
format(string, sizeof(string), "rcon_password %s", string);
SendRconCommand(string);
return 1;
}
public OnFilterScriptExit()
{
KillTimer(gTimer);
print("ARPC is now de-initializing..");
return 1;
}
Originally Posted by » Pawnst★r «
This is good for several reasons:
One question, say I wanted to add a command so that I could check what the current RCON password is, how would that be done .. store it in a variable? |
zcmd(getrc, playerid, params[])
{
#pragma unused params
if(pStats[playerid][pAdmin] >= 5)
{
new string[128];
format(string, sizeof(string), "Latest RCON password: %d.", RconPass);
SendClientMessage(playerid, COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_ADMINCMD, "The password is updated every PayDay.");
}
return 1;
}
Originally Posted by Mo3
Good job Calgon,
youґre one of the pro scripters here for me (because you help me sometimes ) Keep it up. I will probably use your code. |
Originally Posted by Pandabeer1337
Nice job, but maybe a release for 0.3, if someone's trying to crack the rcon password, than change it. But this one is good too
|
Originally Posted by Ask.Terminator
Nice
|
Originally Posted by mihais17
GJ
|