isa_Khamdan Posted January 25, 2014 Posted January 25, 2014 I have error in line 13 saying that expected table got nil while I do have a table named Vehicle1 and I checked it using outputChatBox so can anyone help me to solve it? addEventHandler("onPlayerChat",root, function (msg,type) if ( type == 0 and msg == "test" ) then if ( isStarted == true ) and ( readyPlayers < maxPlayers ) and not isPedInVehicle(source) and not getElementData(source, "inMissionD" ) == true then cancelEvent() readyPlayers = ( readyPlayers + 1 ) VarName = ("vehicle"..readyPlayers) setElementData(source, "inMissionD", true) VarX = ("Vehicles"..vMap) outputChatBox(VarX) local x, y, z, rx, ry, rz = unpack ( VarX [ readyPlayers ] ) VarName = createVehicle ( vID, x, y, z, rx, ry, rz ) table.insert(DVeh,VarName) warpPedIntoVehicle ( source, VarName) setElementData( source, "isBlocked", true, true) toStart() return end end end )
Castillo Posted January 25, 2014 Posted January 25, 2014 VarX = ("Vehicles"..vMap) That's obviously not a table.
isa_Khamdan Posted January 25, 2014 Author Posted January 25, 2014 that's the table Vehicles1 = { [1]={ 2902.6318359375, -2043.0684814453, 3.208420753479, 0, 0, 270 }, [2]={ 2902.5588378906, -2046.3167724609, 3.208420753479, 0, 0, 270 }, [3]={ 2902.4799804688, -2049.8156738281, 3.208420753479, 0, 0, 270 }, [4]={ 2902.4121093755, -2052.8154296875, 3.208420753479, 0, 0, 270 }, [5]={ 2902.3391113281, -2056.0654296875, 3.208420753479, 0, 0, 270 } }
Castillo Posted January 25, 2014 Posted January 25, 2014 What you are trying to do is not going to work, make your table this format: vehicles = { [ 1 ] = { [1]={ 2902.6318359375, -2043.0684814453, 3.208420753479, 0, 0, 270 }, [2]={ 2902.5588378906, -2046.3167724609, 3.208420753479, 0, 0, 270 }, [3]={ 2902.4799804688, -2049.8156738281, 3.208420753479, 0, 0, 270 }, [4]={ 2902.4121093755, -2052.8154296875, 3.208420753479, 0, 0, 270 }, [5]={ 2902.3391113281, -2056.0654296875, 3.208420753479, 0, 0, 270 } } } Then change this: VarX = ("Vehicles"..vMap) Into: VarX = vehicles [ vMap ]
isa_Khamdan Posted January 25, 2014 Author Posted January 25, 2014 and how can I unpack the numbers inside that table?
Castillo Posted January 25, 2014 Posted January 25, 2014 You are already doing it here? local x, y, z, rx, ry, rz = unpack ( VarX [ readyPlayers ] )
isa_Khamdan Posted January 25, 2014 Author Posted January 25, 2014 Thanks a lot I did it and I forget to edit my post
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