Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oprint = print
- local print = function(...)
- local t = {...}
- for k,v in pairs(player.GetAll()) do
- v:ChatPrint(t[1])
- end
- return oprint(...)
- end
- local oldusers, err = ULib.parseKeyValues( ULib.fileRead( ULib.UCL_USERS ) )
- local size = table.Count(oldusers)
- print("syncing users, should end up being: " .. tostring(size) .. "in mysql!")
- local db = ulx_leysql.sqldb.dbobj
- local values = {}
- for k,v in pairs(oldusers) do
- if(not v.group) then continue end
- table.insert(values, "(" .. util.SteamIDTo64(k) .. ", '" .. db:escape(v.group) .. "')")
- end
- local user_add = db:query("INSERT IGNORE INTO `lsql_users`(`steamid`, `group`) VALUES " .. table.concat(values, ","))
- user_add:start()
- local check_query = db:query("SELECT COUNT(*) as `cunt` FROM `lsql_users`")
- check_query.onSuccess = function(q, tbl)
- if(not tbl[1]) then print("something went wrong while syncing! :(") return end
- local num = tbl[1]["cunt"]
- if(num >= size) then
- ErrorNoHalt("Successfully synced: " .. tostring(num) .. "users !")
- else
- ErrorNoHalt("Something went wrong! " .. num .. " users out of " .. size .. " got synced! :(")
- end
- end
- check_query.onError = function(q, s)
- ErrorNoHalt("Something went wrong! " .. q .. " :: " .. s)
- end
- check_query:start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement