The online racing simulator
Searching in All forums
(879 results)
Bass-Driver
S3 licensed
So you took Yisc[NL] his code and you mentioned it works.
Now you edit the code and suddenly it doesn't work.

You ask us for help, while you failed editing existing working code.

I won't help you. Because i do not know how the original code looks like. And i do NOT give myself permission to look into or edit his code.
and i'm not interested in comparing your code with Yisc[NL]'s code.

Seems you did not properly understand/debug the code.

Yisc[NL] put his time and effort into this script, so you can it on your server.
Just leave the orginal code/script as it is.
If you want to change something, try to understand the code and build something yourself.

Have a nice day.
Bass-Driver
S3 licensed
The syntax should be something like this.


#Verify each first word/command that starts with a "!".

SWITCH($command)

CASE "!command":
#your code
BREAK

DEFAULT:
#privmsg("Command does not exist");
BREAK;
ENDSWITCH

Bass-Driver
S3 licensed
The function is usable for V7.0.9.0. Only the 'listcount' variable cannot be used
Bass-Driver
S3 licensed
There is a function named getlisttopuser();

$toplist = getlisttopuser($value,$flagdesc,$flagNear,$StartPos); #Get List from stored database

Take a look at an example how to get values from the user storeddatabase
https://www.lfs.net/forum/post/2081039#post2081039
Bass-Driver
S3 licensed
New update.

VM.Infected gamemode V0.5

Add: List of survivors
Add: DistanceMeter for the infected in the survivorlist behind the playernames.
Add: Groupchat for survivors and infected !gc or !c <message> (auto detection by insim)
Add: Carlist command (admin only) !list <nameoflist> to allow curtain LFS default car and/or modded vehicles
Add: Infected may use the ingame siren to scare the surivors even more. /siren=off/slow/fast

Update: Changed "Get Ready Timer" from 30 seconds to 20 seconds.
Update: Join as an infected when joining mid-game
Update: Changed instructions in helpmenu
Update: Changed Instructions in welcomes window
Update: "Player infected player" message is now a host message (this can be used in replays)

Fix: Double infected players after Drive Away timer has been completed.
Fix: Fix attempt on Callback functions not executing due to invalid userstats.
Fix: "Total Drivers on Track" counter wasn't accurate when leaving the game (pit/spec/disconnect)
Fix: Minor code mess , jup minor xD

Bass-Driver
S3 licensed
Thank you for the layout, we will check it out.Smile

Edit:
The changes has been accepted and loaded on our server, thank you
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Insim Gamemode update

VM.Infected gamemode V0.4

Add: Playerstats : JoinedGames
Add: Playerstats : Times Survived

Update: !stats command: added the two new Playerstats Variables
Update: !help : added the two new Playerstats Variables

Fix: UserData file were filled with empty line after insim reboot
Fix: Minor Button misplacement
Fix: Couldn't drive away because of the falsestarts after a racerestart
Fix: GameMode didn't reset after last player left the race/game.

VM.Infected Gamemode
Bass-Driver
S3 licensed
Hello ,

VM (Velocity Motorsports) is proud to announce their latest addition to their servers, VM.Infected.

This server is powered by an script created in LFSLapper that simulates a gamemode: Infected
In this game mode, your goal is to survive from the infected players by hiding or running until the timer ends.
The first infected player will randomly chosen by inSim.

The layouts keeps the area limited for more fun and action.

The results and feedback during the tests with the VM members and other guests were amazing.
We've chosen to create a server, that runs the gamemode 24/7.
Keep in mind that the gamemode is still under development and will be updated with more features and layouts

Server: VM.Infected

Features
  • Limited area on tracks for more fun and action
  • All (modded) vehicles are allowed (Choose wisefully)
  • Limited playerstats as this will be updated in future updates.
More information can be found on the server.


--------------------------------------------------------------------
Velocity Motorsports Website

Velocity Motorsports Discord

Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
i've created an example.
This example has not been tested.

I'm sure there are better ways to do paging within LFSLapper. I've using this type of paging for a really long time, because it just works Smile.

I've copied some code from my TimeAttack scripts to create this example.
The buttons may out of place, but i think you'll get the idea.

Just give this code a look and try to understand how it works.

Here is a part of the code, the rest can you find in the attachment.

Sub Paging($UserName)

$MaxNrOfResults = 40;
$BtnHgt = 61;
$BtnWdt = 70;
$Counter = 0;
$MaxResultsOnPage = 15;

#Close all buttons that contains "Page_"
#Just to prevent overlapping buttons with different button ID's (actually this shouldn't happen within this code)
CloseButtonRegex ($username, "Page_*");

$StartNrOfResult = (Getplayervar($username,"Page") * $MaxResultsOnPage) - $MaxResultsOnPage;

openPrivButton( "Page_Prev",$BtnWdt,$BtnHgt+10,15,4,5,-1,32, "^7Prev Page",PrevPage);
openPrivTextButton( "Page_Sel",$BtnWdt+15,$BtnHgt+10,10,4,5,32,"Select page 1 - 8","^7Page ".Getplayervar($UserName,"Page"),1,SelectPage);
openPrivButton( "Page_Next",$BtnWdt+25,$BtnHgt+10,15,4,5,-1,32, "^7Next Page",NextPage);

FOR( $i = 0; $i <= ToNum($MaxNrOfResults); $i = $i + 1)

#Show 15 results on screen
#Start result from number $StartNrOfResult
#It stops showing results when $counter hits the limit or reached MaxNumberofResult
IF(($i >= ToNum($StartNrOfResult))&&(ToNum($Counter) < $MaxResultsOnPage)) THEN

openPrivButton( "Page_Button_".$Counter,$BtnWdt,$BtnHgt,5,4,5,-1,16, "".$i);

#Increase the buttonheight by 4 for each button.
$BtnHgt = $BtnHgt + 4;
$Counter = $Counter + 1;
ENDIF

ENDFOR

EndSub

#User Clicked on Next Page Button
Sub NextPage($keyflags,$id)
$UserName = GetCurrentPlayerVar("UserName");
$CurrPage = Getplayervar($UserName,"Page");

#Increase pagenumber by 1. And call 'paging' sub
Setplayervar($UserName,"Page",$CurrPage + 1);
Paging($UserName);

EndSub

#User Clicked on Prev Page Button
Sub PrevPage($keyflags,$id)
$UserName = GetCurrentPlayerVar("UserName");
$CurrPage = Getplayervar($UserName,"Page");

# Reset Playervar when pagenumber is below 1
# Otherwise decrease pagenumber by 1.
# And call 'paging' sub

IF($CurrPage <= 1) THEN
Setplayervar($UserName,"Page",1);
ELSE
Setplayervar($UserName,"Page",$CurrPage - 1);
ENDIF

Paging($UserName);
EndSub

Bass-Driver
S3 licensed
There is something you can do with
getlisttopuser();

LFSLapper version must be 7.0.9.3 or higher

Here is an example code.

$value = ""; #NameOfStoredValue
$flagdesc = "";DESC (descending order ) or ASC (ascending order)
$flagNear = "FALSE"; #TRUE or FALSE
$StartPos = 1;

$toplist = getlisttopuser($value,$flagdesc,$flagNear,$StartPos); #Get List from stored database

#Possible variables
#$toplist["ListCount"] = Number of records saved for requested storedvalue
#$toplist[$pos,"UserName"]
#$toplist[$pos,"NickName"]
#$toplist[$pos,"Value"]

$GetMaxRecords = 1000;
FOR($pos = 0;$pos <= ToNum($GetMaxRecords); $pos = $pos + 1)

#Example
globalmsg($pos.": ".$toplist[$pos,"NickName"] ." (".$toplist[$pos,"UserName"]."): ".$toplist[$pos,"Value"]."");

ENDFOR

Bass-Driver
S3 licensed
not going to fix your code. I see so many errors.
Its better for you to understand how a FOREACH Loop works, and then implement it in your code.

search for FOREACH / ENDFOREACH examples at the LFSLapper development forum.

Also search examples for FOR/ENDFOR and WHILE/ENDWHILE loops aswell
Bass-Driver
S3 licensed
So from i understand is, that you do not want to display the buttons for the spectators.

First, you need to get a list of player that are currently online on the server.
You can do this with:

$ListOfPlayers = GetListOfPlayers("U");

Then create a loop, to go through the list of players
Within that loop you'll check if the player is on track or not.


$ListOfPlayers = GetListOfPlayers("U");
FOREACH( $Var IN $ListOfPlayers ) #Go Through each player in the arraylist $ListOfPlayers
$UserName = $Var["value"];
IF(GetPlayerVar($UserName,"OnTrack") == 1) THEN
#Player On Track
#Open Buttons
ELSE
#Player Spectating or in pit
#Close Buttons
ENDIF
ENDFOREACH

Bass-Driver
S3 licensed
IF you have other example codes. You could give it to me, so i can create a tutorial for it with example codes.
Like i did with the Discord feature.
Bass-Driver
S3 licensed
they prob implemented it before the LFS devs got rid of their dedicated servers.

Here is some code for c#
https://stackoverflow.com/questions/770978/how-do-i-obtain-the-latency-between-server-and-client-in-c
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
That Ping has nothing todo with the ping(latency) of players.

From what i know, and what i see in the Lapper sourcecode.

Tiny_Ping is a small packet that checks the connection between the Insim and the LFS Server. When the InSim doesnt receive any packets for a while. The connection will be closed.

And its only usefull if the insim is on the same server as the LFS server. Otherwise you measure the latency between InSim <> Player instead of LFS Server <> Player.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
I've found some disabled code at the PLL insim packet(PLayer Leave Race) that should execute the LeaveZone code when you leave the race by shift+s or shift+P

But there is a comment, that says that its handled by the MCI (Car Information) packet.
Ill look into this
Bass-Driver
S3 licensed
It took some time,headaches and cursing to windows to get a webserver and PHP working on my PC.
Do not ask me on how or what i did it to setup a webserver with .PHP file extensions.Big grin

But i finally got some results.Thumbs up

The http() function is to execute other functions like:

Sub BlahBlah($something,$something);
EndSub

I've started with creating a simple command named !http.
Within that command, i've executed the http() function with the link to my local website.


CASE "!http":
$user = $argv;
http("http://localhost/Test/LFSLapper_Test.php?u=".$user);
BREAK;

inside the folder of the website, i created a PHP file and took some code i've found on this LFSLapper sub forum .Later i've added more stuff just for testing.

<?php
$allowed_list = array(

"TechEdison" => "no",
"Androphp" => "yes",
"Bass-Driver" => "yes"
);

$username = $_GET["u"];

if (array_key_exists("".$username."",$allowed_list))
{
if($allowed_list[$username] == "yes")
{
echo 'WebReturn('.$username.',"Allowed");';
}
else
{
echo 'WebReturn('.$username.',"Not Allowed");';
}
}
else
{
echo 'WebReturn('.$username.',"Not Found");';
}
?>

The code will check, if the username exist within the array named: $allowed_list
After that it checks if the username is allowed or not.

The return value must be a function and not a single character,number or word.

Example
'privmsg('$username.',"something");';
'globalmsg("something");';
'YourOwnNamedFunction("Parameter");';

In the testcode above, it returns a string named WebReturn('.$username.',"Not Found");
The LFSLapper sourcecode will translate this into a function with their given parameters.

Back to my Lapperscript, i've created a sub function with the parameters.

Sub WebReturn($User,$Allowed)
globalmsg("Player: ".$User." = ".$Allowed);
EndSub

Output:
Player: TechEdison = Not Allowed
Player: Androphp = Allowed
Player: 0 = Allowed (i have no idea why it returns a 0 when i'm in the server, this could be old lapperbug)


Please correct me, if i did something wrong. I'm totally not into web stuff.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
Never used the http feature before, but i think you have to give the $allowed variable a value. Also you need to be sure, that the http function returns a value.


$allowed = http("http://localhost/script.php?u=".$userName);
IF($allowed == 0)
THEN
cmdLFS("/kick ".$userName);
GlobalMsg("Kicked: ".$userName.". Reason: Not Alowed");
ELSE
GlobalMsg("Welcome Back: ".$userName);
ENDIF

EDIT: nvm too late with this post lel

To test and help properly, i need to install a webserver on my pc and make a basic php script. Won't do that today tho. Any more guessing doesn't help.
Last edited by Bass-Driver, .
Discord Embed Examples
Bass-Driver
S3 licensed
<?php 
#################################################
#Single Field
#################################################
#DiscordChannel to receive this embed.
$DiscordChannel = "";
#Set Title/Description and color of the discord embed
$Title = "LFSLapper Embed Title";
$Desc = "Embed Description";
#Prefix must contain &#039;0x&#039; Followed by 6 chars 0-9 and A-F
$Color = "0xFF0000"; #RED
#Field Values
## Use %nf% to create a new field. (Add %nf% to $FieldValue and $FieldInline aswell) ##
## The amount of $FieldTitle and $FieldValue and $FieldInLine must be the same. Otherwise you will receive errors.
$FieldTitle = "Field_01 Title";
$FieldValue = "Field_01 Value";
$FieldInline = "True";
#Use %nf% to add a footer image URL !! Not an local(pc) image.
$Footer = "LFSLapper Footer: ".GetLapperVar("ShortTime")." %nf% https://velocitymsports.com/home/vmlogo.png ";
#Small Image URL on the right side of the Embed box.
$ThumbnailUrl = "https://velocitymsports.com/home/vmlogo.png";
#The Entire EmbedBox will fit to the same size as the ImageUrl.
$ImageUrl = "";
#Function to send Discord Embed
SendDiscordEmbed($DiscordChannel,$Title,$Desc,$Color,$FieldTitle,$FieldValue,$FieldInline,$Footer,$ThumbnailUrl,$ImageUrl);

#################################################
#Multiple Fields
#################################################
#DiscordChannel to receive this embed.
$DiscordChannel = "";
#Set Title/Description and color of the discord embed
$Title = "LFSLapper Embed Title";
$Desc = "Embed Description";
#Prefix must contain &#039;0x&#039; Followed by 6 chars 0-9 and A-F
$Color = "0xFF0000"; #RED
#Field Values
## Use %nf% to create a new field. (Add %nf% to $FieldValue and $FieldInline aswell) ##
## The amount of $FieldTitle and $FieldValue and $FieldInLine must be the same. Otherwise you will receive errors.
$FieldTitle =
"Field_01 Title"
."%nf%Field_02 Title"
."%nf%Field_03 Title"
."%nf%Field_04 Title";
$FieldValue =
"*Field_01 Value*\n*Field_01 Value*"
."%nf%Field_02 Value"
."%nf%```New BlockLine_01\nNew BlockLine_02\nNew BlockLine_03\nNew BlockLine_04\nNew BlockLine_05\nNew BlockLine_06\nNew BlockLine_07```"
."%nf%**Field_04 Value**\n**Field_04 Value**\n**Field_04 Value**\n**Field_04 Value**";
$FieldInline = "True%nf%True%nf%False%nf%False";
#Use %nf% to add a footer image URL !! Not an local(pc) image.
$Footer = "LFSLapper Footer: ".GetLapperVar("ShortTime")." %nf% https://velocitymsports.com/home/vmlogo.png ";
#Small Image URL on the right side of the Embed box.
$ThumbnailUrl = "https://velocitymsports.com/home/vmlogo.png";
#The Entire EmbedBox will fit to the same size as the ImageUrl.
$ImageUrl = "";
#Function to send Discord Embed
SendDiscordEmbed($DiscordChannel,$Title,$Desc,$Color,$FieldTitle,$FieldValue,$FieldInline,$Footer,$ThumbnailUrl,$ImageUrl);
?>
Bass-Driver
S3 licensed
What if you try to rename the sub.
Because the http() function has the same name as the sub.
Discord - How To
Bass-Driver
S3 licensed
Hello,

I've created a small tutorial, how to set-up your LFSLapper to communicate with your discordbot.
This tutorial will be extended with more code examples in the future.

You can PM me, if you have usefull code examples or more tips&tricks, i can add to this tutorial.
Asking for help with Discord will be ignored. Go To: https://www.lfs.net/forum/455-General-Support



#1. Create a DiscordBot @ https://discord.com/developers/applications
Here is an tutorial how to setup your bot properly
https://www.ionos.com/digitalguide/server/know-how/creating-discord-bot/

#2. Once you've added your bot to your discord server, we can now configure LFSLapper to communicate with your discordbot.

#3. Open myInc.LPR (bin\default\includes\myInc.lpr) and fill in the 3 parameters
#####DISCORD API#####
$DiscordToken = ""; # Token to connect LFSLapper with Discord , This is a token with alot of characters
Example: NTY5MjU1234567890NTMy.G12345.36as1234lT9PcdFBd-9niSnIOabcDEFGHJ
$DiscordChannelReceive = ""; # This can be blank or you can add up to 5 discordchannels ID's for receiving LFSLapper messages, seperated with a comma "," .
The Discordchannel ID's can be found when you rightclick on the channel and click on "Copy Channel ID".

$DiscordBotStatus = "Powered by LFSLapper!";

#4. Start LFSLapper
When LFSLapper is connected to your LFS Server, you should see the message : "DiscordBot Connected" in your LFSLapper console.
This message also appears in the MSS log file. 'Bin/Default/Logs/xxx.xxx.xxx.xxx-yyyyy.LOG' if you do not have access to the console.

#5. To send message from LFSLapper to your Discord Server. You use the function: sendmessagetodiscord();
You can use this function in a command,sub or event.

Here's an example:

$DiscordChannel = "123456789012345457214";
$Message = "This is a test";
sendmessagetodiscord($DiscordChannel,$Message);

#6.1. To send an message from Discord To LFSLapper, you type a message in one of the discord channels
you've set @ step 3.
Those messagew will be executed in the LapperEvent named: OnReceiveDiscordMessage()

Open LFSLapper.LPR in the default folder and look for the event you see below.

Event OnReceiveDiscordMessage($ChannelID,$ChannelName,$UNameID,$UName,$Text)
#Your code
EndEvent

#6.2. Type and place the current line between Event and EndEvent
globalmsg("^3DiscordMsg: ^3".$Text);

#6.3. Write a message in the discordchannel and press enter.
You should see the message, you've written in your discordchannel.

Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
You will receive no errors, because this is a logical programming error created by the user.

Always think, what the insim need to check first.

In your case, why whould you check the player's speed before checking if the player is OnTrack.
Because you can only check the Speed of the player, if the player is OnTrack.
Bass-Driver
S3 licensed
@RealistAdam.

Made few small changes and tested it. The code below is working.
I've changed the 2 IF statements in a different order.

CASE "!jrr":

$X_Axis = getcurrentplayervar("X"); #X axis SpawnPoint
$Y_Axis = getcurrentplayervar("Y"); #Y axis SpawnPoint
$Z_Axis = getcurrentplayervar("Z"); #Z axis SpawnPoint
$Flags = 128; #Move/Reset car (128) else (0)
$Heading = 0; #Heading of the players car at Spawnpoint
$UCID = 0; #Connection's unique id (0 = host)
$PLID = getcurrentplayervar("PLID"); #Player's unique id
$JRRAction = 4;

IF(GetPlayerVar($userName,"OnTrack") == 1)
THEN
IF ( GetCurrentPlayerVar( "InstantSpeed" ) < 1 )
THEN
$Message = " ```fix\n (". GetCurrentPlayerVar("UserName").") aracını yeniledi. >> (". GetLapperVar ( "LongTime" ) .") ``` ";
$DiscordChannel = "1206604043112157214";
sendmessagetodiscord($DiscordChannel,$Message);
privMsg( GetCurrentPlayerVar("NickName") . " ^7Araç yenileme başarılı.");
joinrequest($X_Axis , $Y_Axis , $Z_Axis , $Flags ,$Heading , $UCID , $PLID ,$JRRAction); #Send Data to LFS
ELSE
privmsg("^3Command abort: Stop the car!");
ENDIF
ELSE
privmsg("^1You cannot use this command in spectatormode");
ENDIF
BREAK;

The incorrect order of IF statements can cause headaches.
Last edited by Bass-Driver, .
Bass-Driver
S3 licensed
This was just an example how i'm debugging my code.

I've rewriting alot of old code lately. Changing the file/folder structure to make saving times less laggy. I haven't changed multiple lines in WriteToFile(), because it was working fine with the old and new filestructure during developing.

But since many people were driving on our server, many new WR's and PB were set. But at some point, it didn't save the times to the new filestructure i've created.

During testing i've reproduced the errors somehow. Restarted Lapper and did the same thing, but now it was working fine. So i was really confused.

After some more testing the same errors occured, but not at the same point from earlier testing.

So i decided to rewrite the the code that rewrites existing lines and creates new lines to the target file.

I'm testing that piece of code now as we speak with multiple people.
The results are looking good so far.
FGED GREDG RDFGDR GSFDG