Miika Posted April 10, 2016 Share Posted April 10, 2016 Hi, I got this type of error in my garage saver script: ERROR: garagesystem\server.lua:6: attempt to call field 'insert' (a nil value) Part of my code: local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} for i=1, #handlingtable do local dvalue = getVehicleHandling(vehicle)[handlingtable[i]] table.insert(handlingsTable, dvalue) end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) Table: handlingtable = { "mass", "turnMass", "dragCoeff", "centerOfMass", "percentSubmerged", "tractionMultiplier", "tractionLoss", "tractionBias", "numberOfGears", "maxVelocity", "engineAcceleration", "engineInertia", "driveType", "engineType", "brakeDeceleration", "brakeBias", "ABS", "steeringLock", "suspensionForceLevel", "suspensionDamping", "suspensionHighSpeedDamping", "suspensionUpperLimit", "suspensionLowerLimit", "suspensionFrontRearBias", "suspensionAntiDiveMultiplier", "seatOffsetDistance", "collisionDamageMultiplier", "monetary", "modelFlags", "handlingFlags", "headLight", "tailLight", "animGroup" } Link to comment
GTX Posted April 10, 2016 Share Posted April 10, 2016 Weird. Maybe you're overriding table function? Try using handlingsTable[#handlingsTable+1] = dvalue Link to comment
Miika Posted April 10, 2016 Author Share Posted April 10, 2016 Weird. Maybe you're overriding table function?Try using handlingsTable[#handlingsTable+1] = dvalue Same error. Link to comment
Walid Posted April 10, 2016 Share Posted April 10, 2016 it's handlingsTable not handlingtable. if it doesn't work try to use sth like this if ( not handlingsTable[vehicle] ) then handlingsTable[vehicle] = {} end handlingsTable[vehicle] = {--[[ put your value here]]} Link to comment
GTX Posted April 10, 2016 Share Posted April 10, 2016 It's not good to put elements into XML file. handlingtable must be in same script as your 'for' loop. local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} handlingtable = { "mass", "turnMass", "dragCoeff", "centerOfMass", "percentSubmerged", "tractionMultiplier", "tractionLoss", "tractionBias", "numberOfGears", "maxVelocity", "engineAcceleration", "engineInertia", "driveType", "engineType", "brakeDeceleration", "brakeBias", "ABS", "steeringLock", "suspensionForceLevel", "suspensionDamping", "suspensionHighSpeedDamping", "suspensionUpperLimit", "suspensionLowerLimit", "suspensionFrontRearBias", "suspensionAntiDiveMultiplier", "seatOffsetDistance", "collisionDamageMultiplier", "monetary", "modelFlags", "handlingFlags", "headLight", "tailLight", "animGroup" } for i=1, #handlingtable do local dvalue = getVehicleHandling(vehicle)[handlingtable[i]] table.insert(handlingsTable, dvalue) end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) And hitElement should be defined. And datanode also. Link to comment
Miika Posted April 10, 2016 Author Share Posted April 10, 2016 it's handlingsTable not handlingtable.if it doesn't work try to use sth like this if ( not handlingsTable[vehicle] ) then handlingsTable[vehicle] = {} end handlingsTable[vehicle] = {--[[ put your value here]]} Still not working. Link to comment
Anubhav Posted April 10, 2016 Share Posted April 10, 2016 local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} for i,v in ipairs( handlingtable ) do local dvalue = getVehicleHandling(vehicle)[v] table.insert(handlingsTable, dvalue) end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) Link to comment
Miika Posted April 10, 2016 Author Share Posted April 10, 2016 local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} for i,v in ipairs( handlingtable ) do local dvalue = getVehicleHandling(vehicle)[v] table.insert(handlingsTable, dvalue) end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) Same error Link to comment
Miika Posted April 10, 2016 Author Share Posted April 10, 2016 Is this bug? Can't insert any values to any type of tables in serverside? I tested in clientside and insert worked perfectly. Link to comment
Miika Posted April 10, 2016 Author Share Posted April 10, 2016 (edited) --- Problem solved, code removed to make sure that somebody don't steal my script. --- Edited April 10, 2016 by Guest Link to comment
Anubhav Posted April 10, 2016 Share Posted April 10, 2016 local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} for i,v in ipairs( handlingtable ) do local dvalue = getVehicleHandling(vehicle)[v] handlingsTable[#handlingsTable+1] = dvalue end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) Link to comment
Miika Posted April 10, 2016 Author Share Posted April 10, 2016 local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} for i,v in ipairs( handlingtable ) do local dvalue = getVehicleHandling(vehicle)[v] handlingsTable[#handlingsTable+1] = dvalue end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) Oh, this worked perfectly! Thank you and @GTX (used your method wrong first) Link to comment
Anubhav Posted April 10, 2016 Share Posted April 10, 2016 local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} for i,v in ipairs( handlingtable ) do local dvalue = getVehicleHandling(vehicle)[v] handlingsTable[#handlingsTable+1] = dvalue end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) Oh, this worked perfectly! Thank you and @GTX (used your method wrong first) Uhmm welcome Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now