I am trying to grab three fields from my doors table ( EntID, Name, Type ) and then sort them into lua tables depending on their type. Type 1 goes into the closed table, type 2 goes in the public table, and type 3 goes into the admin table. The only values I need in the table are EntID and Name. I am not very fond of tables so I have no Idea how I could use a for loop to lets say get EntID “2” and Name “Admin Door” out of the admin table and apply the name to the entity. I am terrible at explaining so bear with me.
Basic idea, Admin Door:
Type is 3, put EntID and Name in Admin table
Get entity by EntID and setnwstring of that entity to Name from admin table
I am trying to get this to work for multiple doors which can be one of three types.
local function SetTables()
local db, error = mysql.connect( “”, “”, “”, “” )
local DoorQuery = mysql.query( db, "SELECT * FROM doors" ) PrintTable( DoorQuery )
Here is the current loop I use for just grabbing EntID from a predefined table.
local function SetAdminDoors()
for k, v in pairs( AdminDoors ) do
if Entity( v ):IsValid() then
Entity( v ):SetNWInt( “Type”, 3 )
Entity( v ):Fire( “lock”, “”, 0 )
Entity( v ):SetNWInt( “Locked”, 1 )