Advertisement
Guest User

Lazarus

a guest
Feb 17th, 2009
2,989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. forward AfterPlayerConnect(playerid);
  4. forward ChangeRCONPassword();
  5.  
  6. enum pInfo
  7. {
  8.     bool:SCON
  9. }
  10.  
  11. new PlayerInfo[MAX_PLAYERS][pInfo];
  12. new pass[20];
  13.  
  14. #define white 0xFFFFFFFF
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     GetServerVarAsString("rcon_password", pass, sizeof(pass));
  19.     SetTimer("ChangeRCONPassword", 2000, 1);
  20.     return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25.     new string[39];
  26.     format(string, sizeof(string), "rcon_password %s", pass);
  27.     SendRconCommand(string);
  28.     return 1;
  29. }
  30.  
  31. public OnPlayerConnect(playerid)
  32. {
  33.     SetTimerEx("AfterPlayerConnect", 1000, 0, "i", playerid);
  34.     return 1;
  35. }
  36.  
  37. public AfterPlayerConnect(playerid)
  38. {
  39.     PlayerInfo[playerid][SCON] = false;
  40.     return 1;
  41. }
  42.  
  43. public OnPlayerCommandText(playerid, cmdtext[])
  44. {
  45.     if(strcmp("/scon login", cmdtext, true, 11) == 0)
  46.     {
  47.         new string[36];
  48.         if(strlen(cmdtext[12]) == 0) return 1;
  49.         format(string, sizeof(string), "/scon login %s", pass);
  50.        
  51.         if(strcmp(cmdtext, string, true) == 0)
  52.         {
  53.             PlayerInfo[playerid][SCON] = true;
  54.             SendClientMessage(playerid, white, "SCON: You have logged in as admin.");
  55.         }
  56.         return 1;
  57.     }
  58.    
  59.     if(strcmp("/scon", cmdtext, true, 5) == 0)
  60.     {
  61.         if(strlen(cmdtext[6]) == 0) return 1;
  62.         if(cmdtext[6] == ' ') return 1;
  63.    
  64.         if(PlayerInfo[playerid][SCON] == true)
  65.         {
  66.             new string[128];
  67.             SendRconCommand(cmdtext[6]);
  68.             format(string, sizeof(string), "SCON: RCON Command \" %s \" sent", cmdtext[6]);
  69.             SendClientMessage(playerid, white, string);
  70.         }
  71.         return 1;
  72.     }
  73.     return 0;
  74. }
  75.  
  76. public ChangeRCONPassword()
  77. {
  78.     new string[39], password[25];
  79.  
  80.     new letters[][] =
  81.     {
  82.         "a", "b", "c", "d",
  83.         "e", "f", "g", "h",
  84.         "i", "j", "k", "l",
  85.         "m", "n", "o", "p",
  86.         "q", "r", "s", "t",
  87.         "u", "v", "w", "x",
  88.         "y", "z"
  89.     };
  90.  
  91.     new bool:numlet = false;
  92.    
  93.     for(new i = 0; i < 20; i++)
  94.     {
  95.         if(numlet == false)
  96.         {
  97.             new number = random(10);
  98.             format(string, sizeof(string), "%d", number);
  99.             strins(password, string, i, 1);
  100.             numlet = true;
  101.         }
  102.         else if(numlet == true)
  103.         {
  104.             new letter = random(26);
  105.             strins(password, letters[letter], i, 1);
  106.             numlet = false;
  107.         }
  108.     }
  109.  
  110.     format(string, sizeof(string), "rcon_password %s", password);
  111.     SendRconCommand(string);
  112.    
  113.     //print(string);
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement