PData for entity?

Is there a function like PData but for an entity. What I mean is I am going to make a entity permament to the map. I could just make a text file storing the positions but i need to save 3 tables or data too. Is there an effective way to do this, There will be like 50 of these entities and they will all have different values in the table. Thanks

Store it in the text file? There’s no way to set PData for an entity that isn’t a player.

function SaveEnts()
    local _table = {};

    for i, v in pairs( ents.FindByClass( "something" ) )  do
        _table[ i ] = util.TableToJSON( { pos = Vector( 0, 0, 0 }, angle = Angle( 0, 0, 0 ), uniquevariable1 = v:Health(), uniquevariable2 = "bla" } ); 

    file.Write( "savedentities.txt", _table );

function SpawnEnts()
    local _table = util.JSONToTable( file.Read( "savedentities.txt", "DATA" ) );

    for i, v in pairs( _table ) do
        local _e = ents.Create( "something" );
        _e:SetPos( v[ "pos" ] );
        _e:SetAngles( v[ "angle" ] );
        _e:SetHealth( v[ "uniquevariable1" ] );
        _e.uniquevariable2 = v[ "uniquevariable2" ];


I Did not think of doing it that way >.> Thankyou very much. I thougt it would be a nightmare to read the data back from it but forgot about the JSONTotTable

With JSON does it save a table inside of a table? Thanks

util.TableToJSON does indeed store tables within tables. In the future, if you must use the SQL database to store information not related to a player, you can always just use the functions within the SQL library to store data. In fact, that’s all that PData does; it’s just a simplified way of saving player-related data using SQL. Of course, this will be a lot easier if you have knowledge of SQL syntax beforehand.