Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 294 95 96338 339 Next To the start

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
CmDark has written
Help requested:
Blazzingx - Could you please explain the logic behind
the save and loading function to me?

Dunno what you exactly want...

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
This is my error:
Spoiler >

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
uhm it's not nil i've got this befor the script
1
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)

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

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

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

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

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
dude i'm so stupid with the parameters i always include parameters that the hook doesn't have :S
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
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)
The last one:
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
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

old Re: Lua Scripts/Questions/Help

Scythe
User Off Offline

Quote
>Can someone make me a script that detects if a player is the last one?

>I also need somehelp in how to make your char turn into a car like in a script i saw.

Thx for your help

old Re: Lua Scripts/Questions/Help

CarbonLord
User Off Offline

Quote
Hi everyone.
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?

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@CarbonLord are you talking about my code?
          for random critical hit?
Spoiler >

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
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
You have to change it to
1
if player(id,"weaponid") == 40 then
and last one:

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

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@wilson

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

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
here it is.
sorry. when i copy this from the forum and paste it again on the forum it isn't tabbed :S
Spoiler >

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@wilson

er try pasting the functions in dmg_gain into function hitt
instead of just calling the dmg_gain function when hit

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
uh this is weird :S
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
To the start Previous 1 294 95 96338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview