The online racing simulator
LFSLapper List of Events
This thread is work in progress

In this Thread you will find examplecodes for each event in LFSLapper

You can request more code examples in this subforum: https://www.lfs.net/forum/455-General-Support


# This file contains a list of events that are triggered from within LFSLapper . Start with (CATCH)EVENT and it end with (CATCH)ENDEVENT
# ALL of these events MUST have at least 1 Event handler in the LFSLapper.lpr configuration file, otherwise it will cause an error on load.
=========================================================================================

########################################################
#Event triggered when LFSLapper starts Goto post
########################################################

<?php 
    OnLapperStart
();
?>

########################################################
#Connect & Disconnect ,Join & Leaving the race goto post
########################################################

<?php 
    
    OnConnect
$userName ); #Player joined the server
    
OnNewJoinRequest$userName ); #Player request to join the track
    
OnNewPlayerJoin$userName ); #Player joined the race
    
OnDisConnect$userName$reason ); #Player left the server
    
OnLeaveRace$userName ); #Player left the race (Spectate or Pit)
?>

########################################################
#Acceleration progress
########################################################

<?php 
    OnAcceleration
$userName );
    
OnAcceleration2$userName );
?>

########################################################
#Pit events
########################################################

<?php 
    OnPit
$userName );
    
OnEndPit$userName );
    
OnEndPitWindow$userName );
    
OnEnterPitLane$userName$reason );
    
OnExitPitLane(  $userName );
    
OnFastDriveOnPitL1$userName );
    
OnFastDriveOnPitL2$userName );
    
OnMaxFastDriveOnPit$userName );
    
OnNotPitWindow$userName );
    
OnPlayerSelectCar($userName,$Car,$Time); #Player select a car in the garage
    
OnChangeTyres$userName$FL_Changed$FR_Changed$RL_Changed$RR_Changed );
?>

########################################################
#Qualification
########################################################

<?php 
    OnPBQual
$userName );
    
OnPracStart$numP );
    
OnQualStart$NumP );
?>

########################################################
#Race starts
########################################################

<?php 
    OnREO 
$NumP$ReqI$GridOrder );
    
OnRaceStart$NumP );
    
OnFalseStartL1$userName );
    
OnFalseStartL2$userName );
?>

########################################################
#During Race
########################################################

<?php 
    OnLap
$userName );
    
OnMaxAllowedLapTime1$userName );
    
OnMaxAllowedLapTime2$userName );
    
OnNewGapPlayerBefore$userName$split );
    
OnNewGapPlayerBehind$userName$split );
    
OnChangePos($userName$lastPos$currPos);
    
OnPB$userName );
    
OnMaxSessionLaps$userName );
?>

########################################################
#Splittimes
########################################################

<?php 
    OnSpbLast
$userName );
    
OnSpbSplit1$userName );
    
OnSpbSplit2$userName );
    
OnSpbSplit3$userName );
    
OnSplit1$userName );
    
OnSplit2$userName );
    
OnSplit3$userName );
?>

########################################################
#Finishline
########################################################

<?php 
    OnResult
$userName,$flagConfirm );
    
OnFinish$userName );
?>

########################################################
#Race Ends
########################################################

<?php 
    OnRaceEnd
( );
?>

########################################################
#Driven Distance
########################################################

<?php 
    OnDistDone
$userName );
?>

########################################################
#Drifting
########################################################

<?php 
    OnDriftLap
$userName );
    
OnDriftPB$userName );
    
OnDriftResetScore$userName );
    
OnDriftScore$userName );
    
OnDriftTooLow$userName );
    
OnGoodDrift$userName );
?>

########################################################
#Votesystem
########################################################

<?php 
    OnVoteEndChange
($PlayerOnTrack$Vote$Need);
    
OnVoteEndReach($PlayerOnTrack$Vote$Need);
    
OnVoteEndZero();
    
OnVoteQualifyChange($PlayerOnTrack$Vote$Need);
    
OnVoteQualifyReach($PlayerOnTrack$Vote$Need);
    
OnVoteQualifyZero();
    
OnVoteRestartChange($PlayerOnTrack$Vote$Need);
    
OnVoteRestartReach($PlayerOnTrack$Vote$Need);
    
OnVoteRestartZero();
?>

########################################################
#Idlesystem
########################################################

<?php 
    OnIdle1
$userName );
    
OnIdle2$userName );
?>

########################################################
#Spin/Crash Detection
########################################################

<?php 
    OnAngleVelocity
$userName );        
    
OnMaxNbInStunt$userName );
?>

########################################################
#Car Reset
########################################################

<?php 
    OnCarReset
$userName );
    
OnMaxCarResets$userName );
?>

########################################################
#Text Messages
########################################################

<?php 
    OnHostMSO
($Text,$Time)
    
OnMSO$userName$text );
    
OnFlood$userName );
?>

########################################################
#Authorization
########################################################

<?php 
    OnNotMatchFlags
$userName );
    
OnAuthAllowed$userName );
    
OnAuthNotAllowed$userName );
    
OnAuthReached$userName,$level );
?>

########################################################
#Handicaps
########################################################

<?php 
    OnToLowHandicap
$userName );
?>

########################################################
#Swearword detection
########################################################

<?php 
    OnSwearWords1
$userName );
    
OnSwearWords2$userName );
?>

########################################################
#Changing nickname
########################################################

<?php 
    OnNameChange
($userName$oldNickName$newNickName);
?>

########################################################
#Car/Track Rotation
########################################################

<?php 
 
    OnRotateCar
();
    
OnRotateTrack();
?>

########################################################
#ButtonAction (Shift+I en Shift+B)
########################################################

<?php 
    OnButtonFunction
($userName$SubT);
?>

########################################################
#CarContact
########################################################

<?php 
 
    OnCarContact
($PlayerA,$PlayerB,$PlayerA_Speed,$PlayerB_Speed,$PlayerA_X,$PlayerB_X,$PlayerA_Y,$PlayerB_Y);
?>

########################################################
#Hit objects
########################################################

<?php 
    OnObjectHit
($userName,$ObjectFlag,$ObjectHitTime,$Object_X,$Object_Y,$Object_Z,$ObjectType,$ObjectInDex);
    
OnObjectCollision($userName,$ObjectFlag,$ObjectHitTime,$Object_X,$Object_Y,$Object_Z,$ObjectType);
    
OnCrossingChecker($userName,$Flags,$Time,$Object,$UserSpeed,$CircleIndex);
?>

OnLapperStart()
OnLapperStart(); Event triggered when LFSLapper starts

In this event you set GlobalVars, these vars will be static and you use them for all your Lapperscripts, until you change them.


<?php 
=====================================
#Examplecode: using GlobalVars
=====================================
Event OnLapperStart();

    
GlobalVar $UserNotWelcome;
    
$UserNotWelcome "Bass-Driver";

EndEvent

#Event when a player joined the server (this event will be explained in a another post)
Event OnConnect$userName ); #Player joined the server

    
IF ($userName == $UserNotWelcome
    
THEN

      privmsg
("^1You are not welcome in this server!"); #Send private message to user
      
privmsg(GetPlayerVar($UserNotWelcome,"NickName")."^8(".$UserNotWelcome.") ^1is not welcome in this server!"); #Send message to everyone
      
cmdLFS("/kick "  $UserNotWelcome ); #kick user from the server

    
ELSE

      
privmsg("Welcome ".GetPlayerVar($userName,"NickName")); #Send private message to user

    
ENDIF

EndEvent
?>


Connect & Disconnect , Joining & Leaving the race

<?php 
=========================================================
# OnConnect( $userName )
=========================================================
Event OnConnect$userName #Player joined the server
      
privmsg("^3Welcome ".GetPlayerVar($userName,"NickName")." ^8(".$userName.")"); #Send private message to user
      
globalmsg("^3>".GetPlayerVar($userName,"NickName")." ^8(".$userName.") ^7joined the server"); #Send private message to user
EndEvent

=========================================================
# OnDisConnect( $userName, $reason )
=========================================================

#It is not possible to show the nickname in the OnDisConnect event. That because the user is already disconnected before the event is executed
Event OnDisConnect$userName$reason #Player left the server
    
IF( $reason == LEAVR_DISCO THEN  #Normal Disconnect
        
globalmsg("^7User disconnected: ".$userName); #Globalmsg()
    
ENDIF
    IF( 
$reason == LEAVR_LOSTCONN THEN #Lost connection
        
globalmsg("^7User lost connection: ".$userName);
    ENDIF
    IF( 
$reason == LEAVR_KICKED THEN #User Kicked from server
        
globalmsg("^7User kicked: ".$userName);
    ENDIF
    IF( 
$reason == LEAVR_BANNED THEN #User Banned from server
        #Blah
    
ENDIF
    IF( 
$reason == LEAVR_TIMEOUT THEN  #Lost connection (Lag)
        #Blah
    
ENDIF
    IF( 
$reason == LEAVR_SECURITY THEN #Cheat protection
        #Blah
    
ENDIF
    IF( 
$reason == LEAVR_CPW THEN #Cheat protection
        #Blah
    
ENDIF
    IF( 
$reason == LEAVR_OOS THEN #Out of Sync With Host (mods)
        #Blah
    
ENDIF
    IF( 
$reason == LEAVR_JOOS THEN  #join OOS (initial sync failed)
        #Blah
    
ENDIF
    IF( 
$reason == LEAVR_HACK THEN #Invalid Packets
        #Blah
    
ENDIF
EndEvent

=========================================================
# OnNewPlayerJoin( $userName )
=========================================================

Event OnNewPlayerJoin$userName #Player joined the race
    
globalmsg("^3>".GetPlayerVar($userName,"NickName")." ^7joined the track with ^8(".GetPlayerVar($userName,"Car").")");#Display message about the car of the user
EndEvent

=========================================================
# OnLeaveRace( $userName )
=========================================================

Event OnLeaveRace$userName #Player left the race (Spectate or Pit)
    
globalmsg("^3>".GetPlayerVar($userName,"NickName")." ^7left the race");
EndEvent
?>


This thread is closed

LFSLapper List of Events
(3 posts, closed, started )
FGED GREDG RDFGDR GSFDG