xArgonx Posted July 9, 2009 Share Posted July 9, 2009 I'm searching for, how i can save values in variables in .xml files. I have already searched in the forum but i could not find any way. Link to comment
50p Posted July 9, 2009 Share Posted July 9, 2009 Why would you want to save variable names and their values inside xml file? Link to comment
xArgonx Posted July 9, 2009 Author Share Posted July 9, 2009 to save skins for example or money sql is to slowly Link to comment
50p Posted July 9, 2009 Share Posted July 9, 2009 SQLite is the fastest. You can also use MySQL module to use MySQL. Saving variables is silly in my opinion... Link to comment
xArgonx Posted July 9, 2009 Author Share Posted July 9, 2009 and how are the comands for sql? Link to comment
50p Posted July 9, 2009 Share Posted July 9, 2009 http://development.mtasa.com/index.php? ... _functions Link to comment
xArgonx Posted July 9, 2009 Author Share Posted July 9, 2009 and how can i set a variable to a definiton of the table Link to comment
50p Posted July 10, 2009 Share Posted July 10, 2009 Check the executeSQLCreateTable. You can name columns only when you create a table. Link to comment
knash94 Posted July 10, 2009 Share Posted July 10, 2009 https://mtasa.com/forum/viewtopic.php?f= ... 92c1a90794 may help you on my post... if you are on nightly i will update the script later so it will work Link to comment
xArgonx Posted July 10, 2009 Author Share Posted July 10, 2009 i have already read that topic, but it would be very nice of you, if u can update it for nightly... Link to comment
knash94 Posted July 11, 2009 Share Posted July 11, 2009 function dbadd () executeSQLCreateTable ( "ppplayers", "money INTEGER, health INTEGER, armour INTEGER, job TEXT, wanted INTEGER, player TEXT" ) end addCommandHandler ("dbadd", dbadd) function updatedb ( sourcePlayer, theTeam ) sourcename = getPlayerName ( sourcePlayer ) player = executeSQLSelect ( "ppplayers", "player", "player = '" .. sourcename .. "'" ) if ( player == false ) then outputChatBox("You have no account to update", sourcePlayer) else executeSQLUpdate ( "ppplayers", "money = '800', health = '50', armour = '100', job = 'Police', wanted = '1'", "player = '" .. sourcename .. "'" ) outputChatBox ("Update finished", sourcePlayer) end end addCommandHandler ("updatedb", updatedb) function onjoindb () local sourcename = getPlayerName ( source ) player = executeSQLQuery("SELECT money FROM ppplayers WHERE player=?", sourcename) if(#player == 0) then executeSQLInsert ( "ppplayers", "'600', '100', '0', 'Civillian', '0', '" .. sourcename .. "'" ) outputChatBox ( "This is your first time here! Welcome " .. sourcename .. "!", source ) else setPlayerMoney( source, player[1].money ) -- wanted = executeSQLQuery("SELECT wanted FROM ppplayers WHERE player=?", sourcename) setPlayerWantedLevel ( source, wanted[1].wanted ) -- job = executeSQLQuery("SELECT job FROM ppplayers WHERE player=?", sourcename) end end addEventHandler ( "onPlayerJoin", getRootElement(), onjoindb ) function onquitdb () local sourcename = getPlayerName ( source ) getmoney = getPlayerMoney ( source ) getplayerTeam = getPlayerTeam ( source ) wanted = getPlayerWantedLevel( source ) playerTeam = getTeamName ( getplayerTeam ) executeSQLUpdate ( "ppplayers", "money = '" .. getmoney .. "', health = '50', armour = '100', job = '" .. playerTeam .. "', wanted = '" .. wanted .. "'", "player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerQuit", getRootElement(), onquitdb ) Not all the functions work but you can easily change/fix it Link to comment
xArgonx Posted July 11, 2009 Author Share Posted July 11, 2009 could u post what u have changed? Link to comment
knash94 Posted July 12, 2009 Share Posted July 12, 2009 Im sorry but you must be able to tell the diffrence if you look at both codes Link to comment
xArgonx Posted July 13, 2009 Author Share Posted July 13, 2009 ok your right sry, i was a bit busy since i read your post first^^ i do not get any error messages now, but if i use /dbadd or updatedb nothing happens and nothing is saved Link to comment
knash94 Posted July 15, 2009 Share Posted July 15, 2009 Well the server your using does it have teams on it? It dont work without teams and updateDB doesnt need to be used.. It was to test it before. ( And its outdated ) Link to comment
xArgonx Posted July 15, 2009 Author Share Posted July 15, 2009 yes i have already writen and started a working script which creates team on server start Link to comment
xArgonx Posted July 22, 2009 Author Share Posted July 22, 2009 actually i tried to go on whith the script i postet before now it is: function dbadd (commandName) executeSQLCreateTable ( "Players", "Money INTEGER, Skin INTERGER, Team TEXT, Wanted INTEGER, Player TEXT" ) end addCommandHandler ("dbadd", dbadd) function onjoindb () local sourcename = getPlayerName ( source ) player = executeSQLQuery("SELECT Money FROM eVo_Players WHERE Player=?", sourcename) if(#player == 0) then executeSQLInsert ( "Players", "'5000', '0', 'Arbeitsloser', '0', '" .. sourcename .. "'" ) else money = executeSQLQuery ("SELECT Money FROM Players WHERE Player=?", sourcename) setPlayerMoney( source, player[1].money ) -- wanted = executeSQLQuery("SELECT Wanted FROM Players WHERE Player=?", sourcename) setPlayerWantedLevel ( source, wanted[1].wanted ) -- team = executeSQLQuery("SELECT Team FROM Players WHERE Player=?", sourcename) setPlayerTeam (source, team[1].team) -- skin = executeSQLQuery ("SELECT Skin FROM Players WHERE Player=?", sourcename) setElementModel (source, skin[1].skin) end end addEventHandler ( "onPlayerJoin", getRootElement(), onjoindb ) function onquitdb () local sourcename = getPlayerName ( source ) getmoney = getPlayerMoney ( source ) playerskin = getElementModel ( source ) getwanted = getPlayerWantedLevel( source ) playerTeam = getTeamName(playersTeam) playersTeam = getplayerTeam (source) executeSQLUpdate ( "Players", "Money = '" .. getmoney .. "', Skin = ' "..playerskin.. " ', Team = '" .. playerTeam .. "', Wanted = '" .. getwanted .. "'", "Player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerQuit", getRootElement(), onquitdb ) i get theses error messages: line 35: attemp to global 'getPlayerTeam' [this error could be thata i did not be in a team while testing, but i already change the team every time i tried to get the script working) i think the problem is that the executeSQLInsert does not start... hope you can help me Link to comment
Gamesnert Posted July 22, 2009 Share Posted July 22, 2009 line 35: attemp to global 'getPlayerTeam' Yet in the code, I find this: getplayerTeam (source) getplayerTeam and getPlayerTeam are quite different. Link to comment
xArgonx Posted July 22, 2009 Author Share Posted July 22, 2009 ok that's right the other problem is that i think the executeSQLInsert does to start, so there is nothing to update or to get from because there is no row for a player in the sql data table Link to comment
knash94 Posted July 24, 2009 Share Posted July 24, 2009 Well drop the players table and try again maybe you have used that table for somthing before. Link to comment
xArgonx Posted July 25, 2009 Author Share Posted July 25, 2009 i have already tried that, but it doesn't change anything, i think maybe there will not create any row for the users 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