Forum

> > CS2D > Scripts > Lua error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua error

5 replies
To the start Previous 1 Next To the start

old Lua error

Q-Q
User Off Offline

Quote
I learned this piece of code from a lua toturial:

1
2
3
4
5
6
7
8
9
addhook("minute","Test")
function test()
for(i=1,32,2)do
if (player(i,"exists"))then
msg2(i,"This is advertising")
end
end
end
end

But strangeley enough it gives me this error:
LUA ERROR: sys/lua/test.lua:3: '<name>' expected near '('

what is wrong?

old Re: Lua error

Starkkz
Moderator Off Offline

Quote
I think you added an extra "end", btw this is easier:

1
2
3
4
addhook("minute","Test")
function Test()
	msg("This is advertising")
end

Note: test is not the same as Test, there are difference of the capital letters.

old Re: Lua error

SilentDash
User Off Offline

Quote
try this
1
2
3
4
5
6
7
addhook("minute","test")
	function test()
		for(i=1,32,2)do
		if (player(i,"exists"))then
		msg2(i,"This is advertising")
	end
end

old Re: Lua error

Yates
Reviewer Off Offline

Quote
user palomino has written
Too many ends.

MOAR ENDS!

---

You only need 3 ends.
1
2
addhook("minute","Test")
function test()
Capital letter T and small letter t? Won't work.

Why are you checking if the player exists? And why the for i, .. stuff?

Wait, how did you make that "magic wizards" Lua? I fuckin' lol'd.

Edit: You guys posted faster than me
edited 2×, last 28.10.11 07:16:11 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview