Script to get position of all chairs

Can anyone make me a script that gives me the exact position of every chair (vehicle) on the map?
I still need this for that car plugin. I spawned the car’s model at vector( 0,0,0 ), so the position of the chairs would be instantly right.

I don’t know if this will work or not but its worth a try :slight_smile:

[lua]

function listallvehicles()
vehiclelist = {}
for k,v in pairs(ents.GetAll()) do
if v:IsVehicle() then do
vehiclelist[v] = v:GetPos
end
end
for k,v in pairs(vehiclelist) do
RunConsoleCommand(“say”, tostring(v))
end
end

concommand.Add(“listvehicles”,listallvehicles)

[/lua]

yeah, maybe remove the thing that makes everyone say the pos’s of all the vehicles otherwise massive spam, maybe print it to the console or something :smiley:

Doesn’t work, getting this error

:6: function arguments expected near ‘end’

Probably easy to fix, but I’m still a rookie in LUA

[editline]03:28PM[/editline]

[LUA]
function listallvehicles()
vehiclelist = {}
for k,v in pairs(ents.GetAll()) do
if v:IsVehicle() then do
vehiclelist[v] = v:GetPos()
end
end
for k,v in pairs(vehiclelist) do
RunConsoleCommand(“say”, tostring(v))
end
end

concommand.Add(“listvehicles”,listallvehicles)
end
[/LUA]

forgot the parentheses after v:GetPos() and one end

But still isn’t working. Don’t get any errors tho.

Remove the end after concommand.Add. and remove the do in line 4

Try this

[lua]
function listallvehicles()
vehiclelist = {}
for k,v in pairs(ents.GetAll()) do
if v:IsVehicle() then
vehiclelist[v] = v:GetPos()
end
end
for k,v in pairs(vehiclelist) do
RunConsoleCommand(“say”, tostring(v))
end
end

concommand.Add(“listvehicles”,listallvehicles)

[/lua]

@ Ningaglio it makes console say it, not everyone in the game.

The last one worked. Thanks to all who helped.