The online racing simulator
Jail System
Hello LFS Family!

Today, I'm working on the police system on my own server.

However, when a guilty person is caught and moved to spectator mode, I added a 200-second penalty duration. But I don't want the player to join the race for 200 seconds. How can I do this?

https://hizliresim.com/1d51wz4
How about creating a timer and keep spectacting the player every 1 second until it runs out?
Quote from rane_nbg :How about creating a timer and keep spectacting the player every 1 second until...

I tried the method you suggested, and it forces the player to spectator mode every second, preventing them from joining the game. However, the command to send them to spectator mode continues to run even after the time has expired. Can you help me with this?



<?php 
Sub calc_race_start_time
( $KeyFlags,$id )
$Minutes = round(($start_race_seconds/60),0);
$Time = (round(($start_race_seconds/60),2)-$Minutes);
$Seconds = round(($Time*60),0);

IF (
$Seconds < 0 )
THEN
$Minutes
= $Minutes-1;
$Seconds = 60 + $Seconds;
ENDIF

$DisplaySeconds=$Seconds;

Timer( $KeyFlags ); # Geri sayım başlat
EndSub

Sub Timer
( $KeyFlags )
### Ekran düğmesini göster ###
openGlobalButton("countdown_button", 50, 30, 100, 10, 5, -1, 32, "^7". $Minutes . "^1 Dakika ^7" . $DisplaySeconds . "^1 saniye boyunca izleyiciye atıldın! katılamazsın!");

### Saniyeleri azalt ###
### Saniyeler 0&#039;ın altına düşerse, dakikaları 1 azalt ve saniyeleri 59 olarak ayarla ###
### Saniyeler 10&#039;dan küçükse, görüntülenen değere bir sıfır ekle ###
$Seconds = $Seconds-1;

IF (
$Seconds < 0 )
THEN
$Minutes
= $Minutes-1;
$Seconds = 59;
ENDIF

IF (
$Seconds < 10 )
THEN
$DisplaySeconds
="0".$Seconds;
ELSE
$DisplaySeconds=$Seconds;
ENDIF

### Dakikalar ve saniyeler 0 veya daha büyükse, 1 saniyelik döngüyü kullan, aksi takdirde düğmeyi kapat ###
IF ( $Minutes >= 0 && $Seconds >=0 )
THEN
HostDelayedCommand
( 1, Timer );
ELSE
closeGlobalButton( "countdown_button" );
ENDIF
jailspec($KeyFlags);

EndSub

Sub jailspec
($KeyFlags)
cmdLFS("/spec " . GetCurrentPlayerVar("polispanelkisin"));
PrivDelayedCommand(1, jailspec2);
EndSub


Sub jailspec2
( $KeyFlags )
cmdLFS("/spec " . GetCurrentPlayerVar("polispanelkisin"));
PrivDelayedCommand(1, jailspec);
EndSub
?>
It never ends because the code keeps going back and forth between sub "jailspec" and sub "jailspec2"
The code is missing an action that's triggered when the time ran out.

As a side note, why using a GlobalButton while a player is send to jail?
I would expect that only that player should see the button, instead of all players.
Quote from Yisc[NL :;2097819"]It never ends because the code keeps going back and forth between sub "jailspec" and sub "jailspec2"
The code is missing an action that's triggered when the time ran out.

As a side note, why using a GlobalButton while a player is send to jail?
I would expect that only that player should see the button, instead of all players.

"I didn't notice. I just fixed it privately.

So, do you have a chance to help me?
@Yisc[NL]
I think I already helped you by pointing to what's causing the issue.
Now it's up to you to come up with a solution.

FGED GREDG RDFGDR GSFDG