Advertisement
Guest User

newbie

a guest
Sep 21st, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1.  
  2.  
  3.  
  4. local isInSaveDB = {}
  5. local db = dbConnect("sqlite", "/playerstats.db")
  6. 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)")
  7.  
  8. function loadData(query)
  9.     local d = dbPoll(query, 0)
  10.    
  11.     if (not d) then return end
  12.     for ind, data in ipairs(d) do
  13.         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}
  14.     end
  15. end
  16. dbQuery(loadData, db, "SELECT * FROM stats")
  17.  
  18. function setData(plr)
  19.  
  20.     local account = getAccountName(getPlayerAccount(plr))
  21.     if (account ~= "guest") then
  22.    
  23.     local arrests = getElementData(plr, "arrests")
  24.     local arrestpoints = getElementData(plr, "arrestpoints")
  25.     local pilot = getElementData(plr, "pilot")
  26.     local paramedic = getElementData(plr, "paramedic")
  27.     local firefighter = getElementData(plr, "firefighter")
  28.     local busdriver = getElementData(plr, "busdriver")
  29.     local mechanic = getElementData(plr, "mechanic")
  30.     local hooker = getElementData(plr, "hooker")
  31.     local trucker = getElementData(plr, "trucker")
  32.     local Fishs = getElementData(plr, "Fishs")
  33.     local Trainstop = getElementData(plr, "Trainstop")
  34.  
  35.     if (isInSaveDB[account]) then
  36.             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))
  37.             isInSaveDB[account] = {arrests, arrestpoints, pilot, paramedic, firefighter, busdriver, mechanic, hooker, trucker, Fishs, Trainstop}
  38.  
  39.         else
  40.             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))
  41.             isInSaveDB[account] = {arrests, arrestpoints, pilot, paramedic, firefighter, busdriver, mechanic, hooker, trucker, Fishs, Trainstop}
  42.         end
  43.     end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement