Scripting/Squirrel/Client Functions/System::GetTimestamp: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary
 
Line 10: Line 10:
== Example ==
== Example ==
<source lang=squirrel>
<source lang=squirrel>
/* Player::PlayerDeath is triggered whenever someone die */
/* Player::PlayerDeath is triggered whenever someone die, we are going to use this for the sake of example */
function Player::PlayerDeath( player )  
function Player::PlayerDeath( player )  
{
{
       /* Check whether the player that just died is local player/self */
       /* Check whether the player that just died is local player/self by comparing ID */
       if ( player.ID == World.FindLocalPlayer( ).ID )
       if ( player.ID == World.FindLocalPlayer( ).ID )
       {
       {
Line 19: Line 19:
             local time = System.GetTimestamp( );
             local time = System.GetTimestamp( );


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

Latest revision as of 14:34, 2 October 2018

This function returns the number of seconds since the UNIX epoch; equivalent to Squirrel's time function: [1]

Syntax

System.GetTimestamp()

Return type

integer

Example

/* Player::PlayerDeath is triggered whenever someone die, we are going to use this for the sake of example */
function Player::PlayerDeath( player ) 
{
      /* Check whether the player that just died is local player/self by comparing ID */
      if ( player.ID == World.FindLocalPlayer( ).ID )
      {
            /* Get epoch time */
            local time = System.GetTimestamp( );

            /* Show the epoch time of death to local player/self */ 
            Console.Print( player.Name +" died at "+ time );
      }
}

Notes

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