AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Calculate days (https://forums.alliedmods.net/showthread.php?t=155715)

killergirl 04-25-2011 19:52

Calculate days
 
I think the topic title says it all. I'm trying to find a way to calculate days before the the plugin prune the vault file.

Here is my code:
PHP Code:

public test(idlvlcid)
{
    if(!
cmd_access(idlvlcid3))
        return 
PLUGIN_HANDLED
    
    
new arg[32], Value[32], TimeStamp
    
    
new dMonthdDaydYeardHourdMinutedSecond
    
new iMonthiDayiYeariHouriMinuteiSecond
    
    read_argv
(1arg31)
    
read_argv(2Value31)
    
    new 
data nvault_lookup(x_VaultargValue31TimeStamp)
    
    if(
data)
    {
        new 
CreateDate TimeStamp
        
new iUnixTime = ( TimeStamp + (10 86400) )
        
        
UnixToTimeCreateDate dYear dMonth dDay dHour dMinute dSecond )
        
UnixToTimeiUnixTime iYear iMonth iDay iHour iMinute iSecond )
        
        
console_print(id"Created: = %02d/%02d/%02d %02d:%02d:%02d" dYear dMonth dDay dHour dMinute dSecond )
        
console_print(id"Prune: = %02d/%02d/%02d %02d:%02d:%02d" iYear iMonth iDay iHour iMinute iSecond )
        
        new 
HowToCalculateDays = ???
        
        
console_print(id"Day's remaining to prune x_Vault: %d"HowToCalculateDays)
    }
    else
    {
        
        
console_print(id"No existing data !")
    }
    return 
PLUGIN_HANDLED



Exolent[jNr] 04-25-2011 20:04

Re: Calculate days
 
Code:
new iTotalSecondsLeft = iUnixTime - CreateDate; new iDaysLeft = iTotalSecondsLeft / 86400;

fysiks 04-25-2011 20:07

Re: Calculate days
 
Code:

iDays_until_FutureDate = (iFutureDateTimestamp - iNowDateTimestamp) / 86400
Edit: Guess I should refresh before posting :)

killergirl 04-27-2011 07:08

Re: Calculate days
 
Oh, thank you it's working but not the how I want. The plugin calculates the day's when will prune the vault file, and not how many day's remaing to prune.

e.g

Created on: 11/05/2011
Prune on: 21/05/2011
Current day: 15/05/2011

Days remaing before pruning: 6

Exolent[jNr] 04-27-2011 14:51

Re: Calculate days
 
Code:
new iTotalSecondsLeft = iUnixTime - get_systime(); new iDaysLeft = iTotalSecondsLeft / 86400;

fysiks 04-27-2011 18:27

Re: Calculate days
 
Guess s/he didn't feel like reading my post . . .


All times are GMT -4. The time now is 19:54.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.