for k, v in pairs

[lua]
for k, v in pairs
if v:GetTable()
[/lua]

can you explain me this

It goes through each element of the table specified in the first argument of pairs() function.

[lua]

function ENT:Touch(hitEnt)

if hitEnt:GetClass() == “energie” then

local Maxprinter = 0;
for k, v in pairs(ents.FindByClass('printer')) do
	if v:GetTable().Max == Player then
		Maxprinter = Maxprinter + 1;
	end
if Maxprinter >= 1 then
	Player:Notify('ERROR.');
	return false;
end
	Player:Notify('Working.');

end
[/lua]
This is my entity script and its not theking the limit

What is it supposed to do? At a guess I’d say it was an entity that allows the player it hits to get an extra money printer, but if it is it looks very wrong if it is.

The function to get the highest numerical keyvalue for a table is table.maxn.
If that’s supposed to be a value, how does it equal nothing? “Player” in that snippet would be undefined. Maybe you meant to put it in quotes?

[editline] aw shit[/editline]
Hm, it seems that Player is actually an entity you defined…
Is it clientside? You should be using LocalPlayer() if it is. If not, I have no idea.
Try to post more of the code or the dependencies of this code (variables, functions, whatever) it uses.

Its just a example i just need a limit script when 2 entitys hit
[lua]
function ENT:Touch(hitEnt)

if hitEnt:GetClass() == “energie” then

local Maxprinter = 0;
for k, v in pairs(ents.FindByClass('printer')) do
    if v:GetTable().Max == self.dt.owning_ent then
        Maxprinter = Maxprinter + 1;
    end
if Maxprinter >= 1 then

Notify(self.dt.owning_ent, 1, 4, “You have hit the maximum upgrade.”);
return false;
end
Notify(self.dt.owning_ent, 1, 4, “You have upgrade your moneyprinter.”);
end
[/lua]

addit self.dt.owning_ent

I can show you a simple use of it. Let’s say we have a table

[lua]
local HiTable = { – Let’s create the table and add some values
“Hi”, – This is the first value
“My”, – Second value
“Friend”, – Third value
“!”, – And number four
} – So we simply close the table.
[/lua]

What you can do now, is simply looping trough the text
[lua]
for _, v in pairs(HiTable) do – Now we’ll loop through the table, and get all the values
print(v…"
") – Then print them.
end – Now we end the loop
[/lua]

I’m sorry if I misspelled something, I’m just realy tired. Hopefully you understood what I ment (;