[Tutorial] How to: Unix timestamps
#6

I've added a list of calculations now, so it should be a bit more clear, but for your predicament, if you had a command with the syntax of '/tempban [playerid] [years] [weeks] [days] [hours]' then you'd have to do something like this:

pawn Code:
CMD:tempban(playerid, params[]) {
    new
        iYears,
        iMonths,
        iFinalCalculation = gettime(),
        iHours,
        iWeeks,
        iTarget;


    if(sscanf(params, "udddddds", iTarget, iYears, iMonths, iWeeks, iDays, iHours, iMinutes, szReason))
        return SendClientMessage(playerid, COLOR, "Syntax: /tempban [playerid] [years] [months] [weeks] [days] [hours] [minutes] [reason]");


    iFinalCalculation = gettime() + mktime(iHours, iMinutes, 0, iDays, iMonths, iYears); // get mktime() from here: http://y-less.pastebin.ca/1000201
       
    // iFinalCalculation retains the final unix timestamp you'll set them to be banned for.
    // Check when a player connects to see if they have a timestamp, and if they do, check if it exceeds gettime()
    // ...if it does, then unban/remove ban
       
    return 1;
}
Reply


Messages In This Thread
How to: Unix timestamps - by __ - 13.05.2011, 15:22
Re: How to: Unix timestamps - by CrunkBankS - 13.05.2011, 16:58
Re: How to: Unix timestamps - by [03]Garsino - 13.05.2011, 17:11
Re: How to: Unix timestamps - by __ - 13.05.2011, 17:39
Re: How to: Unix timestamps - by [03]Garsino - 13.05.2011, 17:43
Re: How to: Unix timestamps - by __ - 13.05.2011, 17:58
Re: How to: Unix timestamps - by Zimon95 - 13.05.2011, 18:34
Re: How to: Unix timestamps - by __ - 14.05.2011, 10:10
Re: How to: Unix timestamps - by Haydz - 16.05.2011, 10:52
Re: How to: Unix timestamps - by linuxthefish - 16.05.2011, 11:40
Re: How to: Unix timestamps - by Swiftz - 16.05.2011, 15:47
Re: How to: Unix timestamps - by Zimon95 - 16.05.2011, 17:57
Re: How to: Unix timestamps - by __ - 17.05.2011, 08:39
Re: How to: Unix timestamps - by Blacklite - 19.05.2011, 00:23
Re: How to: Unix timestamps - by __ - 19.05.2011, 10:04
Re: How to: Unix timestamps - by BaubaS - 19.05.2011, 14:30
Re: How to: Unix timestamps - by __ - 19.05.2011, 14:42
Re: How to: Unix timestamps - by BaubaS - 19.05.2011, 16:38
Re: How to: Unix timestamps - by Blacklite - 19.05.2011, 22:00
Re: How to: Unix timestamps - by Scenario - 14.06.2011, 19:30
Re: How to: Unix timestamps - by Anzipane! - 14.06.2011, 20:39
Re: How to: Unix timestamps - by Blacklite - 14.06.2011, 21:14
Re: How to: Unix timestamps - by jot16 - 14.06.2011, 21:17
Re: How to: Unix timestamps - by Jack_Rocker - 14.06.2011, 21:20
Re: How to: Unix timestamps - by Iphone1234g - 15.06.2011, 09:41
Re: How to: Unix timestamps - by __ - 17.06.2011, 23:08
Re: How to: Unix timestamps - by Steamator - 20.06.2011, 14:45
Re: How to: Unix timestamps - by ||123|| - 14.07.2011, 07:26
Re: How to: Unix timestamps - by cessil - 14.07.2011, 12:50
Re: How to: Unix timestamps - by __ - 15.07.2011, 05:39
Re: How to: Unix timestamps - by Jantjuh - 16.07.2011, 19:49
Re: How to: Unix timestamps - by BrUn3S - 18.10.2011, 18:59
Re: How to: Unix timestamps - by Scenario - 17.12.2011, 00:28
Re: How to: Unix timestamps - by Rokzlive - 07.01.2012, 20:02
Re: How to: Unix timestamps - by Scenario - 07.01.2012, 20:07
Re: How to: Unix timestamps - by Rokzlive - 07.01.2012, 20:14
Re: How to: Unix timestamps - by Calgon - 23.03.2012, 10:42
Re: How to: Unix timestamps - by __ - 15.06.2012, 07:19
Re: How to: Unix timestamps - by Tanush123 - 22.05.2013, 21:03
Re: How to: Unix timestamps - by trukker1998 - 19.02.2014, 11:35
Re: How to: Unix timestamps - by Scenario - 19.02.2014, 11:53
Re: How to: Unix timestamps - by AroseKhanNiazi - 01.03.2014, 11:38
Re: How to: Unix timestamps - by _Application_ - 20.01.2015, 11:20
Re: How to: Unix timestamps - by PowerPC603 - 20.01.2015, 13:37
Re: How to: Unix timestamps - by AdamCooper - 07.10.2018, 00:45

Forum Jump:


Users browsing this thread: 1 Guest(s)