Adding an DarkRP VAR

hello, im adding a VAR to my darkrp and it works fine but it resets when you rejoin, i can that its saved when you DC from the server but when you respawn it goes back to the starting ammount, do you know what im doing wrong?


Note: im sorry about my english


Can we please see the code you are using?

DarkRP vars does not save

[editline]3rd November 2010[/editline]

You will have to write your own saving, take a look at data.lua if you want to use SQLite, otherwise you can use SetPData and GetPData

PData is the lazy way, mysql/sqlite is the good way

im using litesql, it stores in the sv.db and it only resets when you spawn, yes this is in the DARKRP

[LUA]DB.Query(“CREATE TABLE IF NOT EXISTS darkrp_banks(steam char(20) NOT NULL, amount INTEGER NOT NULL, PRIMARY KEY(steam));”)

function DB.StoreBank(ply, amount)
if not ValidEntity(ply) then return end
if amount < 0 then return end
ply:SetDarkRPVar(“bank”, math.floor(amount))

local steamID = ply:SteamID()
DB.QueryValue("SELECT amount FROM darkrp_banks WHERE steam = " .. sql.SQLStr(steamID) .. ";", function(r)
	if r then
		DB.Query("UPDATE darkrp_banks SET amount = " .. math.floor(amount) .. " WHERE steam = " .. sql.SQLStr(steamID) .. ";")
		DB.Query("INSERT INTO darkrp_banks VALUES(" .. sql.SQLStr(steamID) .. ", " .. math.floor(amount) .. ");")


function DB.RetrieveBank(ply)
if not ValidEntity(ply) then return 0 end
local steamID = ply:SteamID()

DB.QueryValue("SELECT amount FROM darkp_banks WHERE steam = " .. sql.SQLStr(ply:SteamID()) .. ";", function(r)
	if r then
		ply:SetDarkRPVar("bank", math.floor(r))
		DB.StoreBank(ply, 25)



is that nuff?

It would probably be better if you just used SetPData and GetPData, it’s basically the same thing as SQLLite, and it would probably be easier for you to understand.

how do i use it then?