The online racing simulator
Help about afk system
I have the afk timer made by Bassdriver, but I now want the player who remains motionless for a certain period of time to be thrown at the audience. I checked Bassdriver's codes but I couldn't run it. Can you help me?
https://www.lfs.net/forum/post/1645969#post1645969 ı have a lapper version 7.0.8.1
@Bass-Driver
The mentioned script is over 12 years old and might not be working in recent versions of Lapper.
Looking at the script, it should spectate a player that is idle for 600 seconds (10 minutes).
Main problem is that the code probably won't work with recent versions of Lapper and has to be converted first.
https://www.lfs.net/forum/post/1646256#post1646256 I also tried Karry's edit, but I couldn't get any results.


-------------------------------------------------------------------------


#$IdleExclude = "Lagamel,Gai-Luron"; # Usernames excluded for idle check
/*
$OnIdleTimeout1 = 60; # Idle timeout for OnIdleAction1 in seconds

Event OnIdle1( $userName ) # Player event
UserGroupFromFile( "idleExempt", "./idleexempt.txt" );
IF( UserInGroup( "idleExempt",$userName ) == 0 )
THEN
privMsg( langEngine( "%{main_idle1}%" ) );
ENDIF
EndEvent

$OnIdleTimeout2 = 120; # Idle timeout for OnIdleAction2 in seconds

Event OnIdle2( $userName ) # Player event
UserGroupFromFile( "idleExempt", "./idleexempt.txt" );
IF ( UserInGroup( "idleExempt",$userName ) == 0 )
THEN
cmdLFS ( "/spec " . GetCurrentPlayerVar("Nickname") );
privMsg ( langEngine( "%{main_idle2}%" ) );
ENDIF
EndEvent
*/

There is such a directory in Lapper, but it does not work either.
The code is not working, because it is excluded by using /* (this means, start of the exclude) and */ (this means, end of the exlude).

Also good to know, to exclude a single line, just put a # in front of it and Lapper will ignore that line.
Removing the # will enable it again.

So by removing the start and ending of the exclude, that code should start to work and should look like this:


<?php 
$OnIdleTimeout1 
60# Idle timeout for OnIdleAction1 in seconds

Event OnIdle1$userName # Player event
    
UserGroupFromFile"idleExempt""./idleexempt.txt" );
    IF( 
UserInGroup"idleExempt",$userName ) == )
    
THEN
        privMsg
langEngine"%{main_idle1}%" ) );
    ENDIF
EndEvent

$OnIdleTimeout2 
120# Idle timeout for OnIdleAction2 in seconds

Event OnIdle2$userName # Player event
    
UserGroupFromFile"idleExempt""./idleexempt.txt" );
    IF ( 
UserInGroup"idleExempt",$userName ) == )
    
THEN
        cmdLFS 
"/spec " GetCurrentPlayerVar("Nickname") );
        
privMsg langEngine"%{main_idle2}%" ) );
    ENDIF
EndEvent
?>


Thanks👌
Quote from Yisc[NL :;2065935"]The code is not working, because it is excluded by using /* (this means, start of the exclude) and */ (this means, end of the exlude).

Also good to know, to exclude a single line, just put a # in front of it and Lapper will ignore that line.
Removing the # will enable it again.

So by removing the start and ending of the exclude, that code should start to work and should look like this:


<?php 
$OnIdleTimeout1 
60# Idle timeout for OnIdleAction1 in seconds

Event OnIdle1$userName # Player event
    
UserGroupFromFile"idleExempt""./idleexempt.txt" );
    IF( 
UserInGroup"idleExempt",$userName ) == )
    
THEN
        privMsg
langEngine"%{main_idle1}%" ) );
    ENDIF
EndEvent

$OnIdleTimeout2 
120# Idle timeout for OnIdleAction2 in seconds

Event OnIdle2$userName # Player event
    
UserGroupFromFile"idleExempt""./idleexempt.txt" );
    IF ( 
UserInGroup"idleExempt",$userName ) == )
    
THEN
        cmdLFS 
"/spec " GetCurrentPlayerVar("Nickname") );
        
privMsg langEngine"%{main_idle2}%" ) );
    ENDIF
EndEvent
?>



Hello, the shared code is not working right now. I had to switch to a different lapper due to a TCP memory error. But currently, it does not broadcast to the audience in version 7.0.7.1. But warning messages are coming. He doesn't just throw it at the audience.https://hizliresim.com/86kuxr8
Your comment is a bit weird, probably because of a translation issue.
I am guessing you mean that no global message is send when someone is spectated.
That's because "privMsg" is used, which sends a private message to the play involved.
To send the message to everyone, just use "GlobalMsg"
Quote from Yisc[NL :;2068448"]Your comment is a bit weird, probably because of a translation issue.
I am guessing you mean that no global message is send when someone is spectated.
That's because "privMsg" is used, which sends a private message to the play involved.
To send the message to everyone, just use "GlobalMsg"

What I mean is, it gives an afk warning. But he doesn't throw me at the audience.
You should look into cmdLFS function, this is the part of the code that should execute the spectate command. I don't know where in laper this function is declared, but maybe there is some sintax error..
I found a mistake in the code.
You cannot spectate the NickName of the player.

cmdLFS ( "/spec " . GetCurrentPlayerVar("Nickname") );

NickName should be UserName
Quote from Bass-Driver :I found a mistake in the code.
You cannot spectate the NickName of the player.

cmdLFS ( "/spec " . GetCurrentPlayerVar("Nickname") );

NickName should be UserName

Thanks.
Feels good to be right Smile
Quote from Bass-Driver :I found a mistake in the code.
You cannot spectate the NickName of the player.

cmdLFS ( "/spec " . GetCurrentPlayerVar("Nickname") );

NickName should be UserName

oto spec function does not work in 7.0.9.0 version lapper. I tried an empty lapper. But it doesn't work. Is this a Lapper related problem?
show me the code.
its a LFS command, so it should work.
This is the code in lapper version 7.0.9.0. Not working. I didn't make any corrections to it.
$OnIdleTimeout1 = 60; # Idle timeout for OnIdleAction1 in seconds

Event OnIdle1( $userName ) # Player event
UserGroupFromFile( "idleExempt", "./idleexempt.txt" );
IF( UserInGroup( "idleExempt",$userName ) == 0 )
THEN
privMsg( langEngine( "%{main_idle1}%" ) );
ENDIF
EndEvent

$OnIdleTimeout2 = 120; # Idle timeout for OnIdleAction2 in seconds

Event OnIdle2( $userName ) # Player event
UserGroupFromFile( "idleExempt", "./idleexempt.txt" );
IF ( UserInGroup( "idleExempt",$userName ) == 0 )
THEN
cmdLFS ( "/spec " . GetCurrentPlayerVar("Nickname") );
privMsg ( langEngine( "%{main_idle2}%" ) );
ENDIF
EndEvent

Quote from Bass-Driver :show me the code.
its a LFS command, so it should work.

This is my edited code. But this doesn't work either.
$OnIdleTimeout1 = 60; # Idle timeout for OnIdleAction1 in seconds

Event OnIdle1( $userName ) # Player event
UserGroupFromFile( "idleExempt", "./idleexempt.txt" );
IF( UserInGroup( "idleExempt",$userName ) == 0 )
THEN
privMsg( langEngine( "%{main_idle1}%" ) );
ENDIF
EndEvent

$OnIdleTimeout2 = 120; # Idle timeout for OnIdleAction2 in seconds

Event OnIdle2( $userName ) # Player event
UserGroupFromFile( "idleExempt", "./idleexempt.txt" );
IF ( UserInGroup( "idleExempt",$userName ) == 0 )
THEN
cmdLFS ( "/spec " . GetCurrentPlayerVar("UserName") );
privMsg ( langEngine( "%{main_idle2}%" ) );
ENDIF
EndEvent

What did you do to test the code?

-Does the event execute?
etc etc

Do that first.
Quote from Bass-Driver :What did you do to test the code?

-Does the event execute?
etc etc

Do that first.

No. Not even a warning message comes. No reaction.
Did you do any debugging at all?

Do some proper tests please.
Create some "debug" messages to see where and what the problem is.
** Best answer **
Event OnCarStateChanged($userName,$StateOfCar)

Since the Idle system does not work in Lapper, an afk system can be made using this event I shared.

Lastly, @bass-driver asked me to debug. The event does not send any error messages. I can't test new versions but this is the problem for this version.
This thread is closed

FGED GREDG RDFGDR GSFDG