Tempban - command!?
#1

A'iight, I tried it for weeks now, I don't GET how to script a tempban-command! There should be 1 - 23 hours available to ban a player, I just don't get how to script it. This is a request, by the way, I have no clue on how to script it. Thanks!
Reply
#2

pawn Код:
//tempBanned command
new HoursBanned,
    BannedTill = (HoursBanned*60*60*1000)+GetTickCount();

    //save here BannedTillinside file
    //and in his file make variable tempBanned = 1;
    Kick(playerid);
   
//under on player connect
if(/*loading tempbanned here*/ == 1 && /*loading BannedTill fro file*/ ? GetTickCount()) Kick(playerid); //his tempban didn't restart yet.
Thing is when you restart server it all restarts
Reply
#3

Everyone I asked told me the same as you until yet, I exactly don't get the places where you commented, lol.
Reply
#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
#5

Alright, thank you! Since I'm not very familiarized with saving systems (and I'm using INI (SII)), could you convert those lines into my case? Would be cool, then I could experiment with it!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)