Taalasmaa Posted July 8, 2009 Share Posted July 8, 2009 Hi, how can I make script, so there will be "autosave" like.. Always when player quit. His datas will be saved.. And when he join his datas will be loaded. I have to get save only for skins, weapons, moneys. Help? Link to comment
50p Posted July 8, 2009 Share Posted July 8, 2009 Why don't you look up the wiki? Start making resources. Take a look into other resources how to make one. Look at the events that are available for you and use them. - http://development.mtasa.com/index.php? ... _Functions - http://development.mtasa.com/index.php? ... ing_Events Link to comment
Taalasmaa Posted July 8, 2009 Author Share Posted July 8, 2009 I didn't wanted answer from you.. And i'm looked these.. Thousand times!! Link to comment
knash94 Posted July 8, 2009 Share Posted July 8, 2009 DP2.3? https://mtasa.com/forum/viewtopic.php?f= ... a12d53f53b and look at my post with the big script Its client side so your meta should be... Link to comment
50p Posted July 8, 2009 Share Posted July 8, 2009 I didn't wanted answer from you..... LMAO, If you want answer from someone specific just ask him not here because here, everyone try to help. And again LOL. DP2.3?https://mtasa.com/forum/viewtopic.php?f= ... a12d53f53b and look at my post with the big script Its client side so your meta should be... If it's client-side why did you put 'type="server"'? If you try to query server's SQLite database from client-side script then no wonder why it doesn't work. Link to comment
knash94 Posted July 8, 2009 Share Posted July 8, 2009 pretty obvius i meant server but lol my mistake Link to comment
Taalasmaa Posted July 8, 2009 Author Share Posted July 8, 2009 It work with money, it save moneys BUT It doesn't save skins/weapons.. I'm using freeroam gamemode, so I need skin saver and weapons saver. Or my server is freeroam/fun/rpg ... Thanks in advance. Link to comment
knash94 Posted July 8, 2009 Share Posted July 8, 2009 function createdb () executeSQLCreateTable ( "ppplayers", "money INTEGER, health INTEGER, armour INTEGER, job TEXT, wanted INTEGER, skin INTEGER,player TEXT" ) end addCommandHandler ("dbadd", createdb ) function updatedb ( sourcePlayer, theTeam ) sourcename = getClientName ( 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'", "skin = '110'", "player = '" .. sourcename .. "'" ) outputChatBox ("Update finished", sourcePlayer) end end addCommandHandler ("updatedb", updatedb) function onjoindb () local sourcename = getClientName ( source ) player = executeSQLSelect ( "ppplayers", "player", "player = '" .. sourcename .. "'" ) if ( player == false ) then executeSQLInsert ( "ppplayers", "'600', '100', '0', 'Civillian', '0', '110', '" .. sourcename .. "'" ) outputChatBox ( "This is your first time here! Welcome " .. sourcename .. "!", source ) else local money = executeSQLSelect ( "ppplayers", "money", "player = '" .. sourcename .. "'" ) setPlayerMoney( source, money[1][1] ) -- local wanted = executeSQLSelect ( "ppplayers", "wanted", "player = '" .. sourcename .. "'" ) setPlayerWantedLevel ( source, wanted[1][1] ) -- local job = executeSQLSelect ( "ppplayers", "job", "player = '" .. sourcename .. "'" ) setPlayerTeam( source, getTeamFromName( job[1][1] ) ) -- local skin = executeSQLSelect ( "ppplayers", "skin", "player = '" .. sourcename .. "'" ) setPlayerSkin ( source, skin[1][1] ) outputChatBox("Welcome back " .. sourcename .. " to the " .. job[1][1] .. " team... You have $" .. money[1][1], source) end end addEventHandler ( "onPlayerJoin", getRootElement(), onjoindb ) function onquitdb () local sourcename = getClientName ( source ) getmoney = getPlayerMoney ( source ) getplayerTeam = getPlayerTeam ( source ) wanted = getPlayerWantedLevel( source ) skin = getPlayerSkin ( source ) playerTeam = getTeamName ( getplayerTeam ) executeSQLUpdate ( "ppplayers", "money = '" .. getmoney .. "', health = '50', armour = '100', job = '" .. playerTeam .. "', wanted = '" .. wanted .. "', skin = '" .. skin .. "', player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerQuit", getRootElement(), onquitdb ) I have not tested it but it should work edit: i wont do weapons quite yett Link to comment
Jammie Posted July 14, 2009 Share Posted July 14, 2009 hi.. i have a question about this, how that script how can you make that? i have copy the text in a text file and make it .lua and i have make a meta.xml. but do you need a database? and can u explain me how i make this is steps? because i dont know how to work with a database. please explain! i need it really hard. Thanks! Hawk Link to comment
Taalasmaa Posted July 15, 2009 Author Share Posted July 15, 2009 function createdb () executeSQLCreateTable ( "ppplayers", "money INTEGER, health INTEGER, armour INTEGER, job TEXT, wanted INTEGER, skin INTEGER,player TEXT" ) end addCommandHandler ("dbadd", createdb ) function updatedb ( sourcePlayer, theTeam ) sourcename = getClientName ( 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'", "skin = '110'", "player = '" .. sourcename .. "'" ) outputChatBox ("Update finished", sourcePlayer) end end addCommandHandler ("updatedb", updatedb) function onjoindb () local sourcename = getClientName ( source ) player = executeSQLSelect ( "ppplayers", "player", "player = '" .. sourcename .. "'" ) if ( player == false ) then executeSQLInsert ( "ppplayers", "'600', '100', '0', 'Civillian', '0', '110', '" .. sourcename .. "'" ) outputChatBox ( "This is your first time here! Welcome " .. sourcename .. "!", source ) else local money = executeSQLSelect ( "ppplayers", "money", "player = '" .. sourcename .. "'" ) setPlayerMoney( source, money[1][1] ) -- local wanted = executeSQLSelect ( "ppplayers", "wanted", "player = '" .. sourcename .. "'" ) setPlayerWantedLevel ( source, wanted[1][1] ) -- local job = executeSQLSelect ( "ppplayers", "job", "player = '" .. sourcename .. "'" ) setPlayerTeam( source, getTeamFromName( job[1][1] ) ) -- local skin = executeSQLSelect ( "ppplayers", "skin", "player = '" .. sourcename .. "'" ) setPlayerSkin ( source, skin[1][1] ) outputChatBox("Welcome back " .. sourcename .. " to the " .. job[1][1] .. " team... You have $" .. money[1][1], source) end end addEventHandler ( "onPlayerJoin", getRootElement(), onjoindb ) function onquitdb () local sourcename = getClientName ( source ) getmoney = getPlayerMoney ( source ) getplayerTeam = getPlayerTeam ( source ) wanted = getPlayerWantedLevel( source ) skin = getPlayerSkin ( source ) playerTeam = getTeamName ( getplayerTeam ) executeSQLUpdate ( "ppplayers", "money = '" .. getmoney .. "', health = '50', armour = '100', job = '" .. playerTeam .. "', wanted = '" .. wanted .. "', skin = '" .. skin .. "', player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerQuit", getRootElement(), onquitdb ) I have not tested it but it should work edit: i wont do weapons quite yett Omg! It crashed all accounts and It didn't even work! Hmm... It didn't work at all No warnings, but no work.. Link to comment
xArgonx Posted July 15, 2009 Share Posted July 15, 2009 i have the same problem... not errors but these things are not saved... it is a server side script? am i right?? must i do somthing with SQLite Browser Link to comment
knash94 Posted July 15, 2009 Share Posted July 15, 2009 Well ive updated it quite alot you will need other scripts now that aint being released and dont say "OMG".. Ive released this script so dont complain... If there is a problem i guess you better have a look at dev wiki. 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