Dazee Posted July 6, 2014 Share Posted July 6, 2014 I was getting an idea of creating an iron miner job for my local server but I realised how am I going to store the iron in the database or in account data I really have no idea could someone explain me how to create an custom item (element) like getPlayerMoney but for iron so I can call it back to display the amount. Link to comment
DiSaMe Posted July 6, 2014 Share Posted July 6, 2014 Um... Using variables, tables, element data or whatever other stuff you can find for general purpose data storage, probably? Link to comment
Anubhav Posted July 6, 2014 Share Posted July 6, 2014 SQL? local ironMined = {} local con = dbConnect("sqlite","database.db") function createTables() dbExec(con,"CREATE TABLE IF NOT EXISTS ironMined(accName,ironMined)") end function doIronMine() ....After finishing iron mining..... local iron = howMuchIronYouMined? local player = getPlayerAccount( source ) dbExec(con,"INSERT INTRO ironMined accName=? ironMined", player, iron) end function createSavedData(prevAccount,currectAccount,autologin) local query = dbQuery(con,"SELECT * FROM con WHERE accName=?",currentAccount) local poll = dbPoll(query,-1) if not poll then return end if poll and query then local answer = poll[1] setElementData( source, "jobs.ironMined", tostring(answer)) end end addEventHandler("onPlayerLogin", root, createSavedData) 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