Why does this happen... Please help
#5

Use this!

pawn Код:
new expireDays = (86400*days)+gettime();

// Example, I want the vip expire in 30 days.

dini_IntSet(account, "donatorExpire", (86400*30)+gettime());


// Checking if already pass 30 days

new atualTimer = dini_Int(account, "donatorExpire");
if( atualTimer < gettime() ){
   // Your donator is out!
}
else {
   new iRandomTime = (atualTimer-gettime())+gettime();                
   format(string, 128, "Your donator will expire in %d days", timec(iRandomTime));
}



/// End of gm

stock timec(timestamp, compare = -1) {
    if (compare == -1) {
        compare = gettime();
    }
    new
        n,
        // on the following line, I have removed the need for the diff() function.
        // if you want to use the diff() function in pawn, replace the following with:
        // Float:d = diff(timestamp, compare),
        Float:d = (timestamp > compare) ? timestamp - compare : compare - timestamp,
        returnstr[32];
    if (d < 60) {
        format(returnstr, sizeof(returnstr), "< 1 minuto");
        return returnstr;
    } else if (d < 3600) { // 3600 = 1 hour
        n = floatround(floatdiv(d, 60.0), floatround_floor);
        format(returnstr, sizeof(returnstr), "minuto");
    } else if (d < 86400) { // 86400 = 1 day
        n = floatround(floatdiv(d, 3600.0), floatround_floor);
        format(returnstr, sizeof(returnstr), "hora");
    } else if (d < 2592000) { // 2592000 = 1 month
        n = floatround(floatdiv(d, 86400.0), floatround_floor);
        format(returnstr, sizeof(returnstr), "dia");
    } else if (d < 31536000) { // 31536000 = 1 year
        n = floatround(floatdiv(d, 2592000.0), floatround_floor);
        format(returnstr, sizeof(returnstr), "mкs");
    } else {
        n = floatround(floatdiv(d, 31536000.0), floatround_floor);
        format(returnstr, sizeof(returnstr), "ano");
    }
    if (n == 1) {
        format(returnstr, sizeof(returnstr), "1 %s", returnstr);
    } else {
        format(returnstr, sizeof(returnstr), "%d %ss", n, returnstr);
    }
    return returnstr;
}
I hope this is useful for you
Reply


Messages In This Thread
Why does this happen... Please help - by Euan Hughes - 01.07.2012, 23:10
Respuesta: Why does this happen... Please help - by PHudson - 01.07.2012, 23:16
Re: Respuesta: Why does this happen... Please help - by Vince - 01.07.2012, 23:18
Re: Why does this happen... Please help - by Euan Hughes - 01.07.2012, 23:25
Re: Why does this happen... Please help - by Ricop522 - 02.07.2012, 00:19
Re: Why does this happen... Please help - by Euan Hughes - 02.07.2012, 00:25
Re: Why does this happen... Please help - by Tee - 02.07.2012, 02:09

Forum Jump:


Users browsing this thread: 2 Guest(s)