OnFilterScriptInit
OnGameModeInit
OnRconLoginAttempt
OnPlayerConnect
#if defined FILTERSCRIPT
OnFilterScriptInit
#else
OnGameModeInit();
#endif
OnRconLoginAttempt
#if defined FILTERSCRIPT
OnFilterScriptInit();
OnFilterScriptExit();
#else
OnGameModeInit();
OnGameModeExit();
#endif
#if !defined OPRL_USE_TIMER
OnPlayerUpdate(playerid);
#endif
v1.3 (RECOMMENDED) (13-09-2014) • Defining of FILTERSCRIPT constant is no longer required before including this include in case if it's used for filterscripts. Thanks to ****** for the tip. • Removed useless timer call. • Fixed player array values while connections. • The include has been renamed from "OPRL2.inc" to "OPRL3.inc" v1.2 (02-02-2014) • Include has been optimized! Thanks to Konstantinos for showing a better method to callout "OnPlayerRconLogin" v1.0 (01-02-2014) • Initial Release
#include <a_samp>
#include <OPRL3>
public OnPlayerRconLogin(playerid)
{
new
Lname[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, Lname, sizeof(Lname));
format(string, sizeof(string), "<RCON LOGIN> : %s (ID:%d) has logged in as RCON Administrator!", Lname, playerid);
SendClientMessageToAll(-1, string);
printf(string); //Not actually required as it debugs itself, however just adding it as it's an example.
return 1;
}
/*______________________________________________________________________________
Lordz's Second RCON System!
Copyright© - 2014 "SecondRCON"
Author : Lordz™ AKA Lordzy
NOTE:
This script is created as a filterscript, mainly as an example for the include
"OPRL" AKA "OnPlayerRconLogin". This script ensures that the second RCON request
is only sent to the player who RCON logins, not to the players who got the same
IP address.
______________________________________________________________________________*/
#include <a_samp>
#include <OPRL3>
new
bool:RCON2LoggedIn[MAX_PLAYERS],
RCON2WrongLogins[MAX_PLAYERS];
#define SECOND_RCON_DIALOG 1126 //Dialog ID of the second RCON.
#define SECOND_RCON_PASS "testing" //Second RCON password, you can change it but keep it in quotes.
#define MAX_FALSE_2RCON_ATTEMPTS 3 //Maximum number of second RCON fails.
#define MAX_HOLD_SECONDS 120 //Maximum seconds in which a player could stay as RCON without confirming second RCON.
public OnPlayerConnect(playerid)
{
if(IsPlayerAdmin(playerid)) RCON2LoggedIn[playerid] = true;
else RCON2LoggedIn[playerid] = false;
RCON2WrongLogins[playerid] = 0;
return 1;
}
public OnFilterScriptInit()
{
for(new i; i< GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsPlayerAdmin(i)) RCON2LoggedIn[i] = true;
else RCON2LoggedIn[i] = false;
RCON2WrongLogins[i] = 0;
}
printf("-------------------------------------------------");
printf(" OnPlayerRconLogin - Second RCON system");
printf(" Loaded!");
printf("-------------------------------------------------");
return 1;
}
public OnPlayerRconLogin(playerid)
{
if(RCON2LoggedIn[playerid] == false)
{
SendClientMessage(playerid, -1, "{FF0000}Server : {880088}Before playing as RCON Administrator, please login to the second RCON option too.");
ShowPlayerDialog(playerid, SECOND_RCON_DIALOG, DIALOG_STYLE_INPUT, "Second RCON Login", "Hello,\nBefore accessing RCON, please login to the second RCON.", "Login", "");
SetTimerEx("DetectSecondRconLogin", 1000*MAX_HOLD_SECONDS, false, "d", playerid);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == SECOND_RCON_DIALOG)
{
if(response)
{
if(!strlen(inputtext))
{
RCON2WrongLogins[playerid]++;
new
string[128];
if(RCON2WrongLogins[playerid] >= MAX_FALSE_2RCON_ATTEMPTS)
{
new
Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : %d/%d)", Lname, playerid, RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessageToAll(0xFF0000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
format(string, sizeof(string), "ERROR! The previous second RCON given was incorrect! (Warnings : %d/%d)", RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessage(playerid, 0xFF0000FF, string);
return ShowPlayerDialog(playerid, SECOND_RCON_DIALOG, DIALOG_STYLE_INPUT, "Second RCON Login", "Hello,\nBefore accessing RCON, please login to the second RCON.", "Login", "");
}
if(!strcmp(inputtext, SECOND_RCON_PASS, false))
{
GameTextForPlayer(playerid, "~G~ACCESS GRANTED!", 2000, 3);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
RCON2LoggedIn[playerid] = true;
return 1;
}
else if(strcmp(inputtext, SECOND_RCON_PASS, false))
{
RCON2WrongLogins[playerid]++;
new
string[128];
if(RCON2WrongLogins[playerid] >= MAX_FALSE_2RCON_ATTEMPTS)
{
new
Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : Wrong RCON logins | %d/%d)", Lname, playerid, RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessageToAll(0xFF0000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
format(string, sizeof(string), "ERROR! The previous second RCON given was incorrect! (Warnings : %d/%d)", RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessage(playerid, 0xFF0000FF, string);
return ShowPlayerDialog(playerid, SECOND_RCON_DIALOG, DIALOG_STYLE_INPUT, "Second RCON Login", "Hello,\nBefore accessing RCON, please login to the second RCON.", "Login", "");
}
}
if(!response)
{
new
string[128],
Lname[MAX_PLAYER_NAME];
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : Wrong RCON login)", Lname, playerid);
SendClientMessageToAll(0xFF000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
}
return 1;
}
forward KickPlayer(playerid);
forward DetectSecondRconLogin(playerid);
public DetectSecondRconLogin(playerid)
{
if(IsPlayerAdmin(playerid))
{
if(RCON2LoggedIn[playerid] == false)
{
new
Lname[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, Lname, sizeof(Lname));
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : Delayed RCON confirmation)", Lname, playerid);
SendClientMessageToAll(0xFF0000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
}
return 1;
}
public KickPlayer(playerid) return Kick(playerid);
#include <a_samp>
#include <foreach>
main() {}
public OnRconLoginAttempt(ip[], password[], success)
{
if (success) SetTimerEx("RetrieveRconPlayer", 1000, false, "s", ip);
return 1;
}
forward OnPlayerRconLogin(playerid);
public OnPlayerRconLogin(playerid)
{
printf("OnPlayerRconLogin -> playerid (%i) has been RCON logged in!", playerid);
return 1;
}
forward RetrieveRconPlayer(ip[]);
public RetrieveRconPlayer(ip[])
{
new
ip2[16];
foreach(new i : Player)
{
GetPlayerIp(i, ip2, 16);
if (!strcmp(ip, ip2) && IsPlayerAdmin(i))
{
CallRemoteFunction("OnPlayerRconLogin", "i", i);
}
}
return 1;
}
Good work, but I've a question: Can this include be used to create an kinda of "seccond" rcon login?
|
/*______________________________________________________________________________
Lordz's Second RCON System!
Copyright© - 2014 "SecondRCON"
Author : Lordz™ AKA Lordzy
NOTE:
This script is created as a filterscript, mainly as an example for the include
"OPRL" AKA "OnPlayerRconLogin". This script ensures that the second RCON request
is only sent to the player who RCON logins, not to the players who got the same
IP address.
______________________________________________________________________________*/
#define FILTERSCRIPT
#include <a_samp>
#include <OPRL>
new
bool:RCON2LoggedIn[MAX_PLAYERS],
RCON2WrongLogins[MAX_PLAYERS];
#define SECOND_RCON_DIALOG 1126 //Dialog ID of the second RCON.
#define SECOND_RCON_PASS "testing" //Second RCON password, you can change it but keep it in quotes.
#define MAX_FALSE_2RCON_ATTEMPTS 3 //Maximum number of second RCON fails.
#define MAX_HOLD_SECONDS 120 //Maximum seconds in which a player could stay as RCON without confirming second RCON.
public OnPlayerConnect(playerid)
{
if(IsPlayerAdmin(playerid)) RCON2LoggedIn[playerid] = true;
else RCON2LoggedIn[playerid] = false;
RCON2WrongLogins[playerid] = 0;
return 1;
}
public OnFilterScriptInit()
{
for(new i; i< GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsPlayerAdmin(i)) RCON2LoggedIn[i] = true;
else RCON2LoggedIn[i] = false;
RCON2WrongLogins[i] = 0;
}
printf("-------------------------------------------------");
printf(" OnPlayerRconLogin - Second RCON system");
printf(" Loaded!");
printf("-------------------------------------------------");
return 1;
}
public OnPlayerRconLogin(playerid)
{
if(RCON2LoggedIn[playerid] == false)
{
SendClientMessage(playerid, -1, "{FF0000}Server : {880088}Before playing as RCON Administrator, please login to the second RCON option too.");
ShowPlayerDialog(playerid, SECOND_RCON_DIALOG, DIALOG_STYLE_INPUT, "Second RCON Login", "Hello,\nBefore accessing RCON, please login to the second RCON.", "Login", "");
SetTimerEx("DetectSecondRconLogin", 1000*MAX_HOLD_SECONDS, false, "d", playerid);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == SECOND_RCON_DIALOG)
{
if(response)
{
if(!strlen(inputtext))
{
RCON2WrongLogins[playerid]++;
new
string[128];
if(RCON2WrongLogins[playerid] >= MAX_FALSE_2RCON_ATTEMPTS)
{
new
Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : %d/%d)", Lname, playerid, RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessageToAll(0xFF0000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
format(string, sizeof(string), "ERROR! The previous second RCON given was incorrect! (Warnings : %d/%d)", RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessage(playerid, 0xFF0000FF, string);
return ShowPlayerDialog(playerid, SECOND_RCON_DIALOG, DIALOG_STYLE_INPUT, "Second RCON Login", "Hello,\nBefore accessing RCON, please login to the second RCON.", "Login", "");
}
if(!strcmp(inputtext, SECOND_RCON_PASS, false))
{
GameTextForPlayer(playerid, "~G~ACCESS GRANTED!", 2000, 3);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
RCON2LoggedIn[playerid] = true;
return 1;
}
else if(strcmp(inputtext, SECOND_RCON_PASS, false))
{
RCON2WrongLogins[playerid]++;
new
string[128];
if(RCON2WrongLogins[playerid] >= MAX_FALSE_2RCON_ATTEMPTS)
{
new
Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : Wrong RCON logins | %d/%d)", Lname, playerid, RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessageToAll(0xFF0000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
format(string, sizeof(string), "ERROR! The previous second RCON given was incorrect! (Warnings : %d/%d)", RCON2WrongLogins[playerid], MAX_FALSE_2RCON_ATTEMPTS);
SendClientMessage(playerid, 0xFF0000FF, string);
return ShowPlayerDialog(playerid, SECOND_RCON_DIALOG, DIALOG_STYLE_INPUT, "Second RCON Login", "Hello,\nBefore accessing RCON, please login to the second RCON.", "Login", "");
}
}
if(!response)
{
new
string[128],
Lname[MAX_PLAYER_NAME];
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : Wrong RCON login)", Lname, playerid);
SendClientMessageToAll(0xFF000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
}
return 1;
}
forward KickPlayer(playerid);
forward DetectSecondRconLogin(playerid);
public DetectSecondRconLogin(playerid)
{
if(IsPlayerAdmin(playerid))
{
if(RCON2LoggedIn[playerid] == false)
{
new
Lname[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, Lname, sizeof(Lname));
format(string, sizeof(string), "%s (ID:%d) has been automatically kicked from the server! (Reason : Delayed RCON confirmation)", Lname, playerid);
SendClientMessageToAll(0xFF0000FF, string);
return SetTimerEx("KickPlayer", 150, false, "d", playerid);
}
}
return 1;
}
public KickPlayer(playerid) return Kick(playerid);
It can be done without the need of a continuing timer and an array. I wrote this:
pawn Код:
|
[22:57:45] [join] yolo has joined the server (...) [22:57:55] RCON (In-Game): Player #1 (yolo) has logged in. [22:57:56] OnPlayerRconLogin -> playerid (1) has been RCON logged in! [22:58:09] RCON (In-Game): Player #0 (blabla) has logged in. [22:58:10] OnPlayerRconLogin -> playerid (0) has been RCON logged in! [22:58:10] OnPlayerRconLogin -> playerid (1) has been RCON logged in!
It may work, however not very well. What if there are members with same IP address who have already RCON logged in?
EDIT: I've tested your code right now to confirm well and yes I was right. It don't work well in case if there's already admins logged in as RCON with same IP address. Код:
[22:57:45] [join] yolo has joined the server (...) [22:57:55] RCON (In-Game): Player #1 (yolo) has logged in. [22:57:56] OnPlayerRconLogin -> playerid (1) has been RCON logged in! [22:58:09] RCON (In-Game): Player #0 (blabla) has logged in. [22:58:10] OnPlayerRconLogin -> playerid (0) has been RCON logged in! [22:58:10] OnPlayerRconLogin -> playerid (1) has been RCON logged in! |
#include <a_samp>
#include <foreach>
static
bool: Player_Rcon[MAX_PLAYERS char];
main() {}
public OnPlayerConnect(playerid)
{
Player_Rcon{playerid} = false;
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
if (success) SetTimerEx("RetrieveRconPlayer", 1000, false, "s", ip);
return 1;
}
forward OnPlayerRconLogin(playerid);
public OnPlayerRconLogin(playerid)
{
printf("OnPlayerRconLogin -> playerid (%i) has been RCON logged in!", playerid);
return 1;
}
forward RetrieveRconPlayer(ip[]);
public RetrieveRconPlayer(ip[])
{
new
ip2[16];
foreach(new i : Player)
{
GetPlayerIp(i, ip2, 16);
if (!strcmp(ip, ip2) && !Player_Rcon{i} && IsPlayerAdmin(i))
{
Player_Rcon{i} = true;
CallRemoteFunction("OnPlayerRconLogin", "i", i);
}
}
return 1;
}
Heyhey! http://pastebin.com/Px5SMVcc. (BY: ENZOMETLC ON JAN 23RD, 2014).
You stole the idea from me! Nice work and include ^^. |
• Include has been optimized! Thanks to Konstantinos for showing a better method to callout "OnPlayerRconLogin"
for(new i; i< GetMaxPlayers(); i++)
for(new i, j = GetMaxPlayers(); i< j; i++)