SA-MP Forums Archive
Tempban - command!? - 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: Tempban - command!? (/showthread.php?tid=336126)



Tempban - command!? - Twisted_Insane - 21.04.2012

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!


Re: Tempban - command!? - [MG]Dimi - 21.04.2012

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


Re: Tempban - command!? - Twisted_Insane - 21.04.2012

Everyone I asked told me the same as you until yet, I exactly don't get the places where you commented, lol.


AW: Re: Tempban - command!? - Nero_3D - 21.04.2012

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



Re: Tempban - command!? - Twisted_Insane - 21.04.2012

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!