• Adding an DarkRP VAR
    9 replies, posted
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? //Thanks Note: im sorry about my english
-bump-
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
[QUOTE=Tobba;25837288]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[/QUOTE] im using litesql, it stores in the sv.db and it only resets when you spawn, yes this is in the DARKRP
[QUOTE=Drew P. Richard;25835694]Can we please see the code you are using?[/QUOTE]
[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) .. ";") else DB.Query("INSERT INTO darkrp_banks VALUES(" .. sql.SQLStr(steamID) .. ", " .. math.floor(amount) .. ");") end end) end 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)) else DB.StoreBank(ply, 25) end end) end [/LUA]
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.
[QUOTE=Drew P. Richard;25874243]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.[/QUOTE] how do i use it then?
Sorry, you need to Log In to post a reply to this thread.