Monsthers Posted December 9, 2015 Share Posted December 9, 2015 Hello, i have this script and has one error, please help me Error [2015-12-08 17:56:21] ERROR: rpgLogin\sql.lua:24: Database query failed: no such column: loggedin [2015-12-08 17:56:21] ERROR: rpgLogin\sql.lua:26: attempt to index field '?' (a nil value) Script --[[ +---------------------------------------------------------------------------- | SAMS:RPG v1 | ======================================== | by SAMS Scripting Team | All rights reserved. | [url=http://www.sams.net]http://www.sams.net[/url] | ======================================== +----------------------------------------------------------------------------- | You are not allowed to adapt, copy, redistribute this script. | You are not allowed to use this script outside servers ran by [url=http://www.samsYUDA.net]www.samsYUDA.net[/url] +----------------------------------------------------------------------------- ]]-- local blockedUsernames = {["console"] = true,["admin"]= true,["moderator"]= true,["guest"]= true,["none"]= true,["saes"]= true,["[saes]"]= true,["sa housing agency"]= true,["sa_housing_agency"] = true} executeSQLQuery("CREATE TABLE IF NOT EXISTS user_data (id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, pwsalted TEXT, groups TEXT, email TEXT, money INTEGER, wanted TINYINT, jailed BOOLEAN, lastnick TEXT, lastlogin TEXT)") function playerLogin(username,password,serial) if getElementData(source,"loggedIn") then return triggerClientEvent(source,"RPGlogin.errorBox",source,"You are already logged in.") end local ip = getPlayerIP(source) local playername = getPlayerName(source) local playerQuery = executeSQLQuery("SELECT id, loggedin FROM user_data WHERE username = ? AND pwsalted = ? LIMIT 1",username,password) if playerQuery and #playerQuery > 0 then if (playerQuery[1].loggedin == 1) then return triggerClientEvent(source,"RPGlogin.errorBox",source,"Your account is already in use.") end local account = setElementData(source,"username",username) local id = setElementData(source,"id",playerQuery[1].id) if account and id then local thetime = getRealTime() local MM = thetime.month+1 if MM < 10 then MM = "0"..MM end local DD = thetime.monthday if DD < 10 then DD = "0"..DD end local thedate = (thetime.year+1900).."-"..MM.."-"..DD local ip = getPlayerIP(source) local serial = getPlayerSerial(source) executeSQLQuery("UPDATE user_data SET lastlogin = '"..thedate.."', ip = '"..ip.."', serial = '"..serial.."', loggedin = 1 WHERE username = '"..username.."'") outputChatBox("You are now logged in as: "..username,source,0,255,255) setElementData(source,"loggedIn",true) triggerEvent("onPlayerLogIn",source,playerQuery[1].id,username) triggerClientEvent(source,"RPGlogin.clearLoginGUI",source) outputServerLog(("RPGlogin: %s has successfully logged in as %q. (IP: %s Serial: %s)"):format(playername,username,ip,serial)) triggerClientEvent(source,"RPGlogin.hideLogin",source,true) else triggerClientEvent(source,"RPGlogin.errorBox",source,"Login failed.") end elseif playerQuery then triggerClientEvent(source,"RPGlogin.errorBox",source,"Invalid password specified.") outputServerLog(("RPGlogin: %s failed to log in as %q. Wrong password. (IP: %s Serial: %s)"):format(playername,username,ip,serial)) else triggerClientEvent(source,"RPGlogin.errorBox",source,"An error occurred, please try again") end end addEvent("RPGlogin.playerLogin",true) addEventHandler("RPGlogin.playerLogin",root,playerLogin) function registerPlayer(username,password,email) if username and password and email then if not blockedUsernames[username] then if not username:match("[%s%p]") then local accountQuery = executeSQLQuery("SELECT id FROM user_data WHERE username=? LIMIT 1",username) if accountQuery and #accountQuery == 0 then if executeSQLInsert("user_data","'"..username.."','"..password.."','"..email.."',0,0,1000","'username','pwsalted','email','wanted','jailed','money'") then triggerClientEvent(source,"RPGlogin.showLogin",source) triggerClientEvent(source,"RPGlogin.errorBox",source,"Account registration completed. Your username is "..username..". Remember it.") else triggerClientEvent(source,"RPGlogin.errorBox",source,"Account registration failed") end elseif accountQuery and #accountQuery > 0 then triggerClientEvent(source,"RPGlogin.errorBox",source,"An account with this name has already been registered") else triggerClientEvent(source,"RPGlogin.errorBox",source,"Account registration failed") end else triggerClientEvent(source,"RPGlogin.errorBox",source,"The username you register must not contain any spacing or punctuation") end else triggerClientEvent(source,"RPGlogin.errorBox",source,"This username is blocked") end end end addEvent("RPGlogin.playerRegisterAccount",true) addEventHandler("RPGlogin.playerRegisterAccount",root,registerPlayer) function markAsLogOut() local id = getElementData(source,"id") if id then executeSQLUpdate("user_data","loggedin = 0","id = "..id) end end addEventHandler("onPlayerQuit", root,markAsLogOut) addEvent("onPlayerLogOut",true) addEventHandler("onPlayerLogOut",root,function() setElementData(source,"loggedIn",false) local username = getElementData(source,"username") local id = getElementData(source,"id") if id then executeSQLUpdate("user_data","loggedin = 0","id = "..id) end if not username then username = "N/A" end local ip = getPlayerIP(source) local serial = getPlayerSerial(source) if ip and serial then outputServerLog("RPGlogin: "..getPlayerName(source).." has logged out from '"..username.."' (IP: "..ip.." Serial: "..serial..")") end setElementData(source,"username",nil) setElementData(source,"id",nil) triggerClientEvent(source,"RPGlogin.showLogin",source) killPed(source) fadeCamera(source,false) setElementInterior(source,0) setElementDimension(source,0) end) Link to comment
AlvarO Posted December 9, 2015 Share Posted December 9, 2015 The database "loggedin" doesn't exist, try to create it by yourself. Link to comment
Brophy Posted January 18, 2016 Share Posted January 18, 2016 Stop using stolen scripts. You wont get support for them here. Link to comment
tosfera Posted January 18, 2016 Share Posted January 18, 2016 The database "loggedin" doesn't exist, try to create it by yourself. I like how your lack of knowledge fails you to give the correct answer to a person the entire community refuses to help since the entire community refuses to help people with leaked resources. I'll pm you the answer for his "problem". Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now