/Unlockserver Command Correct? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /Unlockserver Command Correct? (
/showthread.php?tid=675688)
/Unlockserver Command Correct? -
RainW - 18.05.2020
Hello i created my /unlockserver Command
is this Correct?
Code:
CMD:unlockserver(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] == 99999)
{
new string[128],name[50];
GetPlayerName(playerid,name,sizeof(name));
// if(ServerLocked)
{
// ServerLocked = false;
SendRconCommand("password 0");
SendRconCommand("hostname Neterval Roleplay ");
format(string, sizeof(string), "{FF0000}ADMCMD:{FF6347}Server Director %s unlocked the server.",name);
SendClientMessageToAll(COLOR_WHITE, string);
}
}
else return SendClientMessage(playerid, COLOR_RED, " You are not authorized to use this Command!");
return 1;
}
Re: /Unlockserver Command Correct? -
XStormiest - 18.05.2020
Yes, it is correct.
Re: /Unlockserver Command Correct? -
EternalDirection - 21.05.2020
No, it is not. You shouldn't have commented line 7 on that code.
Here, it is the optimized one:
Code:
CMD:unlockserver(playerid, params[]) {
if (PlayerInfo[playerid][pAdmin] == 99999) {
if (ServerLocked) {
new string[87], name[24];
GetPlayerName(playerid, name, sizeof(name));
ServerLocked = false; // unlock
SendRconCommand("password 0");
SendRconCommand("hostname Neterval Roleplay");
format(string, sizeof(string), "{FF0000}ADMCMD:{FF6347}Server Director %s unlocked the server.", name);
SendClientMessageToAll(COLOR_WHITE, string);
} else
SendClientMessage(playerid, COLOR_WHITE, "The server is not locked.");
} else
SendClientMessage(playerid, COLOR_RED, " You are not authorized to use this command!");
return 1;
}