Guest User

RCON Security by: EvanA

a guest
Dec 25th, 2013
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.35 KB | None | 0 0
  1. /* RCON Protection/Security By: EvanA */
  2. /* Use /togglercon to enable/disable the ability to login to RCON. */
  3.  
  4. #include <a_samp>
  5. #include ZCMD
  6. #include foreach
  7. #define DIALOG_RCON 25
  8. // #define MAX_PLAYERS 500 // Change this to your Player Slot Amount.
  9. #define MAX_PLAYER_IP 32
  10. #define rconpass 02908929389378387 // This is your secondary RCON Login code. Change it to whatever you want :), TIP: Make it challenging to guess.
  11. new RconAttempts[MAX_PLAYERS] = 0;
  12. new RCONEnabled = 0;
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     print("\n--------------------------------------");
  17.     print("Evan's RCON Security Loaded.");
  18.     print("--------------------------------------\n");
  19.     return 1;
  20. }
  21.  
  22. public OnFilterScriptExit()
  23. {
  24.     return 1;
  25. }
  26.  
  27. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  28. {
  29.     if(dialogid == DIALOG_RCON)
  30.     {
  31.         if(!response)
  32.         {
  33.             SendClientMessage(playerid, -1, "You must enter the secondary rcon pass-code to login.");
  34.             Kick(playerid);
  35.         }
  36.         else {
  37.             if(inputtext[30] == rconpass) {
  38.             {
  39.                 SendClientMessage(playerid, -1, "You are now logged in as RCON Admin!");
  40.             }
  41.             if(strcmp(inputtext) != rconpass) { ShowPlayerDialog(playerid,DIALOG_RCON, DIALOG_STYLE_INPUT, "RCON", "Enter the secondary passcode below.", "Authorize", "Cancel"); }
  42.             }
  43.         }
  44.         return 1;
  45.     }
  46.     return 0;
  47. }
  48.  
  49. public OnRconLoginAttempt(ip[], password[], success)
  50. {
  51.     new tempip[MAX_PLAYER_IP], playerid;
  52.     foreach(Player, i) {
  53.         GetPlayerIp(i, tempip, sizeof(tempip));
  54.         if(strcmp(tempip, ip) == 0) {
  55.             playerid = i;
  56.         }
  57.     }
  58.    
  59.     if(success && RCONEnabled == 0) {
  60.       ShowPlayerDialog(playerid,DIALOG_RCON, DIALOG_STYLE_INPUT, "RCON", "Enter the secondary passcode below:", "Authorize", "Cancel");
  61.     } else {
  62.         if(RconAttempts[playerid] < 3) RconAttempts[playerid]++;
  63.         else Kick(playerid);
  64.     }
  65.     return 1;
  66. }
  67.  
  68. CMD:togglercon(playerid, params[])
  69. {
  70.  if(IsPlayerAdmin(playerid))
  71.  {
  72.        if(RCONEnabled == 0)
  73.         {
  74.             SendClientMessage(playerid, -1, "You have disabled logging into RCON. Use /togglercon to enable it again");
  75.             RCONEnabled = 1;
  76.         }
  77.         else
  78.         {
  79.             SendClientMessage(playerid, -1, "You have enabled logging into RCON. Use /togglercon to enable it again");
  80.             RCONEnabled = 0;
  81.         }
  82.   }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment