Tockra Posted May 7, 2010 Share Posted May 7, 2010 Hello, i hope i can writte my question understandable. I created an login system. When the player is loggined his for example: PlayerElementData(..."car"...) Shall change to the Value, which is in an mysql Table in the line by "car" where ´Nickname´='name...' I hope you understand all and you can help me. Link to comment
dzek (varez) Posted May 7, 2010 Share Posted May 7, 2010 I created an login system. post your code then, so we can look into your problem.. and what is PlayerElementData ? getElementData/setElementData i think.. i think you have to learn lua more before you will start with databases Link to comment
Tockra Posted May 7, 2010 Author Share Posted May 7, 2010 I created an login system. post your code then, so we can look into your problem.. and what is PlayerElementData ? getElementData/setElementData i think.. i think you have to learn lua more before you will start with databases I had something scripted, when i asked the question I asked because i dont knew how i can do it... Now i have http://pastebay.com/97446 in my onPlayerJoin event, but i get an mysql error for the mysql_fetch_assoc line... What is wrong in my script ? Link to comment
dzek (varez) Posted May 7, 2010 Share Posted May 7, 2010 you should post whole error and code.. anyway: https://forum.multitheftauto.com/viewtop ... oc#p309354 here i wrote how to loop through mysql results.. just remove (you can leave it too) the loop, and do it once.. it wont throw error if you do it like that.. and: its very good idea to script in english.. (funcions names, database columns etc) this is just good habit, but also can help others understanding your code if you need help or if you gonna release it in the future.. Link to comment
Tockra Posted May 8, 2010 Author Share Posted May 8, 2010 you should post whole error and code..anyway: https://forum.multitheftauto.com/viewtop ... oc#p309354 here i wrote how to loop through mysql results.. just remove (you can leave it too) the loop, and do it once.. it wont throw error if you do it like that.. and: its very good idea to script in english.. (funcions names, database columns etc) this is just good habit, but also can help others understanding your code if you need help or if you gonna release it in the future.. okey thx for your help, i found my failor. I used ´´ but i must use `` here is the running code: http://pastebay.com/97525 So new problem, the elements will not set. In my mysql Tabel i have the Value 1 by level but if i show the getPlayerElementData(player,"Level") later in the script it give nil back... Here set the element: local result = mysql_query(Datenbank, "SELECT `Autoschein` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Autoschein", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Bootschein` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Bootschein", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Flugschein` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Flugschein", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Motorradschein` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Motorradschein", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Angelschein` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Angelschein", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Waffenschein` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Waffenschein", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Leader` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "fLeader", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `GeldH` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "GeldH", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `GeldB` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "GeldB", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Adminlevel` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Adminlevel", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Level` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Level", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Geschlecht` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Geschlecht", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Geburtsdatum` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Geburtsdatum", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) local result = mysql_query(Datenbank, "SELECT `Fraktion` FROM `benutzertabelle` WHERE `Benutzername`='"..nick.."'") setElementData( playerid, "Fraktion", tonumber(mysql_fetch_assoc(result)) ) mysql_free_result(result) 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