The online racing simulator
[Solved] Simple Restriction problem
(6 posts, closed, started )
[Solved] Simple Restriction problem
I've just done a simple restriction code but for some reason it does nothing when "Pinto" or "Zetec" is clicked.

Ive spectated every driver when they join aswell as a test and that does not work aswell.


Event OnMSO( $userName, $text ) # Player event
$idxOfFirtsSpace = indexOf( $text, " ");

IF( $idxOfFirtsSpace == -1 ) THEN
$command = $text;
$argv = "";
ELSE
$command = subStr( $text,0,$idxOfFirtsSpace );
$argv = trim( subStr( $text,$idxOfFirtsSpace ) );
ENDIF

SWITCH( $command )

CASE "!node":
IF ( UserIsAdmin( $userName ) == 1 )
THEN

ENDIF
BREAK;
ENDSWITCH
EndEvent

CatchEvent OnConnect ( $userName )
$userName = GetCurrentPlayerVar("UserName");
openPrivButton( "tws_PLAIN",31,50,148,100,5,-1,96," ");
openPrivButton( "tws_Pinto",46,90,54,15,5,-1,16,"^7Pinto Engine",tws_Pinto);
openPrivButton( "tws_Zetec",110,90,54,15,5,-1,16,"^7Zetec Engine",tws_Zetec);
IF (GetUserStoredValue($userName," register") == 1) THEN
privmsg($userName,"^7Welcome Back!");
ELSE
privmsg($userName,"^7Welcome for the first time on our Server!");
SetUserStoredValue($userName," register", 1);
ENDIF
EndCatchEvent

CatchEvent OnNewPlayerJoin ( $userName )
$userName = GetCurrentPlayerVar("UserName");
cmdLFS("/spec ".$userName); #Test
IF(GetPlayerVar($userName,"Car") == XRT) THEN
IF (GetUserStoredValue($userName," XRT_Pinto") == 1) THEN
IF(GetPlayerVar($userName,"P_Tres") == 25) THEN
privmsg($userName,"you successfully entered the Track with Pinto powered XRT!);
ELSE
privmsg($userName,"To Enter the Track please use 25% of Air Restriction for the Pinto Engine!");
cmdLFS("/spec ".$userName);
ENDIF
ELSE
IF (GetUserStoredValue($userName," XRT_Zetec") == 1) THEN
IF(GetPlayerVar($userName,"P_Tres") == 23) THEN
privmsg($userName,"you successfully entered the Track with Zetec powered XRT!);
ELSE
privmsg($userName,"To Enter the Track please use 23% of Air Restriction and 150kg Mass weight for the Zetec Engine!");
cmdLFS("/spec ".$userName);
ENDIF
ENDIF
ENDIF
ELSE
cmdLFS("/spec ".$userName);
ENDIF
EndCatchEvent

Sub Money( $KeyFlags )
$userName = GetCurrentPlayerVar("UserName");
closePrivButton( "MoneyD&MoneyD1");
openPrivButton( "MoneyD",110,10,20,5,5,-1,16,"^3Money Balance :");
openPrivButton( "MoneyD1",132,10,20,5,5,-1,16,"^3£ ".GetUserStoredValue($userName," Money"));
EndSub

Sub tws_Zetec( $KeyFlags )
$userName = GetCurrentPlayerVar("UserName");
closePrivButton( "tws_Pinto&tws_Zetec&tws_PLAIN");
SetUserStoredValue($userName," XRT_Zetec", 1);
SetUserStoredValue($userName," XRT_Pinto", 0);
EndSub

Sub tws_Pinto( $KeyFlags )
$userName = GetCurrentPlayerVar("UserName");
closePrivButton( "tws_Pinto&tws_Zetec&tws_PLAIN");
SetUserStoredValue($userName," XRT_Zetec", 0);
SetUserStoredValue($userName," XRT_Pinto", 1);
EndSub

Have you checked the logfiles and if so, any errors in there?
Had no Errors in the log file
Add a debugging message in both Subs and see if the tekst appears when the button is clicked.
If so, there's a problem within the Sub(s) and if not, there is a problem with the button.
I have loaded your script and found several errors:

This: privmsg($userName,"you successfully entered the Track with Pinto powered XRT!);

Should be: privmsg($userName,"you successfully entered the Track with Pinto powered XRT!");

This: privmsg($userName,"you successfully entered the Track with Zetec powered XRT!);

Should be: privmsg($userName,"you successfully entered the Track with Zetec powered XRT!");

This: Sub tws_Zetec( $KeyFlags )
Should be: Sub tws_Zetec( $KeyFlags , $id )

This: Sub tws_Pinto( $KeyFlags )
Should be: Sub tws_Pinto( $KeyFlags , $id )

All these errors were visable in the log file:

3/23/2020 8:17:11 PM -> Error: Unclosed string on file: ".\AB-configs\.\..\includes\.\test\test_restrict.lpr" at line #41
3/23/2020 8:28:48 PM -> Syntax error: Incorrect number of arguments at line #76 in function 'tws_pinto' script aborted

You might have looked at the wrong lof file, as Lapper has two of them.
This file* is the correct file to check: 127.0.0.1-29994-ERR.log

*29994 = the port number your Lapper is running on, so that might differ on your end

Of course it's always a good thing to learn the coding skills your self and you are well on your way, but if you want some inspiration or to have a fully developed handicap (or restrictions as you call it) system, have a look at the script I made in the past: https://www.lfs.net/forum/post/1954184#post1954184
Help given, no feedback, thread closed.
This thread is closed

[Solved] Simple Restriction problem
(6 posts, closed, started )
FGED GREDG RDFGDR GSFDG