Miika Posted April 10, 2016 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" } Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
GTX Posted April 10, 2016 Posted April 10, 2016 Weird. Maybe you're overriding table function? Try using handlingsTable[#handlingsTable+1] = dvalue Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Miika Posted April 10, 2016 Author Posted April 10, 2016 Weird. Maybe you're overriding table function?Try using handlingsTable[#handlingsTable+1] = dvalue Same error. Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Walid Posted April 10, 2016 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]]} Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
GTX Posted April 10, 2016 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. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Miika Posted April 10, 2016 Author 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. Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Anubhav Posted April 10, 2016 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)) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Miika Posted April 10, 2016 Author 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 Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Miika Posted April 10, 2016 Author 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. Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Miika Posted April 10, 2016 Author 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 Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Anubhav Posted April 10, 2016 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)) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Miika Posted April 10, 2016 Author 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) Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Anubhav Posted April 10, 2016 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 See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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