The online racing simulator
Sending a message when the specified time arrives
The version of what I mentioned in c# is as follows, how can I do this with lapper

if (DateTime.Now > DateTime.Parse("29.6.2023 21:00:00"))
{
this.MsgPly("^2The product has expired!", Conn.UniqueID);
}
For time it should look something like this.
For the date GetLapperVar("ShortDate") it should somewhat the same.

$SplitCurrTime = SplitToArray(GetLapperVar("ShortTime"), ":");
$SplitSetTime = SplitToArray("21:00:00", ":");


$SplitCurrTime[0] = Hours
$SplitCurrTime[1] = Minutes
$SplitCurrTime[2] = Seconds

$SplitSetTime[0] = Hours
$SplitSetTime[1] = Minutes
$SplitSetTime[2] = Seconds

IF((ToNum($SplitCurrTime[0]) > ToNum($SplitSetTime[1])) && (ToNum($SplitCurrTime[1]) > ToNum($SplitSetTime[0])) &&(ToNum($SplitCurrTime[2]) > ToNum($SplitSetTime[2]))) THEN
#Your Code.
ENDIF


Thx to Racon for a much more efficient way.


<?php 
$SplitCurrTime 
SplitToArray(GetLapperVar("ShortTime"), ":");
$SplitSetTime SplitToArray("21:00:00"":");

$TimeInSecondsCurrTime ToNum(($SplitCurrTime[0]*3600) + ($SplitCurrTime[1]*60) + ($SplitCurrTime[2]));
$TimeInSecondsSetTime ToNum((SplitSetTime[0]*3600) + ($SplitSetTime[1]*60) + ($SplitSetTime[2]));

IF (
$TimeInSecondsCurrTime $TimeInSecondsSetTimeTHEN
  
#code
ENDIF
?>

#3 - Racon
15:03 is later than 14:59, but will fail that check because the minutes value is lower and you've used '&&'. I think you need to compile both values into seconds before comparing to avoid a whole bunch of conditional testing, ie:


<?php 

$test1 
= ($Split1[0]*3600)+($Split1[1]*60)+$Split1[2];
$test2 = ($Split2[0]*3600)+($Split2[1]*60)+$Split2[2];

IF (
$test1>$test2THEN
  
#code
ENDIF

?>

Quote from Bass-Driver :For time it should look something like this.
For the date GetLapperVar("ShortDate") it should somewhat the same.


<?php 
$SplitCurrTime 
SplitToArray(GetLapperVar("ShortTime"), ":");
$SplitSetTime SplitToArray("21:00:00"":");


$SplitCurrTime[0] = Hours
$SplitCurrTime
[1] = Minutes
$SplitCurrTime
[2] = Seconds

$SplitSetTime
[0] = Hours
$SplitSetTime
[1] = Minutes
$SplitSetTime
[2] = Seconds

IF((ToNum($SplitCurrTime[0]) > ToNum($SplitSetTime[1])) && (ToNum($SplitCurrTime[1]) > ToNum($SplitSetTime[0])) &&(ToNum($SplitCurrTime[2]) > ToNum($SplitSetTime[2]))) THEN
#Your Code. 
ENDIF
?>


Thank you
Quote from Racon :15:03 is later than 14:59, but will fail that check because the minutes value is lower and you've used '&&'. I think you need to compile both values into seconds before comparing to avoid a whole bunch of conditional testing, ie:


<?php 

$test1 
= ($Split1[0]*3600)+($Split1[1]*60)+$Split1[2];
$test2 = ($Split2[0]*3600)+($Split2[1]*60)+$Split2[2];

IF (
$test1>$test2THEN
  
#code
ENDIF

?>


Thank you I will try
Quote from Racon :15:03 is later than 14:59, but will fail that check because the minutes value is lower and you've used '&&'. I think you need to compile both values into seconds before comparing to avoid a whole bunch of conditional testing, ie:


<?php 

$test1 
= ($Split1[0]*3600)+($Split1[1]*60)+$Split1[2];
$test2 = ($Split2[0]*3600)+($Split2[1]*60)+$Split2[2];

IF (
$test1>$test2THEN
  
#code
ENDIF

?>


Yeah didnt think of that.
your code is much more efficient, ill edit the code in my first post.
Thx
#7 - Racon
npnp, I learned it the hard way Wink

FGED GREDG RDFGDR GSFDG