Jump to content

bad argument #1 to 'ipairs' (table expected got string)


Xabache

Recommended Posts

The values account, car and vehicle function in earlier calls and are presumed to do so in the following code which receives only "bad argument #1 to 'ipairs' (table expected got string)"

From: function carSpawn ()

  
          local upgrade = getAccountData (account, "funmodev2-carupg") 
      if (upgrade) then 
          local upgrades = nil 
          local upgrades = {} 
          local upgrades = upgrade 
          for i,v in ipairs (upgrades) do 
            addVehicleUpgrade (vehicle, v) 
          end 
        end 

From: function carDestroy ()

setAccountData (account, "funmodev2-carupg", getVehicleUpgrades(car)) 

But no upgrades result on car spawn. ideas?

Link to comment
  • Moderators
setAccountData (account, "funmodev2-carupg", toJSON (getVehicleUpgrades(car))) 

  
local upgrades = getAccountData (account, "funmodev2-carupg") 
  
if upgrades then 
          for i,v in ipairs (fromJSON(upgrades)) do 
            addVehicleUpgrade (vehicle, v) 
          end 
end 

Use LUA tags, pls.

Link to comment
  • 1 month later...

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...