Hello everyone,
I have a PData value I'm using to store some points for the player, but when the value gets added past 128 it goes back to 0.
Why is that happening?
As the wiki says (Player/SetPData) I wouldn't really recommend you using PData to store player data due to it using UniqueID and having the possibility of having two players data conflicting each other.
AS Geferon said. PData is not reliable anymore.
I copied and rewrote the PData system to use AccountID. Feel free to use.
if ( !sql.TableExists( "ndata" ) ) then
sql.Query( "CREATE TABLE IF NOT EXISTS ndata ( infoid TEXT NOT NULL PRIMARY KEY, value TEXT );" )
end
local meta = FindMetaTable("Player")
function meta:GetNData( name, default )
name = Format( "%s[%s]", self:AccountID(), name )
local val = sql.QueryValue( "SELECT value FROM ndata WHERE infoid = " .. SQLStr( name ) .. " LIMIT 1" )
if ( val == nil ) then return default end
return val
end
function meta:SetNData( name, value )
name = Format( "%s[%s]", self:AccountID(), name )
sql.Query( "REPLACE INTO ndata ( infoid, value ) VALUES ( " .. SQLStr( name ) .. ", " .. SQLStr( value ) .. " )" )
end
function meta:RemoveNData( name )
name = Format( "%s[%s]", self:AccountID(), name )
sql.Query( "DELETE FROM ndata WHERE infoid = " .. SQLStr( name ) )
end
Sorry, you need to Log In to post a reply to this thread.