Forum
CS2D Scripts Lua Scripts/Questions/Help playa slaya has written
i think you need another 'end'
But where?
I'm confused...
New Rex has written
But where?
I'm confused...
I'm confused...
USE the fu**ing TABS!!! DC said, Im repeating that.
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
function bla 	if bla then 		if bla then 			if bla then 			end 		end 	end end
Understand what it means?!
Btw, you should learn it your self...
This tread isnt school or something like that!
edited 1×, last 12.09.09 05:15:08 pm
Blazzingxx has written
USE the fu**ing TABS!!! DC said, Im saying that.
Understand what it means?!
Btw, you should learn it your self...
This tread isnt school or something like that!
New Rex has written
But where?
I'm confused...
I'm confused...
USE the fu**ing TABS!!! DC said, Im saying that.
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
function bla 	if bla then 		if bla then 			if bla then 			end 		end 	end end
Understand what it means?!
Btw, you should learn it your self...
This tread isnt school or something like that!
I see. But do I need to remove the ut.sample? You don't need to scream...
just example
Fail. Just Goggling...
Quote
I don't know how to make tabs.
Fail. Just Goggling...
Fail. Just Goggling...
LOL
Blazzingxx has written
LOL
Quote
I don't know how to make tabs.
Fail. Just Goggling...
Fail. Just Goggling...
LOL
I was just triying to say I saw TKD's Lua tut.
___
I press Tab at all lines?
Do not quote images.
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
function initArray(m) local array = {} for i = 1, m do array[i]=0 end return array end sample.ut.timer=initArray(32) sample.ut.level=initArray(32) sample.ut.fblood=0
I'm confused even with tutorials. Shit...
Its should look like that:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end sample.ut.timer=initArray(32) sample.ut.level=initArray(32) sample.ut.fblood=0
I Need Cs2d Script!
Admin Script - Green Say!
Example:
I Say:
Fehuziom: Hi!
In script:
(Admin)Fehuziom: Hi! (In green)
P.S: Sry my english is bad
Blazzingxx has written
OMG, its useless even to help you...
Its should look like that:
Its should look like that:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end sample.ut.timer=initArray(32) sample.ut.level=initArray(32) sample.ut.fblood=0
I have it just like that. Still giving error.
You even havent learnt a bit.
I COPIED LAYOUT FROM UTSFX
I PUT REPLACED MY STUFF FOR THAT.
AND NOTHING.
TUTORIALS ARE FREAKING Shit.
Yeasp, didn't learn nothing.
I'm a noob that needs to die but needs to kill tooooooooooo.
New Rex has written
I have it just like that. Still giving error.
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end sample.ut.timer=initArray(32) sample.ut.level=initArray(32) sample.ut.fblood=0
I have it just like that. Still giving error.
The problem here is that you're using a namespace identifier technique without prior declaration of the namespace, try the following
use replace to replace "sample.ut." with just ""
so your code would look like
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end [b]timer=initArray(32) level=initArray(32) fblood=0[/b]
or create the namespace tables via
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
[b]sample={} sample.ut={}[/b] function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end sample.ut.timer=initArray(32) sample.ut.level=initArray(32) sample.ut.fblood=0
Also, let's not get too angry over here. Scripting is frustrating work, you just need to remind yourself to stay coolheaded and to just keep at it if no one's willing to help.
I think it's more organised now, but still giving same error...
So as I'm more peaceful now, I'll do all stuff in organised and good way.
Error Screenshot
http://img5.imageshack.us/img5/8281/luaerror1.jpg
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---------------------- -- Ultimate Female Sounds Script by Xt3ND3d -- -- Version 0.5 Alpha -- -- © 11.09.2009 Xt3ND3d Productions -- ----------------------- function initArray(m) local array = {} for i = 1, m do array[i]=0 end return array end timer=initArray(32) level=initArray(32) fblood=0 ----------------------- -- Killing sounds and messages -- ----------------------- addhook("kill","sample.ut.kill") function sample.ut.kill(killer,victim,weapon) if (os.clock()-sample.ut.timer[killer])>3 then 	sample.ut.level[killer]=0; end level=sample.ut.level[killer] level=level+1 sample.ut.level[killer]=level sample.ut.timer[killer]=os.clock() -- Humiliation (Killed with knife) if (weapon==50) then parse("sv_sound 'fun/f_humiliation.wav'"); msg (player(killer,"name").." humiliated "..player(victim,"name").."!") msg "You humiliated me..." else -- First kill. if (level==1) then -- Doesn't do nothing at his point. if (level==2) then -- Doesn't do anything either. This is unfinished version. elseif (level==3) then -- Megakill. parse("sv_sound 'fun/f_megakill.wav'") msg (player(killer,"name").." made a Megakill!") elseif (level==4) then -- Ultrakill. parse("sv_sound 'fun/f_ultrakill.wav'") msg (player(killer,"name").." made an ULTRAKILL.") elseif (level==5) then -- Monsterkill. parse("sv_sound 'fun/f_monsterkill.wav'") msg (player(killer,"name").." made a MONSTERKILL! W00t!") elseif (level==6) then -- Ludacriskill. parse("sv_sound 'fun/f_ludacrisskill.wav'") msg (player(killer,"name").." made a LUDACRISKILL!") elseif (level==7) then -- Holyshit. parse("sv_sound 'fun/f_holyshit.wav'") msg (player(killer,"name").." made a HOLYSHIT!") elseif (level==8) then -- Godlike. parse("sv_sound 'fun/f_godlike.wav'") msg (player(killer,"name").." is a GODLIKE!!!") elseif (level==9) then -- Wicked-Sick. parse("sv_sound 'fun/f_wickedsick.wav'") msg (player(killer,"name").." made a Wiiickeeed-Siiick!!") else parse("sv_sound 'fun/f_unstoppable.wav\'") msg (player(killer,"name").." is UNNNSTOPPABLE...! Made "..level.." kills!!!") 		end 	end end
Could someone fix it and send me it?
I actually have 'spaces' or tabs in start. It doesn't show here.
1. Tabs are for management of the code, Lua doesn't require you to tab but it's a good habit to develop.
2. Don't listen to those people who tell you that real programmers use Notepad, try the following link
http://luaforwindows.luaforge.net/index.html#Download
Which installs a great development environment for windows. Programmers are people who are mathematically oriented. Programmers are not people who like to waste hours using an outdated editor just so that they can be cool. (Although, sometimes notepad are easier to use, this however only depends on the scope of the project. I for example start with notepad and then migrate to SciTe only when I hit around 200+ lines)
So here's the basic problem to your code, you're missing just one 'end' statement somewhere in your code. The fix is relatively simple, but a bit of work is needed first.
This is the types of error to which indenting would have been of great help.
Now I understand that some people don't know where and when to indent so here's a small primer on indenting code.
In Lua, there are 2 types of statements (statements are instructions that lua follows), the first is a simple statement, they're usually the one line type of statements like x = 4*3
The other type of statement is a blocked statement. These are multilined instructions enclosed within a 'condition' or a 'group'
So for example, the following keywords in Lua defines the start of a block (they always end with the keyword 'end')
if, for, else, elseif, while, function
For each block of code, the code within the block (that's the line after if, for, else, etc and before the keyword 'end') will be indented one more tab then the one before. So in this case, let's take the initArray function that I wrote.
1
2
3
4
5
6
7
2
3
4
5
6
7
[b]function[/b] initArray(m) local array = {} [b]for[/b] i = 1, m do array[i]=0 [b]end[/b] return array [b]end[/b]
every time that you encounter one of these bolded words, the next line will be indented one level. If you see the word end, unindent that line and the next by one level
So:
1
2
3
4
5
6
7
2
3
4
5
6
7
[b]function[/b] initArray(m) 	local array = {} 	[b]for[/b] i = 1, m do 		array[i]=0 	[b]end[/b] 	return array [b]end[/b]
And here I'll take your code as a last example.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[b]function[/b] sample.ut.kill(killer,victim,weapon) ... -- Humiliation (Killed with knife) [b]if[/b] (weapon==50) then ... [b]else[/b] -- First kill. [b]if[/b] (level==1) then -- Doesn't do nothing at his point. [b]if[/b] (level==2) then -- Doesn't do anything either. This is unfinished version. [b]elseif[/b] (level==3) then -- Megakill. ... [b]end[/b] [b]end[/b] [b]end[/b]
will become
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[b]function[/b] sample.ut.kill(killer,victim,weapon) 	... 	-- Humiliation (Killed with knife) 	[b]if[/b] (weapon==50) then 		... 	[b]else[/b] 		-- First kill. 		[b]if[/b] (level==1) then 			-- Doesn't do nothing at his point. 			[u][b]if[/b] (level==2) then[/u] 				-- Doesn't do anything either. This is unfinished version. 			[b]elseif[/b] (level==3) then 				-- Megakill. 				... 			[b]end[/b] 		[b]end[/b] 	[b]end[/b]
Here's where a bit of logic comes in handy. where you see the underlined if (level==2) then, that means that if level is one, and level is 2, then do the following.
That's simply an impossibility, what you meant to do was if level is 1 then do nothing. If level is 2 then do the following. So you're missing and 'end' before the underlined line
the correct code would thus be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[b]function[/b] sample.ut.kill(killer,victim,weapon) 	... 	-- Humiliation (Killed with knife) 	[b]if[/b] (weapon==50) then 		... 	[b]else[/b] 		-- First kill. 		[b]if[/b] (level==1) then 			-- Doesn't do nothing at his point. 		[b]end[/b] -- This is important 		[u][b]if[/b] (level==2) then[/u] 			-- Doesn't do anything either. This is unfinished version. 		[b]elseif[/b] (level==3) then 			-- Megakill. 			... 		[b]end[/b] 	[b]end[/b] [b]end[/b]
Now notice how everything looks pretty and the last end meets the left margin of the first function keyword?
Now I'm not going to change your code for you, but follow what I've just said and see if you can get yours to work.
Rather pointless because you learned nothing from it.
It is better to make mistakes, and fix them.