#Verify each first word/command that starts with a "!".
SWITCH($command)
CASE "!command":
#your code
BREAK
DEFAULT:
#privmsg("Command does not exist");
BREAK;
ENDSWITCH
$toplist = getlisttopuser($value,$flagdesc,$flagNear,$StartPos); #Get List from stored database
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
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.
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
getlisttopuser();
$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
$ListOfPlayers = GetListOfPlayers("U");
$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
Sub BlahBlah($something,$something);
EndSub
CASE "!http":
$user = $argv;
http("http://localhost/Test/LFSLapper_Test.php?u=".$user);
BREAK;
<?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");';
}
?>
Example
'privmsg('$username.',"something");';
'globalmsg("something");';
'YourOwnNamedFunction("Parameter");';
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)
$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
<?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 '0x' 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 '0x' 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);
?>
#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.
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;