Forum
CS2D Scripts Lua Scripts/Questions/Help CmDark has written
Help requested:
Blazzingx - Could you please explain the logic behind
the save and loading function to me?
Blazzingx - Could you please explain the logic behind
the save and loading function to me?
Dunno what you exactly want...
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
function array(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end timer = array(32)
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
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
adhook("second","sec") addhook("attack","at") function array(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end mp = game("sv_maxplayers") timer = array(mp) function at(id) 	if (player(id,"weaponid")==24) then 		parse("sethealth "..id.." "..(player(id,"health")+20)) 		parse("strip"..id.."24") 		timer[id] = 1 	end end function sec(id) 	if (timer[id] >= 1) then 		timer[id] = timer[id] + 1 		if (timer[id] >= 15) then 			equip(id,24) 			timer[id] = 0 		end	 	end end
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
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
ad[b]d[/b]hook("second","sec") addhook("attack","at") function array(m) local array = {} for i = 1, m do array[i]=0 end return array end mp = game("sv_maxplayers") mytimer = array(mp) --We will just rename this to not cause conflict with CS2D function function at(id) if (player(id,"weaponid")==24) then parse("sethealth "..id.." "..(player(id,"health")+20)) parse("strip"..id.."24") mytimer[id] = 1 end end function sec() --No parameters [b]for id=1,mp do[/b] --Cycle through players if (mytimer[id] >= 1) then mytimer[id] = mytimer[id] + 1 if (mytimer[id] >= 15) then equip(id,24) mytimer[id] = 0 end end end end
Try that and tell me about errors
WTF no tabs o.o
EDIT:
Ok now i've got more errors:
LUA ERROR: dir: Bad argument #2 to 'player' (string expected, got boolean)
LUA ERROR: attempt to call a nil value
LUA ERROR: dir: attempt to compare a number with nil
(i think the last one is the same as the timer thing)
The boolean thing
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("attack,"at") function at(id) 	if player(id,"weaponid" == 40) then 		equip(id,40) 		setw(id,40) 	end end (the line with the problem is the "if" line)
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
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
addhook("hit","hitt") function array(m) local array = {} for i = 1, m do array[i]=0 end return array end mp = game("sv_maxplayers") class = array(mp) dmg = array(mp) function dmg_gain(vic,id,wp,hp,ap) 	if (hp >= 1) then 		dmg[id] = dmg[id] + hp 		if (ap >= 1) then 			dmg[id] = dmg[id] + ap 			for i = 1, 5 do 				if (class == 1) then 					some hudtxts 				end 				if (class == 2) then 					some hudtxts 				end 				if (class == 5) then 					some hudtxts 				end 				if (class == 6) then 					some hudtxts 				end 				if (class == 7) then 					some hudtxts 				end						 			end 		end 	end end function hitt(vic,id,wp,hp,ap) 	dmg_gain(id) end (here the line that has the problem is the HP line)
edited 3×, last 18.11.09 06:40:37 pm
I also need somehelp in how to make your char turn into a car like in a script i saw.
Thx for your help
Did anyone see one of Bear Grylls Survival films?
I think someone yes
I want to do a big mappack, but I need some scripts. I have tryied to do them, but I dont understand Lua. I read all of tutorials, and I still dont know lua.
I need only one easy script.
In my maps will be "hungry system". In every 10 second you loosing 5 hp. I need something like this, that when you will hit tile/script exactly fish, you earning hp. It is possible? Can you write it for me?
for random critical hit?
and I don't think that we can write a script for you for you like this because we don't understand what you actually want
and @wilson are you using wrapper functions?
if not then you gotta have
1
2
3
4
5
6
7
2
3
4
5
6
7
function equip(id,wpn) parse("equip "..id.." "..wpn) end function setw(id,wpn) parse("setweapon "..id.." "..wpn) end
and
wilson
notice you have this in your if line
1
if [b]player(id,"weaponid" == 40)[/b] then
1
if player(id,"weaponid") == 40 then
Your problem is actually
function dmg_gain
as thats the function that is calling the attempt to compare a number with nil
@Blazzingxxx er I wanna know how to write and read
using io.write() and io.read()
I understand the part of ..r.. and ..w.. as read and write but how would you use it..
io.open(filname [, mode])
io.close ([file]
edited 1×, last 18.11.09 11:39:31 pm
thanks for it.
yes i'm using wrappers but what do you mean with the dmg_gain function is the problem ?
well its the function which is called in hitt
which means its the problem
and which line did you say was the problem in there?
i dunno i think dmg[id] is the nil thats compared with number
sorry. when i copy this from the forum and paste it again on the forum it isn't tabbed :S
er try pasting the functions in dmg_gain into function hitt
instead of just calling the dmg_gain function when hit
but well i'll try it.
it seems it's my last error !
EDIT: well this works fine
but i need to do a save and load function :S
anyone knows how to do this ??
EDIT2:
well now i'm getting another error:
LUA ERROR: attempt to call a nil value.
it doesn't show direction or something just says that.
what does it mean ?
edited 1×, last 19.11.09 12:15:58 am
you know some functions always have a nil value that is called yet work perfectly you know?