Forum

> > CS2D > General > New to LUA - My code wont start
Forums overviewCS2D overviewGeneral overviewLog in to reply

English New to LUA - My code wont start

5 replies
To the start Previous 1 Next To the start

old New to LUA - My code wont start

HappYxD
User Off Offline

Quote
Hey ho
This is my very first day with LUA.

I have made a code, but it don´t start!
I did put
1
dofile("sys/lua/Tutorial_Script.lua)
in the end of the server.lua (And my server starts with that file in CS2D)

This is the code that I made:
More >

NOTHING that is in that code do something in the server

What am i doing wrong?

Admin/mod comment

Please use The Lua Scripts/Questions/Help thread for Lua related questions. /Lee

old Re: New to LUA - My code wont start

Lee
Moderator Off Offline

Quote
Along with Nemesis' suggestion, apply the following edits:

Ln10:
1
msg(..played(id, "name").. " said something!")
Change to
1
msg(played(id, "name").. " said something!")

Repeat the above for Ln15:
1
msg(..played(id, "name").. " said something!")

Ln23
Lua doesn't allow for (...) do style, you need to ungroup the parameters:
1
for (i = 1, 32, 1) do
Change to
1
for i = 1, 32, 1 do

old Re: New to LUA - My code wont start

Starkkz
Moderator Off Offline

Quote
There's a problem at minute hook.
Isn't player(player,"name")..
it's player(i,"name")..
I prefer use the pairs of the player table.

1
2
3
4
5
6
addhook ("minute", "tutorialadvertise")
function tutorialadvertise()
	for _, id in pairs(player(0,"table")) do
		msg2(id, "Hello, "..player(id, "name")..", Enjoy this Awesome Server :P") 
	end
end

old Re: New to LUA - My code wont start

Starkkz
Moderator Off Offline

Quote
well, i tell you, never use player like value.
It was like a function.
You can get names, pings, positions, health, and more things with player function. If you use it like a value you will confuse the lua script. That will give you an error at console.
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview