Jump to content

Problem regarding table


Recommended Posts

This is the code:

  
  
local tempDat =  
{ 
    "hasAccount", 
    "loggedIn" 
} 
  
function PlayerSave(player) 
  
    for k, v in pairs(getAllElementData(player)) do 
     
     
        for z, x in pairs(impDat) do 
         
         
            if k ~= x then 
                 
                print(tostring(k) .." " .. tostring(v)) 
                dbExec(db, "UPDATE `account` SET `??` = ? WHERE `username` = ?", k, v, getPlayerName(player)) 
                 
            end 
         
        end 
     
    end 
  
end 
  

What I want to do is to ignore the values as keys in tempDat when updating the database. But the problem is that it still includes those values. What should be done in order to fix it? Is there another way to solve the problem?

Link to comment

Here is an example:

local tempData = 
{ 
    'hasAccount', 
    'loggedIn'; 
} 
  
function PlayerSave( player, k ) 
    for i = k, #getAllElementData( player ) do 
        for z, x in pairs( impData ) do 
            if( i == x ) then 
                PlayerSave( player, i + 1 ); 
                return; 
            end 
            outputChatBox( tostring( i ) .. ' - ' .. tostring( getAllElementData( player )[i] ) ); 
            dbExec( db, 'UPDATE `account` SET `??` = ? WHERE `username` = ?', k, v, getPlayerName( player ) ); 
        end 
    end 
end 

Not tested.

It should work that way:

PlayerSave( myPlayerElem, 1 ); 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...