Tempban - command!?
#4

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Thing is when you restart server it all restarts
Therefore you normally use the unix timestamp

I am using as example the dudb file system, so its quite clear what the code does
pawn Код:
CMD:tempban(playerid, params[]) {
    new
        id,
        hours
    ;
    if(sscanf(params, "uis", id, hours, params)) {
        SendClientMessage(playerid, -1, "Usage: \"/ban <playerid><hours><reason>\"");
    } else {
        if(id == INVALID_PLAYER_ID) {
            SendClientMessage(playerid, -1, "Player not found");
        } else {
            if(0 < hours < 24) {
                // some nice messages to the players
                // the unix timestap is in seconds, so we convert the hours to seconds
                dUserSetINT(PlayerName(id)).("ban", (gettime() + (hours * 60 * 60)));
                Kick(id);
            } else {
                SendClientMessage(playerid, -1, "You can only ban him for 1 - 23 hours!");
            }
        }
    }
    return true;
}
pawn Код:
// OnPlayerConnect
    new
        banned = dUserINT(PlayerName(playerid)).("ban")
    ;
    if(banned) {
        if(banned == 1) { // default ban without time
            Kick(playerid);
        } else {
            if(banned < gettime()) { // reset his ban
                dUserSetInt(PlayerName(playerid)).("ban", 0);
            } else { // if the time hasnt passed kick him
                Kick(playerid);
            }
        }
    }
Reply


Messages In This Thread
Tempban - command!? - by Twisted_Insane - 21.04.2012, 10:00
Re: Tempban - command!? - by [MG]Dimi - 21.04.2012, 10:06
Re: Tempban - command!? - by Twisted_Insane - 21.04.2012, 10:13
AW: Re: Tempban - command!? - by Nero_3D - 21.04.2012, 10:46
Re: Tempban - command!? - by Twisted_Insane - 21.04.2012, 10:54

Forum Jump:


Users browsing this thread: 2 Guest(s)