[CODE]
function DB.StoreMoney(ply, amount)
if not ValidEntity(ply) then return end
if amount < 0 then return end
ply.MoneyInBackPack = amount
ply:SetNWInt("money", math.floor(amount))
end
function DB.StoreMoneyInBank(ply, amount)
if not ValidEntity(ply) then return end
if amount < 0 then return end
local steamID = ply:SteamID()
local r = sql.QueryValue("SELECT amount FROM darkrp_wallets WHERE steam = " .. sql.SQLStr(steamID) .. ";")
if r then
sql.Query("UPDATE darkrp_wallets SET amount = " .. math.floor(amount) .. " WHERE steam = " .. sql.SQLStr(steamID) .. ";")
else
sql.Query("INSERT INTO darkrp_wallets VALUES(" .. sql.SQLStr(steamID) .. ", " .. math.floor(amount) .. ");")
end
ply:SetNWInt("BankMoney", math.floor(amount))
end
function DB.RetrieveMoneyFromBank(ply)
if !ply:IsPlayer() then
return 0
end
local steamID = ply:SteamID()
local startingAmount = 500
local r = sql.QueryValue("SELECT amount FROM darkrp_wallets WHERE steam = " .. sql.SQLStr(ply:SteamID()) .. ";")
if r then
ply:SetNWInt("BankMoney", math.floor(r))
return tonumber(r)
else
-- No record yet, setting starting cash to 500
DB.StoreMoneyInBank(ply, startingAmount)
return startingAmount
end
end
function DropMoney(ply, args)
if args == "" then return "" end
if not tonumber(args) then
return ""
end
local amount = math.floor(tonumber(args))
if amount <= 0 then
return ""
end
if not ply:CanAfford(amount) then
Notify(ply, 1, 4, "Can not afford this!")
return ""
end
ply:AddMoney(-amount)
local trace = {}
trace.start = ply:EyePos()
trace.endpos = trace.start + ply:GetAimVector() * 85
trace.filter = ply
local tr = util.TraceLine(trace)
local moneybag = ents.Create("prop_physics")
moneybag:SetModel("models/props/cs_assault/money.mdl")
moneybag:SetNWString("Owner", "Shared")
moneybag:SetPos(tr.HitPos)
moneybag.nodupe = true
moneybag:Spawn()
moneybag:GetTable().MoneyBag = true
moneybag:GetTable().Amount = amount
return ""
end
local meta = FindMetaTable("Player")
function meta:AddMoneyToBank(amount)
DB.StoreMoneyInBank(self, DB.RetrieveMoneyFromBank(self) + math.floor(amount))
end
function meta:GetMoneyOfBank()
if IsValid(self) then
return DB.RetrieveMoneyFromBank(self)
else
return 0
end
end
[/CODE]
So, My problem is that, with the newest DarkRP today, via svn, somewhere in this script is causing rp_dropmoneyondeath to not work probably. Let me explain. This script is part of a bank version of DarkRP that was edited by Lilezek. This edited version of DarkRP is outdated. So i wanted to just take the bank class all together and "move" it to the newer version of DarkRP. I knew there were going to be some problems from the start, but so far i can only find one. With this script on the server, when you die it will drop all your money and bring you down to 0 dollars. When you have any change in your money, however, say like pay day, your money will will go back to what it was, before you dropped all your money, and will add your payday on. So if i died and lost 50k, and now have 0, when pay day comes, i will get my 50k back and the 45 dollars from my salary. Also, the money you dropped when you died, is still on the ground and you are able to pick it up to double your money. I have narrowed it down to this script that is causing it, but i'm not very good with lua, so i have no idea what is causing it inside the script. It would be really cool if someone could help me out.
EDIT: I have found out it has something to do with sql. I have no idea what to do now, if anyone can help, please do.
Sorry, you need to Log In to post a reply to this thread.