server lock - 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: server lock (
/showthread.php?tid=559448)
server lock -
Karolukas123 - 23.01.2015
Hello , me they should have such a thing as a server lock for 1 minute and automatic unlocking after 1 minute. How to do it?
Re: server lock -
biker122 - 23.01.2015
You need sscanf and zcmd to run and use this.
pawn Код:
new gLockTimer;
CMD:lockserver(playerid, params[])
{
new password[20], seconds, str[60];
if(sscanf(params, "s[20]i", password, seconds)) return SendClientMessage(playerid, -1, "Usage: /lockserver [password] [seconds]");
format(str, 60, "You have successfully locked the server with the password %s!", password);
SendClientMessage(playerid, -1, str);
format(str, 30, "password %s", password);
SendRconCommand(str);
KillTimer(gLockTimer), gLockTimer = SetTimer("UnlockServer", seconds*1000, 0);
return 1;
}
forward UnlockServer();
public UnlockServer()
{
SendRconCommand("password 0");
KillTimer(gLockTimer);
return 1;
}
Re: server lock -
Karolukas123 - 23.01.2015
Yes, i have made one command to lock, but i need to show that how much its left on server name
Server: Testing Land [Lock 60] and so far lock 59,58,57
Re: server lock -
biker122 - 23.01.2015
pawn Код:
new gLockTimer, ServerLocked = 0, LockSeconds = -1;
CMD:lockserver(playerid, params[])
{
new password[20], minutes, str[60];
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "s[20]i", password, seconds)) return SendClientMessage(playerid, -1, "Usage: /lockserver [password] [seconds]");
format(str, 60, "You have successfully locked the server with the password %s!", password);
SendClientMessage(playerid, -1, str);
format(str, 30, "password %s", password);
KillTimer(gLockTimer), gLockTimer = SetTimer("ServerLockTimeUpdater", 1000, 1);
SendRconCommand(str), ServerLocked = 1, LockSeconds = seconds;
return 1;
}
forward ServerLockTimeUpdater();
public ServerLockTimeUpdater()
{
LockSeconds--;
if(LockSeconds <= -1) return SendRconCommand("password 0"), KillTimer(gLockTimer), LockSeconds = -1, ServerLocked = 0;
new str[30];
format(str, 30, "hostname Server locked for: %i seconds", LockSeconds);
SendRconCommand(str);
return 1;
}