<?php
{"data":{"id":"1AF20E","name":"TOMMY28","descriptionShort":"Tommy 28 - A vintage racing car from 1920'","description":"feel the vintage racing with big moustache and reckless drivers\r\ndo not search extrem grip, do not search evil power, but be extremely sharp in your track feeling with this 1928 Tommy racing car.\r\n\r\n2 configs :\r\n- Sport : stricly minimum to race\r\n- Sport Lux : tiny windscreen and lights (very usefull when LFS release the night races)\r\n\r\nMartin18 has work on the 8 inline engine !\r\nFlame CZE give me authorisation for his Hadraplan's steering wheel, clocks and mirrors (modified)\r\nNene87 help me on editor and blender at the beginning\r\n\r\nClocks are old but it works.\r\nsee the motor behind events ;)\r\nlook at the hand-polishing chromes !\r\n2 versions\r\n\r\nantiroll bar are finally added to maintain fun to drive (it was very slippery without)\r\n\r\n- skins with racing numbers and vintage look\r\n- suspensions 3d anim on the rear\r\n- lean driver animation","userId":79595,"userName":"Tomfuel","wip":true,"publishedAt":1640879379,"numDownloads":3803,"curUsage":0,"rating":4.34,"numRatings":43,"staffPick":false,"tweakMod":false,"version":5,"lastDownloadedAt":1640881808,"class":2,"ev":false,"coverUrl":"https:\/\/www.lfs.net\/attachment\/276798","screenshotUrls":["https:\/\/www.lfs.net\/attachment\/274160","https:\/\/www.lfs.net\/attachment\/274161","https:\/\/www.lfs.net\/attachment\/274162","https:\/\/www.lfs.net\/attachment\/274163","https:\/\/www.lfs.net\/attachment\/274164","https:\/\/www.lfs.net\/attachment\/274165","https:\/\/www.lfs.net\/attachment\/274166","https:\/\/www.lfs.net\/attachment\/274167"],"vehicle":{"iceCc":5237,"iceNumCylinders":8,"iceLayout":0,"evRedLine":0,"drive":1,"shiftType":1,"power":81.76211547851562,"maxPowerRpm":3586,"torque":233.3720703125,"maxTorqueRpm":1687,"mass":889.9309692382812,"bhp":109.66752549133301,"powerWeightRatio":91.87467152480184,"bhpTon":125.20896003186276,"fuelTankSize":39.000003814697266}}}
?>
public class GetCarInfo
{
public ModCarEntry CarInfo { get; set; }
}
public class ModCarEntry
{
public string id { get; set; }
public string name { get; set; }
public string descriptionShort { get; set; }
public string description { get; set; }
public int userId { get; set; }
public string userName { get; set; }
public bool wip { get; set; }
public int publishedAt { get; set; }
public int numDownloads { get; set; }
public int curUsage { get; set; }
public double rating { get; set; }
public int numRatings { get; set; }
public int version { get; set; }
public int lastDownloadedAt { get; set; }
public int _class { get; set; }
public bool ev { get; set; }
public string coverUrl { get; set; }
public List<string> screenshotUrls { get; set; }
public CarDetails details { get; set; }
}
public class CarDetails
{
public int iceCc { get; set; }
public int iceNumCylinders { get; set; }
public int iceLayout { get; set; }
public int evRedLine { get; set; }
public int drive { get; set; }
public int shiftType { get; set; }
public double power { get; set; }
public int maxPowerRpm { get; set; }
public double torque { get; set; }
public int maxTorqueRpm { get; set; }
public double mass { get; set; }
public double bhp { get; set; }
public double powerWeightRatio { get; set; }
public double bhpTon { get; set; }
public double fuelTankSize { get; set; }
}
<?php
#####DISCORD VARIABLES#####
$DiscordToken = "";
$DiscordChannelReceive = ""; #discordchannel to sent commands to LFSLapper. (Rightclick on the channel and click 'Copy ID')
$DiscordBotStatus = "Powered by LFSLapper";
?>
sendmessagetodiscord($DiscordChannel,$Message);
<?php
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 "!message":
$Message = $argv;
$DiscordChannel = "";
sendmessagetodiscord($DiscordChannel,$Message);
BREAK;
ENDSWITCH
EndEvent
?>
// For Task<T>: will block until the task is completed...
var result = task.Result;
<?php
public void getmoddedcarinfo(GLScript.unionVal val, ArrayList args)
{
infoPlayer currInfoPlayer = newCfg.getCurrInfoPlayer();
string ident = val.nameFunction;
var CarInfo = LFSRestAPI.GetModdedCars(newCfg.varsLapper.RestAPIClientID, newCfg.varsLapper.RestAPIClientSecret).Result;
for (int i = 0; i < CarInfo.Count; i++)
{
Console.WriteLine(CarInfo[i].id + " = " + CarInfo[i].name);
}
}
?>
The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
'Task<List<LFSRestAPI.ModCarEntry>>' does not contain a definition for 'Count' and no extension method 'Count' accepting a first argument of type 'Task<List<LFSRestAPI.ModCarEntry>>' could be found (are you missing a using directive or an assembly reference?)
<?php
public void getmoddedcarinfo(GLScript.unionVal val, ArrayList args)
{
infoPlayer currInfoPlayer = newCfg.getCurrInfoPlayer();
string ident = val.nameFunction;
var v = await LFSRestAPI.GetModdedCars(newCfg.varsLapper.RestAPIClientID, newCfg.varsLapper.RestAPIClientSecret);
for (int i = 0; i < v.Count; i++)
{
Console.WriteLine(v[i].name);
}
}
?>
/* get data */
var list = LFSRestAPI.GetModdedCars(newCfg.varsLapper.RestAPIClientID, newCfg.varsLapper.RestAPIClientSecret);
/* Serialize data to string */
string json = JsonConvert.SerializeObject(list, new JsonSerializerSettings());
//Console.WriteLine(json); // this works yippie:)
============================================================================
/* Deserialize string to object */
LFSRestAPI.ModCarEntriesResponse Cars = JsonConvert.DeserializeObject<LFSRestAPI.ModCarEntriesResponse>(json);
foreach (var car in Cars.Data)
{
Console.WriteLine("" + car.name);
}[/php]
====================================================================
/* Deserialize string to object */
var Cars = JsonConvert.DeserializeObject<List<LFSRestAPI.ModCarEntry>>(json);
foreach (var car in Cars)
{
Console.WriteLine("" + car.name);
}[/php]
edit:
tried this aswell
===============================================================
List<LFSRestAPI.ModCarEntry> cars = JsonConvert.DeserializeObject<List<LFSRestAPI.ModCarEntry>>(json);
foreach (LFSRestAPI.ModCarEntry car in cars)
{
Console.WriteLine("field0: " + car.id);
}
<?php
using Newtonsoft.Json.Linq;
JArray NewArray = JArray.Parse(list.ToString());
foreach (JObject Car in NewArray)
{
Console.WriteLine($"{Car["id"]} -> {Car["name"]}");
}
?>
<?php
JArray NewArray = JArray.Parse(list.ToString());
int nrofmods = NewArray.Count;
?>
<?php
//scriptFunction.cs
/* Function i call from a LFSLapper Script, this is fine.
CASE "!gm":
GetModdedCarInfo();
BREAK;*/
public void GetModdedCarInfo(GLScript.unionVal val, ArrayList args)
{
infoPlayer currInfoPlayer = newCfg.getCurrInfoPlayer();
string ident = val.nameFunction;
var list = LFSRestAPI.GetModdedCars(newCfg.varsLapper.RestAPIClientID, newCfg.varsLapper.RestAPIClientSecret);
}
//LFSRestAPI.cs
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System;
using Configurator;
namespace LapperThreads
{
public class LFSRestAPI
{
public static async Task<List<ModCarEntry>> GetModdedCars(string RestclientID, string RestclientSecret)
{
/*just a few warning messages*/
if (string.IsNullOrWhiteSpace(RestclientSecret))
{
Console.WriteLine("ClientSecret Empty");
}
if (string.IsNullOrWhiteSpace(RestclientID))
{
Console.WriteLine("ClientID Empty");
}
var client = new HttpClient();
var content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"client_secret", RestclientSecret },
{"client_id", RestclientID },
{"grant_type", "client_credentials"}
});
var tokenResponse = await client.PostAsync("https://id.lfs.net/oauth2/access_token", content);
var tokenText = await tokenResponse.Content.ReadAsStringAsync();
var tokenObject = JsonConvert.DeserializeObject<TokenResponse>(tokenText);
var accessToken = tokenObject.access_token;
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
var carEntriesResponse = await client.GetStringAsync("https://api.lfs.net/vehiclemod/");
return JsonConvert.DeserializeObject<ModCarEntriesResponse>(carEntriesResponse).Data;
}
public class TokenResponse
{
public string token_type { get; set; }
public int expires_in { get; set; }
public string access_token { get; set; }
}
public class ModCarEntriesResponse
{
public List<ModCarEntry> Data { get; set; }
}
public class ModCarEntry
{
public string id { get; set; }
public string name { get; set; }
public string descriptionShort { get; set; }
public string description { get; set; }
public int userId { get; set; }
public string userName { get; set; }
public bool wip { get; set; }
public int publishedAt { get; set; }
public int numDownloads { get; set; }
public int curUsage { get; set; }
public float rating { get; set; }
public int numRatings { get; set; }
public int version { get; set; }
public int lastDownloadedAt { get; set; }
public int _class { get; set; }
public bool ev { get; set; }
}
}
}
?>
V2.7(11-12-2021)
-Fix: Window overlap when using Timetable and Reportwindow at the same time.
-Fix: [Times] more efficient way to set/get WR Save when finishing with a WR/PB.(Rewrite)
-Update: [Times] New system to retrieve/save times from/to database (Rewrite)
-Update: [Times] Scheduled save local times to database ( every 15 min if anything has changes within the timetable (PB/WR))
-Update: [TimeTable]: Displays the current list of times of your current car, instead of total timelist.
-Update: [TimeTable]: Filter on 1 car instead of multiple car.
-Disabled [TimeTable]: WR List
-Removed: [TimeTable]: Username filter
V2.6(24-11-2021)
-Add: Modsupport
-Add: CarDamage (TestFase) , get damage while colliding with AutoX objects or Other cars
-Add: [Admincommands]: !amod/!dmod (Add/Delete mod to/from whitelist)
-Add: [PlayerCommand]: !fix (Fix cardamage)
-Update: [LFSLapper] Updated library to 7.0.9.0 Test #5
-Update: [TimeTable] changed design to support mods (SkinID)
-Update: [Top HUD] Small design changes.
=================================================
Fix:
================================================
1: [Event]: OnPlayerSelectCar() didnt displayed the name of the car correctly
2: [Event]: Several Events like (OnDist(), OnDriftScore()) didn't execute when more than 8 players on the track
Caused by MCI packet manager didn't allow more than 8 players on the track.
=================================================
Changed:
=================================================
1: Updated trackList.cfg
=================================================
Fixed:
=================================================
1: Lappercrash when loading more than 30 objects at once
1: [LapperFunction]: SetListAllowedMods(); Set allowed mods. Max 120 mods allowed
<?php
CASE "!setmodlist":
SetListAllowedMods("4A1C57,FA2989,39CEEB,238F06");
#SetListAllowedMods(""); #Allow all mods.
BREAK;
?>
2: [LapperFunction]: GetListAllowedMods(); Get list of allowed mods.
<?php
CASE "!getmodlist":
$List = getlistallowedmods();
$NrOfMods = ToNum($List["NrOfAllowedMods"]);
privmsg("^7===== ^3List of Allowed mods ^7(".$NrOfMods.") ^3mods ^7=====");
IF($NrOfMods == 0) THEN
privmsg("^3All mods are allowed!");
ELSE
FOR ( $i = 0; $i < $NrOfMods ; $i = $i + 1)
privmsg("^7Mod ^0[^3".$i+1."^0]^7: ".$List[$i,"SkinID"]);
ENDFOR
ENDIF
BREAK;
?>
+---------------------------------------------------------------+
|Changes from 7.0.9.0 TEST #1 to 7.0.9.0 TEST #2
+---------------------------------------------------------------+
=================================================
New:
=================================================
1: New Playervar: "SkinName". GetPlayerVar("SkinName");
=================================================
Changed:
=================================================
1: PlayerVar: GetPlayerVar("Car"); , Will now display the SkinID, if you've selected a mod.