server lock
#1

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?
Reply
#2

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;
}
Reply
#3

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
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)