Forum

> > CS2D > Scripts > Lua Problem!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Problem!

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

old Lua Problem!

Marcell
Super User Off Offline

Quote
what the problem with this lua?:/
because not works,and i not understand

1
2
LUA ERROR: Attempt to call nill value LUA ERROR: Attempt to call nill value LUA ERROR: Attempt to call nill value
ERROR: CANNOT PLAY SOUND sfx/sfx/musics/1.ogg - file does not exist sv_sound

the lua is:
1
2
3
4
5
6
7
addhook("menu", "music-p")
function music-p(id, tit, sel)
  if(tit=="Music Player") then
       if(sel==1) then
parse("sv_sound music/1.ogg"); 
end
end

old Re: Lua Problem!

DannyDeth
User Off Offline

Quote
Realy, can you not speak English well enought o say that the file does not exist?!?

Your music file doesn't exist, it is simple as that!

old Re: Lua Problem!

EngiN33R
Moderator Off Offline

Quote
No Danny, see, the error says
Quote
CANNOT PLAY SOUND sfx/sfx/musics/1.ogg


It has double sfx which means he wrote
1
sv_sound sfx/musics/1.ogg
somewhere. It's a pretty common mistake. But in the code he provided there isn't such a mistake. Hell, there aren't any mistakes there. So, I dunno.

old Re: Lua Problem!

Marcell
Super User Off Offline

Quote
This is the new code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("serveraction" ,"serveraction")
function sact(id, act)
 if(act==1) then
  menu(id, "Music Player, Play Music 1")
 end
end

addhook("menu", "music")
function music(id, tit, sel)
if(tit=="Music Player") then
if(sel==1) then
parse("sv_sound sfx/music/1.ogg"); 
end
end
end

and in console successfully added hooks!
1
2
Lua: Adding function 'serveraction' to hook 'serveraction'
Lua: Adding function 'music' to hook 'menu'
But when i hit 1 serveraction the menu not show and in console write this:
1
LUA ERROR: Attempt to call nill value

old Re: Lua Problem!

PyroCracker
User Off Offline

Quote
user Marcell has written
-.-" you aren't helps me ,you are always insulting me.


yeah, but.... guy...
i mean...
WTF!?

http://unrealsoftware.de/forum_posts.php?post=246485&start=0

you create threads like this and youre mad that nobody help you!?

-we cant understand you
-youre using translators (notpadd++ translator wtf!?)
-youre creating fucking threads
-youre spamming pointless polls and posts
wtf do you want?

learn some englisch!

youre englisch dont has to be perfect. look at me! my gramma is a fool! but the people understand what i mean. thats enough for the most posts. nobody here wants a 100% perfect englisch. but please please learn some englisch. we have to understand what you want from us.
we cant help you that way!

old Re: Lua Problem!

JONY
User Off Offline

Quote
Try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("serveraction" ,"serveraction")
function sact(id, act)
if(act==1) then
menu(id, "Music Player, Play Music 1")
end
end

addhook("menu", "music")
function music(id, tit, sel)
if(tit=="Music Player") then
if(sel==1) then
parse("sv_sound music/1.ogg");
end
end
end

old Re: Lua Problem!

EngiN33R
Moderator Off Offline

Quote
Yes, like JONY said, you have to remove the sfx. The sound function already searches in the sfx folder.

old Re: Lua Problem!

Marcell
Super User Off Offline

Quote
i found the problem!
1
2
addhook("serveraction" ,">>>>>serveraction2<<<<<<")
function sactTHIS IS THE PROBLEM(id, act)


and now works!:)))
anyway thanks to all:)

old Re: Lua Problem!

Marcell
Super User Off Offline

Quote
this is the works script!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("serveraction" ,"serveraction2")
function serveraction2(id, act)
if(act==1) then
menu(id, "Music Player, Play Music 1")
end
end

addhook("menu", "music")
function music(id, tit, sel)
if(tit=="Music Player") then
if(sel==1) then
parse("sv_sound music/1.ogg");
end
end
end

old Re: Lua Problem!

KimKat
GAME BANNED Off Offline

Quote
Could this possibly work?
I think that the sfx folder isn't needed in the string value as it'll automaticly locate that folder, from what I know. You'd just need the code below and the files for each sound which are to be 0.ogg, 1.ogg, 2.ogg. If files don't exist it'll of course become a Lua error. Hope I've helped.

There is a useful command to use in order to be able to play the sound for each player individually cs2d cmd sv_sound2.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
sound_path = {[0] = "music/0.ogg",[1] = "music/1.ogg",[2] = "music/2.ogg"}

addhook("menu", "music")
function music(id, tit, sel)
	if(tit=="Music Player") then
		if(sel==1) then
			sv_sound2(id, sound_path[0])
		-- elseif(sel==2) then
			-- sv_sound2(id, sound_path[1])
		-- elseif(sel==3) then
			-- sv_sound2(id, sound_path[2])
		end
	end
end
Remove the comments if you want the other music files to be able to play aswell.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview