Scripting/Squirrel/Client Functions/System::GetDate

From Vice City Multiplayer
Revision as of 16:52, 28 September 2018 by Human. (talk | contribs) (Created page with "This function returns a table containing a date/time splitted in the slots. It follows same syntax as the Squirrel standard library's date function: [http://squirrel-lang.org/...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

This function returns a table containing a date/time splitted in the slots. It follows same syntax as the Squirrel standard library's date function: [1]

Syntax

System.GetDate([time], [format]])

time and format are optional.

Return type

table

Name Description
sec Seconds after minute (0 - 59)
min Minutes after hour (0 - 59)
hour Hours since midnight (0 - 23)
day Day of month (1 - 31)
month Month (0 - 11; January = 0)
year Year (current year)
wday Day of week (0 - 6; Sunday = 0)
yday Day of year (0 - 365; January 1 = 0)

Example

/* Player::PlayerDeath is triggered whenever someone die */
function Player::PlayerDeath( player ) 
{
      /* Check whether the player that just died is local player/self */
      if ( player.ID == World.FindLocalPlayer().ID )
      {
            local now = System.GetDate(); 

            // hour:minute:sec
            local ftTime = format( "%i:%i:%i", now.hour, now.min, now.sec ); 

            /* Show the time of player's death to local player/self. This is just for example */ 
            Console.Print( player.Name +" died at "+ ftTime );
      }
}

Notes

Player::PlayerDeath, World::FindLocalPlayer and Console::Print were used in this example, more info about them in the corresponding pages.