Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local isInSaveDB = {}
- local db = dbConnect("sqlite", "/playerstats.db")
- dbExec(db, "CREATE TABLE IF NOT EXISTS stats (account TEXT, arrests TEXT, arrestpoints TEXT, pilot TEXT, paramedic TEXT, firefighter TEXT, busdriver TEXT, mechanic TEXT, hooker TEXT, trucker TEXT, Fishs TEXT, Trainstop TEXT)")
- function loadData(query)
- local d = dbPoll(query, 0)
- if (not d) then return end
- for ind, data in ipairs(d) do
- isInSaveDB[data.account] = {data.arrests, data.arrestpoints, data.pilot, data.paramedic, data.firefighter, data.busdriver, data.mechanic, data.hooker, data.trucker, data.Fishs, data.Trainstop}
- end
- end
- dbQuery(loadData, db, "SELECT * FROM stats")
- function setData(plr)
- local account = getAccountName(getPlayerAccount(plr))
- if (account ~= "guest") then
- local arrests = getElementData(plr, "arrests")
- local arrestpoints = getElementData(plr, "arrestpoints")
- local pilot = getElementData(plr, "pilot")
- local paramedic = getElementData(plr, "paramedic")
- local firefighter = getElementData(plr, "firefighter")
- local busdriver = getElementData(plr, "busdriver")
- local mechanic = getElementData(plr, "mechanic")
- local hooker = getElementData(plr, "hooker")
- local trucker = getElementData(plr, "trucker")
- local Fishs = getElementData(plr, "Fishs")
- local Trainstop = getElementData(plr, "Trainstop")
- if (isInSaveDB[account]) then
- dbExec(db, "UPDATE stats SET arrests=?, arrestpoints=?, pilot=?, paramedic=?, firefighter=?, busdriver=?, mechanic=?, hooker=?, trucker=?, Fishs=?, Trainstop=? WHERE account=?", tostring(arrests), tostring(arrestpoints), tostring(pilot), tostring(paramedic), tostring(firefighter), tostring(busdriver), tostring(mechanic), tostring(hooker), tostring(trucker), tostring(Fishs), tostring(Trainstop), tostring(account))
- isInSaveDB[account] = {arrests, arrestpoints, pilot, paramedic, firefighter, busdriver, mechanic, hooker, trucker, Fishs, Trainstop}
- else
- dbExec(db, "INSERT INTO stats (account, arrests, arrestpoints, pilot, paramedic, firefighter, busdriver, mechanic, hooker, trucker, Fishs, Trainstop) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", tostring(account), tostring(arrests), tostring(arrestpoints), tostring(pilot), tostring(paramedic), tostring(firefighter), tostring(busdriver), tostring(mechanic), tostring(hooker), tostring(trucker), tostring(Fishs), tostring(Trainstop))
- isInSaveDB[account] = {arrests, arrestpoints, pilot, paramedic, firefighter, busdriver, mechanic, hooker, trucker, Fishs, Trainstop}
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement