edited 2×, last 02.08.18 01:27:01 pm
Forum
CS2D Scripts Incorrect code messageIncorrect code message
23 replies1
local wrong = 'message'
edited 1×, last 01.08.18 08:58:00 pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
admin = {142925} addhook("say","kck") function kck(id,txt) for _, usgn in ipairs(admin) do if txt:sub(1,5) == "!kick" then kid = txt:sub(6) parse("kick "..kid) msg("kicked!!!") else end msg("code is wrong!") return 1 end end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
admin = {142925} addhook("say","kck") function kck(id,txt) 	for _, usgn in ipairs(admin) do 		if txt:sub(1,5) == "!kick" then 			kid = txt:sub(6) 			parse("kick "..kid) -- results in "kick <id>" (one space too many, provided you write '!kick <id>') 			msg("kicked!!!") -- Global message that the kicked player won't see because he'd be kicked 		else -- what is this? 		end -- did you misplace this 'end' ? 		msg("code is wrong!") 		return 1 	end end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("say","kck") function kck(id,txt) 	for _, usgn in ipairs(admin) do 		if txt:sub(1,5) == "!kick" then 			kid = txt:sub(6) 			parse("kick "..kid) 			msg("kicked!!!") 		else 			-- nothing... 		end 		msg("code is wrong!") -- this is written always cuz its not in the if 	return 1 	end end
So you gotta replace line 11 and 12 in your code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
admin = {142925} addhook("say","kck") function kck(id,txt) for _, usgn in ipairs(admin) do if txt:sub(1,5) == "!kick" then kid = txt:sub(6) parse("kick "..kid) msg("kicked!!!") else -- nothing... end return 1 msg("code is wrong!") end end
Bowlinghead has written
So you gotta replace line 11 and 12 in your code
In your code that you posted, not on mine :3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
admin = {142925} addhook("say","kck") function kck(id,txt) 	for _, usgn in ipairs(admin) do 		if txt:sub(1,5) == "!kick" then 			kid = txt:sub(6) 			parse("kick "..kid) 			msg("kicked!!!") 		else 			msg("code is wrong!") 			return 1 			end 		end 	end end
edited 2×, last 04.08.18 01:39:54 pm
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
d = 50 for i = 1, d if player(1,'exists')then if player(1,'team')==1 then if player(1,'health')>0 then if player(1,'health')<50 then msg2(1,'this is a nice piece of new generation style code') end var = 'kids are stupid' end parse('restart') end msg(var) end return end end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
d = 50 for i = 1, d do 	if player(1,'exists') then 		if player(1,'team')==1 then 			if player(1,'health')>0 then 				if player(1,'health')<50 then 					msg2(1,'this is a nice piece of new generation style code') 				end 			var = 'kids are stupid' 			end 		parse('restart') 		end 	msg(var) 	end return end
@ Quattro:
you missed the do after the for-statement (line 2)
this code will throw an error message, if player 1 is dead and it is executed, because the variable var is unknown.
But why do you use a for-Loop, in this case it is pointless.
please tab your code
@ phalenkO:
you get the error-message because your message wasn't "!kick <id>"
remove the else-statement to avoid this
edited 2×, last 04.08.18 06:44:40 pm
Cebra has written
please tab your code
You either don't know how to tab.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
d = 50 for i = 1, d do 	if player(1,'exists') then 		if player(1,'team')==1 then 			if player(1,'health')>0 then 				if player(1,'health')<50 then 					msg2(1,'this is a nice piece of new generation style code') 				end 				var = 'kids are stupid' 			end 			parse('restart') 		end 		msg(var) 	end 	return end
@ phalenkO:
based on this code:
if you write "hello" as a message,
the if-statement in line 4 returns false so that the else-statement is executed.
btw:
The return 1 is executed every time, that's why on your server no message are shown
and every body can kick players, because you don't test the identity of the player