BeamMB Paramater in Server To Client APP

I have create a
MP.TriggerClientEventJson(-1, “SetRaceRequirements”, [{ “PSKG”: strRaceType, “Tires”: strTireType }]) event and i want those 2 values to be sent to my APP on the client side of the server. I need the race requirements to be displayed for the driver. I am using a basic PS/KG app for a test and wants to display this 2 extra values in this APP. Please help?

Hello (:

Try something like the following to send data from server to client.

Server:

local strRaceType = "Default" --whatever you would use
local strTireType = "Default"--whatever you would use
local encodedData = {} --create table to store data
encodedData.PSKG = strRaceType --add PSKG
encodedData.Tires = strTireType -- add Tires
MP.TriggerClientEventJson(-1, "SetRaceRequirements", encodedData) --send data to client

Client:

local yourData --a variable to receive what results from SetRaceRequirements()
AddEventHandler("SetRaceRequirements", SetRaceRequirements) --register the event to be called from the server
local function SetRaceRequirements(encodedData)
    local decodedData = jsonDecode(encodedData) --jsonDecode is provided by BeamNG
    --do something with decodedData, like
    yourData = decodedData
end
print(yourData.PSKG)
>>> Default
print(yourData.Tires)
>>> Default

I hope this makes sense, let me know if you have any questions.