SAMP ban system, why not?
#9

If you intend to let staff set the ban time, here's a short snippet for quickly grabbing an English string and converting it to seconds. It's a rather crude and basic parser but it does a decent job. Interprets (value) (unit) such as "1 week", "3 days", "1 day", etc:

pawn Код:
GetDurationFromString(string[])
{
    new
        value,
        type[16];

    if(sscanf(string, "ds[16]", value, type))
        return -1;

    if(value <= 0)
        return -1;

    if(!strcmp(type, "day", true, 3)) // only check 3 chars, technically "days" works, so does "daytona"...
        return value * 86400;

    if(!strcmp(type, "week", true, 4))
        return value * 604800;

    if(!strcmp(type, "month", true, 5))
        return value * 2628000;

    return -1;
}
Reply


Messages In This Thread
SAMP ban system, why not? - by Evocator - 21.02.2015, 17:27
Re: SAMP ban system, why not? - by Puppy - 21.02.2015, 17:46
Re: SAMP ban system, why not? - by PowerPC603 - 23.02.2015, 00:03
Re: SAMP ban system, why not? - by Vince - 23.02.2015, 17:49
Re: SAMP ban system, why not? - by PowerPC603 - 23.02.2015, 18:57
Re: SAMP ban system, why not? - by HeLiOn_PrImE - 23.02.2015, 21:59
Re: SAMP ban system, why not? - by cessil - 24.02.2015, 01:00
Re: SAMP ban system, why not? - by PowerPC603 - 24.02.2015, 10:34
Re: SAMP ban system, why not? - by [HLF]Southclaw - 24.02.2015, 15:57

Forum Jump:


Users browsing this thread: 2 Guest(s)