Difference between revisions of "ScriptCore3.Now"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
m (Bolded definition, removed extra space, removed line break)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
  '''function Now: [[TDateTime]]'''
+
'''function Now: [[TDateTime]]'''
   Result: Current Date + Time (encoded)<br>
+
   Result: Current Date + Time (encoded)
  
 
==Description==
 
==Description==
Line 6: Line 6:
  
 
==Example==
 
==Example==
 +
Below example allows players to see the server's local time by saying !time
 
<syntaxhighlight lang="pascal">
 
<syntaxhighlight lang="pascal">
 
var
 
var

Latest revision as of 00:45, 26 August 2013

function Now: TDateTime
 Result: Current Date + Time (encoded)

Description

This function will return TDateTime representing current date and time

Example

Below example allows players to see the server's local time by saying !time

var
  i: ShortInt;
  
procedure OnSpeak(P: TActivePlayer; Text: string);
begin
  if lowercase(Text) = '!time' then
    Players.WriteConsole('Current local time: '+FormatDateTime('ddddd t',Now()),$FFFFFF);
end;

begin
  for i:=1 to 32 do
    Players[i].OnSpeak := @OnSpeak;
end.