Artisz Posted April 21, 2016 Posted April 21, 2016 (edited) Hi! (Sorry for my English!) I want to create an RP login system with mysql. I can save my basic details: Username, password, serial, admin, etc. I want to save the player name too, but I have problems. First, in the system, need to give the username and the password twice. If it is ok, we go to a character creator window, where now there is just the character name's input, nothing else. Somehow I could save the given name in mysql. When I firs logging in to the server, it is running correct, my name is changing. But after a relog, I don't know, what is happening. It writes: false is now known as nil nil is now known as false But in the mysql has no problem. Register, mysql insert: addEvent("onPlayerAttemptFinish",true) addEventHandler("onPlayerAttemptFinish",root, function(name) if (exports["main"]:singleQuery("SELECT charactername FROM accounts WHERE charactername=? LIMIT 1",string.lower(name))) then exports.infobox:showBox (root,"error","Username has already taken!") else local charname = string.gsub(tostring(name), " ", "_") local safecharname = (charname) local x,y,z = 1450.32421875, -2287.287109375, 13.546875 username = getElementData(source, "accountUsername") password1 = getElementData(source, "accountPassword") if (dbExec(kapcsolat, "INSERT INTO accounts (username,password,mtaserial,registerdate,ip,admin,warns,money,monitored, charactername) VALUES (?,?,?,?,?,?,?,?,?,?)",string.lower(username),sha256(password1),getPlayerSerial(source), getRealTime(), getPlayerIP (source),0,0,0,0, tostring(safecharname))) then setElementData(source, "CharName", safecharname) triggerClientEvent(source,"switchToLogin",source) end end end) Login addEvent("onPlayerAttemptLogin",true) addEventHandler("onPlayerAttemptLogin",root, function(username,password) if (exports["main"]:singleQuery("SELECT * FROM accounts WHERE username=? LIMIT 1",string.lower(username))) then local accData = exports["main"]:singleQuery("SELECT * FROM accounts WHERE username=? AND password=? LIMIT 1",string.lower(username),sha256(password)) if (accData) then setElementData(source,"accountID",accData.id) setElementData(source,"accountUsername",accData.username) setElementData(source, "adminlevel", accData.admin) setElementData(source, "adminduty", 0) setElementData(source, "skinid", accData.skin) setElementData(source, "money", accData.money) setElementData(source, "dimension", accData.dimension_id) setElementData(source, "CharSkin", accData.charactername) setPlayerName (source, tostring(getPlayerData(source, "CharName"))) setElementModel(source, getElementData(source, "skinid")) fadeCamera(source,false,1.0,0,0,0) setTimer(fadeCamera,2000,1,source,true,1.0,0,0,0) setCameraTarget(source,source) showChat(source,true) showPlayerHudComponent(source,"radar",true) showPlayerHudComponent(source,"area_name",true) --spawnPlayer(source,accData.x,accData.y,accData.z+1,accData.rotation,accData.skin,accData.interior,accData.dimension,accData.team) spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) Edited April 22, 2016 by Guest
Artisz Posted April 22, 2016 Author Posted April 22, 2016 Nevermind. I solved the problem. I misspelled this two lines: setElementData(source, "CharSkin", accData.charactername) setPlayerName (source, tostring(getPlayerData(source, "CharName")))
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