papam77 Posted February 18, 2013 Share Posted February 18, 2013 Hey, i want saving user panel db to web. How can do it ? ------------------------------------------ -- Load & Save Data ------------------------------------------ function loadPlayerData (player,datatype) local playerSerial = getPlayerSerial (player) if (playerSerial) then local root = xmlLoadFile ("DataBase.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. playerSerial,0) if not (playerRootNode == false) then local playerData = xmlNodeGetAttribute (playerRootNode,datatype) if (playerData) then xmlUnloadFile (root) --outputDebugString("---- LoadD: "..getPlayerName(player).." , "..datatype.." , "..playerData) return playerData else xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) --outputDebugString("---- LoadD: "..getPlayerName(player).." , "..datatype.." , 0") return 0 end else local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. playerSerial) xmlNodeSetAttribute (playerRootNode,datatype,0) xmlSaveFile (root) xmlUnloadFile (root) --outputDebugString("---- LoadD: "..getPlayerName(player).." , "..datatype.." , 0") return 0 end end end end end function savePlayerData (player,datatype,newvalue) local playerSerial = getPlayerSerial (player) if (playerSerial) then local root = xmlLoadFile ("DataBase.xml") if (root) then local usersNode = xmlFindChild (root,"user",0) if (usersNode) then local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. playerSerial,0) if not (playerRootNode == false) then local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) --outputDebugString("---- SaveD: "..getPlayerName(player).." , "..datatype.." , "..newvalue) return newNodeValue else local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. playerSerial) local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue) xmlSaveFile (root) xmlUnloadFile (root) --outputDebugString("---- SaveD: "..getPlayerName(player).." , "..datatype.." , "..newvalue) return newNodeValue end end end end end to ----> http://kfc-gaming.eu/DataBase.xml Link to comment
Gallardo9944 Posted February 18, 2013 Share Posted February 18, 2013 save your data at MySQL database and then read it from your site. dbConnect() dbQuery() These functions will help you. Link to comment
papam77 Posted February 18, 2013 Author Share Posted February 18, 2013 full script please Link to comment
manve1 Posted February 18, 2013 Share Posted February 18, 2013 full script please why would u need full script while problem isn't in whole script? just maybe in one line Link to comment
papam77 Posted February 18, 2013 Author Share Posted February 18, 2013 full script please why would u need full script while problem isn't in whole script? just maybe in one line But i am not scripter I can only html and css Link to comment
iPrestege Posted February 18, 2013 Share Posted February 18, 2013 full script please why would u need full script while problem isn't in whole script? just maybe in one line But i am not scripter I can only html and css Learn Lua .? Link to comment
papam77 Posted February 18, 2013 Author Share Posted February 18, 2013 Learn Lua .? Too hard for my brain Link to comment
manve1 Posted February 18, 2013 Share Posted February 18, 2013 take your time, it took me 8months to learn .. Link to comment
tosfera Posted February 18, 2013 Share Posted February 18, 2013 Learn Lua .? Too hard for my brain if learning lua is to hard for your brain, start at the highest point and jump down! With saying that I mean, you want to learn lua and also make something usefull for your self, so... Create a script that saves the user information into a database, just keep it simple first. Save the serial of an user in a table, you can use the function dbConnect and executeSQLQuery for that. First thing to do is create a dbconnection dbConnect( "sqlite", "file.db" ) -- string databaseType, string host after you got the connection to your database, you can start selecting and inserting stuff. Before you can do this, you need to have alitle knowledge about SQL. but the functions you're going to use are; create table insert select to help you into the right direction: local dbType = "sqlite" local dbFile = "mtaServer.db" addEventHandler("onResourceStart", root, function () local create = executeSQLQuery("CREATE TABLE IF NOT EXISTS `players` (`serial` TEXT)") if ( create ) then outputChatBox("Table created!") end end ) addCommandHandler("saveSerial", function ( source ) local serial = getPlayerSerial( source ) local insert = executeSQLQuery("INSERT INTO players(serial) VALUES(?)", serial ) if ( insert ) then outputChatBox("Serial saved into the db!") end end ) (haven't tested it) Link to comment
papam77 Posted February 19, 2013 Author Share Posted February 19, 2013 A joining to DB file is this code ? local function connect( ) -- retrieve the settings local server = get( "server" ) or "localhost" local user = get( "user" ) or "root" local password = get( "password" ) or "" local db = get( "database" ) or "mta" local port = get( "port" ) or 3306 local socket = get( "socket" ) or nil 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