Bon voilà j'ai fait cela , j'utilise une Base de donnée MYSQL , bon au niveau de la DB cela save bien la position et l'update bien quand je déco MAIS quand je me reconnecte à nouveau sa me mets sur les positions 0, 0, 0.. Je comprends pas pourquoi
local db = exports.db:getDBConnection()
addEventHandler("onPlayerJoin", getRootElement(), function()
fadeCamera(source, true)
setCameraTarget(source, source)
local username = getPlayerName(source)
local qh = dbQuery(db, "SELECT * FROM users WHERE username=?", username)
local result = dbPoll (qh, -1)
local row = result[1]
if not row then
spawnPlayer(source, 1743.63281, -1861.50757, 13.57743)
local x, y, z = getElementPosition(source)
dbExec(db, 'INSERT INTO users (username, posX, posY, posZ) VALUES (?,?,?,?)', username, x, y, z)
else
local x, y, z = getElementPosition(source)
setElementPosition(source, x, y, z)
end
end)
addEventHandler("onPlayerQuit", getRootElement(), function()
local x, y, z = getElementPosition(source)
local username = getPlayerName(source)
outputDebugString("x: "..x..", y: "..y..", z: "..z)
dbExec(db, 'UPDATE users SET posX = ?, posY = ?, posZ = ?', x, y, z)
end)