Troubles with tables

-bump-

Shit thread, you don’t even say what you want your code to do, nor provide any insight into what is “not working”.

Your loop is somewhat problematic - if the first group of doors doesn’t contain the door you are buying, it will eject you every time. It’d be better to do something like:


function P.Buy( pl, ent )
	local k, v, found
	
	for k, v in pairs( Property ) do
		if table.HasValue( v.doors, ent:EntIndex( ) ) then
			found = v
			
			pl:AddMoney( -v.cost )
			
			for k, v in pairs( v.doors ) do
				ents.GetByIndex( v ):Own( pl )
			end
		end
	end
	
	if found then
		GAMEMODE:Notify( pl, 0, 8, "You've bought " .. found.name .. " for " .. found.cost .. "$" )
	else
		GAMEMODE:Notify( pl, 0, 8, "Door (" .. ent:EntIndex( ) .. ") is not in the schema!" )
	end
end

But as EvacX said, we’re going to need to know what the problem is in more detail or if there are any errors.

I found the main problem:

[LUA]
else
GAMEMODE:Notify( ply, 0, 8, “Door (”…ent:EntIndex( )…") is not in the schema!" )
return
end
[/LUA]

Here, if i remove this code work fine