[lua]
local Player = FindMetaTable("Player")
function Player:expGetData()
self.expXP = self:GetPData("expXP")
self.expLevel = self:GetPData("expLevel")
self.expPoints = self:GetPData("expPoints")
self.expPerks = self:GetPData("expPerks")
if !self.expXP then
self.expXP = 0
else
self.expXP = tonumber(self.expXP)
end
if !self.expLevel then
self.expLevel = 1
else
self.expLevel = tonumber(self.expLevel)
end
if !self.expPoints then
self.expPoints = 0
else
self.expPoints = tonumber(self.expPoints)
end
if !self.expPerks then
self.expPerks = {}
else
self.expPerks = util.TableToJSON(self.expPerks)
end
print(self.expXP, self.expLevel, self.expPoints)
self:SetNWInt("expXP", self.expXP)
self:SetNWInt("expLevel", self.expLevel)
self:SetNWInt("expPoints", self.expPoints)
end
[/lua]
[code]
] rcon lua_run Clark:expGetData()
autokick is disabled for Clark
> Clark : expGetData ( )...
nil nil nil
nil nil nil
[/code]
PLAYER:GetPData() will return nil if you haven't passed a 2nd parameter (the default value) and if the PData has never been set on that player.
If a call to tonumber() is unsuccessful, nil will be returned (including when nil is passed to tonumber)
This appears strange, but suggests that GetPData is returning a value that evaluates to true but can not be converted to a number. Try printing the direct output of the GetPData calls.
[QUOTE=Willox;42770539]PLAYER:GetPData() will return nil if you haven't passed a 2nd parameter (the default value) and if the PData has never been set on that player.
If a call to tonumber() is unsuccessful, nil will be returned (including when nil is passed to tonumber)
This appears strange, but suggests that GetPData is returning a value that evaluated to true but can not be converted to a number. Try printing the direct output of the GetPData calls.[/QUOTE]
Interesting I was originally passing a 2nd argument but never got return values that weren't nil.
[editline]5th November 2013[/editline]
Deleted sv.db started acting normal. Could possibly be that the value inserted was nil as such it was reading it as nil. Or some other messed up bullshit. Anyways I believe this to be solved but probably a issue someone else has experienced.
Sorry, you need to Log In to post a reply to this thread.