Forum

> > CS2D > Scripts > Error/Wrong Script, h e l p me
Forums overviewCS2D overview Scripts overviewLog in to reply

English Error/Wrong Script, h e l p me

5 replies
To the start Previous 1 Next To the start

old Error/Wrong Script, h e l p me

RulesFollower
BANNED Off Offline

Quote
what is the error with this ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
nkkk = {}

addhook("serveraction","menu")
function menu(id,action)
if action == 1 then
nkkk[id] = "Enabled"
msg2(id,"ENABLED SUCCESSFUL")
end
end
addhook("second","second")
function second(id)
if nkkk[id] == "Enabled" then
parse("spawnprojectile "..id.." 51 "..player(id,"x").." "..player(id,"y").." 1 1")
end
end
addhook("join","join")
function join(id)
nkkk[id] = "Disabled"
end

why its won't work ?
i think addhook("second"... have a error right ?
can some one fix it 2 me ?

old Re: Error/Wrong Script, h e l p me

Hajt
User Off Offline

Quote
1. line 4, should be
nkkk[id] = "Enabled"


2. Did you initialize an array at the start of script?
1
2
3
4
nkkk = {}
for i=1,32 do
	nkkk[i] = "Disabled"
end

3. Hook cs2d lua hook second don't have parameters

old Re: Error/Wrong Script, h e l p me

Hajt
User Off Offline

Quote
Read what I wrote, hook cs2d lua hook second don't have parameters. You can't get id from nowhere. Try to use it:
1
2
3
4
5
6
7
8
9
10
11
addhook("second","second")
function second()
	local playerlist = player(0,"tableliving")
	for _,id in pairs(playerlist) do
		if nkkk[id] == "Enabled" then
			local x = player(id,"x")
			local y = player(id,"y")
			parse("spawnprojectile "..id.." 51 "..x.." "..y.." 1 1")
		end
	end
end

old Re: Error/Wrong Script, h e l p me

Yates
Reviewer Off Offline

Quote
@user RulesFollower: Let's hope Hajt didn't see your arrogant edit

cs2d lua hook minute, cs2d lua hook second & cs2d lua hook ms1000 all do not have any parameters.

You can create your own loop within one of the above hooks using a simple for:

1
2
3
for _, id in pairs(player(0, "table")) do
	print(id)
end

You may need to change the player parameters to something more specific. But the table option should always do the trick.

Edit: Aaaand I got ninja'd..
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview