–SOLVED–
I’m not going to go through your code but i’ll give you a concept on how my usually look like
This is just a “concept”
hook.Add( "PlayerDeath", "Killing Reward", function( victim, inflictor, attacker )
if ( attacker:IsPlayer() && attacker:Alive() ) then
attacker:GetCurrentMoney() + 30
attacker:GetCurrentExp() + 30
else
-- Loses a certain amount of money and exp on death
victim:DeductMoney() - 30 -- or victim:GetCurrentMoney() - 30
victim:DeductExp() - 30 -- or victim:GetCurrentExp() - 30
end)
First off, you are typing local too many times Just use local once to declare the variable and then you can reference it without that.
function ply:ShortSteamID()
local id = self:SteamID()
local id = tostring(id) -- Remove the local in front of all of these below
local id = string.Replace(id, "STEAM_0:0:", "")
local id = string.Replace(id, "STEAM_0:1:", "")
return id
Now for your question, usually in gLua people have SetX and GetX functions that are opposites with X being whatever it does (except for SetHealth/Heath…). You have databaseGetValue and I found databaseSetValue in the code and it has 2 arguments. So your code should be something like this: (assuming I understand the code right)
local curXP = ply:databaseGetValue("xp")
local newXP = 10 + curXP
ply:databaseSetValue("xp", newXP)
No idea if that works, thats just how you would do it I figure
Ok, thanks that works for the code. I was a little confused on how to do this, because I mainly code java. But yah, I shouldn’t have put local either infront every time xD Thanks though.
Next time try to make your code more readable to yourself, so you can avoid having this problem again.
I thought it was something like that, but it was a little confusing cause I mainly code java. But thanks for the comment, ill try to make it more readable!