Jump to content

Help about storing stuff


Dazee

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...