Stuneris

[Squirrel]Rcon admin system

Dec 27th, 2011
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. /* Local variables */
  2. local PlayerRCON = array(getPlayerSlots(), false);
  3. local rconpassword;
  4.  
  5. /* Functions */
  6. function OnPlayerConnect(playerid)
  7. {
  8.     PlayerRCON[playerid] = false;
  9.     return 1;
  10. }
  11.  
  12. function OnScriptInit()
  13. {  
  14.     local config = getConfig();
  15.     if(config.rawin("rconpassword")) foreach(i, message in config.rconpassword) rconpassword = message;
  16.     log("\nScript by Stuneris loaded!\n");
  17.     return 1;
  18. }
  19.  
  20. function OnPlayerCommandText(playerid, commandtext)
  21. {
  22.  
  23.     if(commandtext == "/login")
  24.     {
  25.         if(!IsPlayerAdmin(playerid))
  26.         {
  27.             local pass = command.slice(12);
  28.             if(pass == rconpassword)
  29.             {
  30.                 PlayerRCON[playerid] = true;
  31.                 sendPlayerMessage(playerid, "Slaptažodis teisingas, sėkmingai prisijungėte į administratoriaus statusą.", GREEN);
  32.             }
  33.             else
  34.             {
  35.                 sendPlayerMessage(playerid, "Slaptažodis neteisingas!", RED);
  36.             }
  37.         }
  38.     }
  39.    
  40.     if(commandtext == "/a")
  41.     {
  42.         if(IsPlayerAdmin(playerid))
  43.         {
  44.             if(cmd.len() < 3) return 0;    
  45.             local text = command.slice(10);
  46.             sendMessageToAll("[ADMIN] " + getPlayerName(playerid) + ": " + text, GREEN);
  47.         }
  48.     }
  49.    
  50.     if(commandtext == "/kick")
  51.     {  
  52.         if(IsPlayerAdmin(playerid))
  53.         {
  54.             local player = cmd[2].tointeger();
  55.             if(!isPlayerConnected(player)) return 1;
  56.             kickPlayer(player, true);
  57.             sendMessageToAll("[KICK]: " + getPlayerName(player) + " IP: " + getPlayerIp(player), RED);
  58.         }
  59.     }
  60.    
  61.     if(commandtext == "/ban")
  62.     {
  63.         if(IsPlayerAdmin(playerid))
  64.         {
  65.             local player = cmd[2].tointeger();
  66.             if(!isPlayerConnected(player)) return 1;
  67.             banPlayer(player, 0);
  68.             sendMessageToAll("[BAN]: " + getPlayerName(player) + " IP: " + getPlayerIp(player), RED);
  69.         }
  70.     }
  71.     return 0;
  72. }
  73.  
  74. function IsPlayerAdmin(playerid)
  75. {
  76.     if(PlayerRCON[playerid] == true) return true;
  77.     return false;
  78. }
  79.  
  80. /* Add Events */
  81. addEvent("playerCommandText", OnPlayerCommandText);
  82. addEvent("scriptInit", OnScriptInit);
  83. addEvent("playerConnect", OnPlayerConnect);
Advertisement
Add Comment
Please, Sign In to add comment