Advertisement
ChearTmans

[uScript] Admin Password

Feb 25th, 2020
1,884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.24 KB | None | 0 0
  1. scriptTitle = "<color=cyan>[ADMIN]</color> <color=orange>[PASSWORD]</color>";
  2.  
  3. transEmpty = "Please enter a password.";
  4. transSuccess = "Admin authority was successfully granted.";
  5. transWrong = "The password you entered is not valid. Please try again.";
  6. transTargetEmpty = "Please enter a player you want to admin.";
  7. transTargetSuccess = "Admin successfully granted to you.";
  8. transTargetIsAdmin = "The person you want to authorize is already Admin.";
  9.  
  10. transUnSuccess = "Successfully received Admin authorization.";
  11. transUnTargetEmpty = "Please enter a player for which you want to get admin authority.";
  12. transUnTargetSuccess = "Your Admin authorization has been successfully received.";
  13. transUnTargetIsAdmin = "The person you want to authorize is not Admin.";
  14.  
  15. adminPassword = "testPassword";
  16.  
  17. command admin(){
  18.     permission = "admin";
  19.     execute(){
  20.         isAdminSet(player.id, arguments[0], arguments[1], 1);
  21.     }
  22. }
  23.  
  24. command unadmin(){
  25.     permission = "unadmin";
  26.     execute(){
  27.         isAdminSet(player.id, arguments[0], arguments[1], 2);
  28.     }
  29. }
  30.  
  31. function isAdminSet(player, target, password, type){
  32.     player = toPlayer(player);
  33.    
  34.     if(target == "a"){
  35.         if(type == 1){
  36.             player.message(scriptTitle + " " + transTargetEmpty);
  37.         }
  38.         else if (type == 2){
  39.             player.message(scriptTitle + " " + transUnTargetEmpty);
  40.         }
  41.         return;
  42.     }
  43.    
  44.     target = toPlayer(target);
  45.    
  46.     if(type == 1){
  47.         if(target.isAdmin == true){
  48.             player.message(scriptTitle + " " + transTargetIsAdmin);
  49.             return;
  50.         }
  51.     }
  52.     else if (type == 2){
  53.         if(target.isAdmin == false){
  54.             player.message(scriptTitle + " " + transUnTargetIsAdmin);
  55.             return;
  56.         }
  57.     }
  58.    
  59.     if(password == "a"){
  60.         player.message(scriptTitle + " " + transEmpty);
  61.         return;
  62.     }
  63.        
  64.     if(password == adminPassword){
  65.         if(type == 1){
  66.             target.isAdmin = true;
  67.             if(player.id != target.id){
  68.                 target.message(scriptTitle + " " + transTargetSuccess);
  69.             }
  70.             player.message(scriptTitle + " " + transSuccess);
  71.         }
  72.         else if (type == 2){
  73.             target.isAdmin = false;
  74.             if(player.id != target.id){
  75.                 target.message(scriptTitle + " " + transUnTargetSuccess);
  76.             }
  77.             player.message(scriptTitle + " " + transUnSuccess);
  78.         }
  79.     }
  80.     else{
  81.         player.message(str.format("{0} <color=red>{1}</color>", scriptTitle, transWrong));
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement