Forum

> > CS2D > Scripts > Incorrect code message
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Incorrect code message

23 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: Incorrect code message

phalenkO
User Off Offline

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

alt Re: Incorrect code message

phalenkO
User Off Offline

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

alt Re: Incorrect code message

Rainoth
Moderator Off Offline

Zitieren
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

alt Re: Incorrect code message

Bowlinghead
User Off Offline

Zitieren
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

alt Re: Incorrect code message

phalenkO
User Off Offline

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

alt Re: Incorrect code message

LoaderFRA
User Off Offline

Zitieren
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

alt Re: Incorrect code message

Quattro
GAME BANNED Off Offline

Zitieren
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

alt Re: Incorrect code message

Cebra
User Off Offline

Zitieren
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
2× editiert, zuletzt 04.08.18 18:44:40

alt Re: Incorrect code message

Masea
Super User Off Offline

Zitieren
user Cebra hat geschrieben
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

alt Re: Incorrect code message

Cebra
User Off Offline

Zitieren
@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
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht