Ban Length CMD
#1

Hello, so I've searched everywhere, with no luck, to try and find a tutorial or command that might help me with what I am after.

Basically I want to make my /ban command syntax to be /ban [length] - (1w/1m/1h) [id/name] [reason].

Where:
- 1w = 1 week;
- 1m = 1 month;
- 1h = 1 hour and so on.

I am using sscanf to break down the parameters, but can't seem to find out how to make it detect the length.

Any help would be appreciated.

Thanks,
CM707
Reply
#2

MySQL or INI
Reply
#3

Quote:
Originally Posted by arlindi
Посмотреть сообщение
MySQL or INI
Just curious, did you even read the question?
Reply
#4

pawn Код:
CMD:ban(playerid, params[]) {
    new banId, banLen[12], banX, banT, banTimestamp;

    if (sscanf(params, "us[12]", banId, banLen))
        return SendClientMessage(playerid, -1, "Usage: /ban [id/name] Xy/Xm/Xd/Xh/Xm - X = number");

    if (!IsPlayerConnected(banId))
        return SendClientMessage(playerid, -1, "Invalid player.");

    if (!(banX = strval(banLen)))
        return SendClientMessage(playerid, -1, "Usage: /ban [id/name] Xy/Xm/Xd/Xh/Xm - X = number");

    for (new i = -1; banLen[++ i] != '\0' ;) {
        switch (banLen[i]) {
            case 'y', 'm', 'd', 'h': {
                banT = ((banLen[i] == 'y') ? 31536000 : ((banLen[i] == 'm') ? 2592000 : ((banLen[i] == 'd') ? 86400 : ((banLen[i] == 'h') ? 3600 : 60))));
                printf("debug: LOOP\r\n");
                break;
            }
        }
    }

    if (!banT)
        return SendClientMessage(playerid, -1, "Usage: /ban [id/name] Xy/Xm/Xd/Xh/Xm - X = number");

    banTimestamp = gettime() + (banT * banX);

    printf("debug: TS: %d | banT: %d | banX: %d\r\n", banTimestamp, banT, banX);

    // ban them
    // ban length should be banTimestamp
    // OnPlayerConnect fetch banTimestamp and compare like
    // if (banTimestamp <= gettime())
    // if so then unban them
    // else kick because they're still banned
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)