Forum

> > CS2D > Scripts > Incorrect code message
Forums overviewCS2D overview Scripts overviewLog in to reply

English Incorrect code message

23 replies
Page
To the start Previous 1 2 Next To the start

old Re: Incorrect code message

phalenkO
User Off Offline

Quote
@user Avo: i do not have enough english to tell the situation, but i do not look at the translator. im serious and i do not use it a lot because there are too many mistakes in translation from turkish to english, just looking at the words i do not know. But now i look

old Re: Incorrect code message

phalenkO
User Off Offline

Quote
@user Gaios: even if i writee normal text in this code i get an error message, can you find the error?

1
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

old Re: Incorrect code message

Rainoth
Moderator Off Offline

Quote
Start tabbing your code and you'll find mistakes.
1
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

old Re: Incorrect code message

Bowlinghead
User Off Offline

Quote
Always TAB your code!!

1
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

old Re: Incorrect code message

phalenkO
User Off Offline

Quote
@user Bowlinghead: how is it going to be? will this happen? i probably misunderstood
1
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

old Re: Incorrect code message

LoaderFRA
User Off Offline

Quote
Return 1, it's not before the end ?

1
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

old Re: Incorrect code message

Quattro
GAME BANNED Off Offline

Quote
Could someone help me fix my code? it no works plz help :(((
1
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

old Re: Incorrect code message

Cebra
User Off Offline

Quote
1
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

@user 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

@user 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

old Re: Incorrect code message

Masea
Super User Off Offline

Quote
user 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
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

old Re: Incorrect code message

Cebra
User Off Offline

Quote
@user Masea: yes, you are right, my fault

@user phalenkO:
based on this code:
Spoiler >


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
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview