ChaoticTheDev

Server Lock command

Jan 5th, 2020
2,275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.27 KB | None | 0 0
  1. new bool:ShutDown; // Add this to the top of your script
  2.  
  3. // This is your command, change the RCON Admin restriction if you want to; up to you.
  4.  
  5. CMD:lockserver(playerid, params[])
  6. {
  7.     if(!IsPlayerAdmin(playerid))
  8.         return SendClientMessage(playerid, -1, "Notice: You don't have access to this command.");
  9.  
  10.     new string[200];
  11.  
  12.     if(ShutDown)
  13.     {
  14.         ShutDown = false;
  15.         SendRconCommand("password 0");
  16.         SendRconCommand("hostname YourServerNameHere");
  17.         format(string, sizeof(string), "Notice: %s unlocked the server.", ReturnName(playerid));
  18.         SendClientMessageToAll(-1, string);
  19.     }
  20.     else
  21.     {
  22.         ShutDown = true;
  23.         SendRconCommand("password YourPasswordHere");
  24.         SendRconCommand("hostname YourServerNameHere [Locked]");
  25.         format(string, sizeof(string), "Notice: %s locked the server.", ReturnName(playerid));
  26.         SendClientMessageToAll(-1, string);
  27.     }
  28.     return 1;
  29. }
  30.  
  31. // This is the stock that returns the name of a player connected to the server, with the use of their ID.
  32. // If you already have a stock like this in your gamemode, you can do the replacements and configurations.
  33.  
  34. stock ReturnName(playerid)
  35. {
  36.     new name[90], character[MAX_PLAYER_NAME];
  37.     GetPlayerName(playerid, character, sizeof(character));
  38.     name = character;
  39.     return name;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment