so lets say your checkpoints is saved as a table like so…
checkpoints = {
[1] = {x = 0.0, y = 0.0, z = 0.0},
[2] = {x = 1.0, y = 1.0, z = 1.0},
}
You can pass that table with the TriggerServerEvent I guess you are already doing?
All you would need to do then is create a unique ID/name to the track you are saving in the database I guess RaceID/insertId is something you already setup todo this?
then on the mysql insert and fetch it would look something like this:
MySQL.Async.insert('INSERT INTO RaceCheckpoints (RaceID, raceData) VALUES (@RaceID, @raceData)',
{ ['@RaceID'] = insertId, ['@raceData'] = json.encode(checkpoints)})
end
so for example it would look like this in the database and LUA would not recognise it as a table:
[{"1":{"x":"0.0", "y":"0.0", "z":"0.0"} "2":{"x":"1.0", "y":"1.0", "z":"1.0"}]
To get the databack into a format lua would recognise you would use json.decode and it would look something like this:
MySQL.Async.fetchAll('SELECT * FROM RaceCheckpoints WHERE RaceID=@RaceID',{['@RaceID'] = what ever race id you want to fetch..)}, function(RecievedData)
if RecievedData[1] ~= nil then
checkpoints = json.decode(RecievedData[1].raceData)
--Put a callback here to the client so they recieve the data.
end
end)
It would then be back into the lua table format like so:
checkpoints = {
[1] = {x = 0.0, y = 0.0, z = 0.0},
[2] = {x = 1.0, y = 1.0, z = 1.0},
}