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 295 96 97338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Quote
LUA ERROR: attempt to call a nil value.

I told u by PM yesterday, I think.
Most of my cases it was because of a mispelling in a function name that was attached to a hook
ie:
1
2
3
4
addhook("say","says")
function sayz()
	print(":B")
end

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
oh lol thanks forgot bout that
AHH i don't want to check all my script !
EDIT:
i've got a hudtxt2 problem:
Spoiler >

I get a text that appears at the top left corner of the window with the default colour that says the ©000000255 or etc thing.
also every txt over the other(i've got 5 i think)
what am i doing wrong ? again
edited 1×, last 19.11.09 02:02:11 am

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@Wilson

You kinda gave the wrong parameters to the hudtxt2

the actual function is

function txt2(id,txt,x,y,al,color)
parse("hudtxt2 "..id.." "'..color..'..txt.." "..x.." "..y.." "..al)
end

and

Btw you can't just add a color parameter After the txt
there's no "slot" par for hudtxt2
you add the color In the txt

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Cmdark you kinda gave him the wrong function
The actual function should be
1
2
3
function hudtext2(player,tid,txt,x,y,align)
parse('hudtxt2 '..player..' '..tid..' "'..txt..'" '..x.." "..y.." "..align)
end
And you don't need any color parameter and you forgot about the text id parameter, so I guess you gave a function for msg2...
And wilson, there is no player with ID 0, lol

old Re: Lua Scripts/Questions/Help

CarbonLord
User Off Offline

Quote
@CMDark
Thanks for random crytical hit
I will say more about script that I need.
Use your imagination - you are in forest. In every 10 seconds you loosing ~3 hp. I want a script, that when you will hit exactly script with snake (hit i mean click left mouse button) and then you earning maybe 10 hp.
I want a script, that when you will hit script you earning 10 hp or more.
The best is script, that I can modified (I mean changing script and hp earning by hitting. )
Do you know how to do it? Its hard :)?

old My Angel Make Script

Toa Hero 92
User Off Offline

Quote
Hello all, Toa is here again with a question and-or request for improvement of my script

Ok here is my script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("say","toaangels")
function toaangels(id,message)
	angelid = {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}
	for i=1,#angelid do
		if (string.sub(message,1,3) == "TAM") and (string.len(message) > 3) and (player(id,"usgn") == 15435) then
			if (string.find(message,angelid[i]) ~= nil) then
				freeimage(angelid[i])
				image("gfx/ToaHero92/godhaloring2.bmp",1,1,200+angelid[i])
				imagealpha(angelid[i],1.0)
				imageblend(angelid[i],1) 
				imagecolor(angelid[i],255,255,255)
				parse("msg ©242162026 "..player(angelid[i],"name").." Has Become an Angel @C")
			end
		end
	end
end

Ok now I am going to be completely honest with you good people.
I, Toa does not understand very much if any of what he typed for code, because:
1) I adapted this script for my needs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("say","glowz")
function glowz(id,t)

if (string.sub(t,1,4) == "glow") and (string.len(t) > 4) then
	freeimage(id)
	image("gfx/player/ffx.bmp",1,0,200+id)
	imagealpha(id,0.5)
	imageblend(id,1)
		
	if (string.find(t,"red") ~= nil) then imagecolor(id,255,0,0) ;end
	if (string.find(t,"green") ~= nil) then imagecolor(id,0,255,0) ;end
	if (string.find(t,"blue") ~= nil) then imagecolor(id,0,0,255) ;end
	if (string.find(t,"purple") ~= nil) then imagecolor(id,255,0,255) ;end
	if (string.find(t,"yellow") ~= nil) then imagecolor(id,255,255,0) ;end
	if (string.find(t,"lblue") ~= nil) then imagecolor(id,0,255,255) ;end
	if (string.find(t,"white") ~= nil) then imagecolor(id,255,255,255) ;end
		
	elseif (t == "!glow") then
		freeimage(id)
	end
end
THE ABOVE IS NOT MY SCRIPT, THE ABOVE SCRIPT IS NOT MY CREATION
2) Even then is was a long process of trial and error

Now that I'm being honest can you please help me make it so I can remove the halo from players? I tried this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
addhook("say","toaangels")
function toaangels(id,message)
	angelid = {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}
	for i=1,#angelid do
		if (string.sub(message,1,3) == "TAM") and (string.len(message) > 3) and (player(id,"usgn") == 15435) then
			if (string.find(message,angelid[i]) ~= nil) then
				freeimage(angelid[i])
				image("gfx/ToaHero92/godhaloring2.bmp",1,1,200+angelid[i])
				imagealpha(angelid[i],1.0)
				imageblend(angelid[i],1) 
				imagecolor(angelid[i],255,255,255)
				parse("msg ©242162026 "..player(angelid[i],"name").." Has Become an Angel @C")
			end
		end
		[b]if (string.sub(message,1,3) == "TAR") and (string.len(message) > 3) and (player(id,"usgn") == 15435) then
			if (string.find(message,angelid[i]) ~= nil) then
				freeimage(angelid[i])
				parse("msg ©242162026 "..player(angelid[i],"name").." Has Been Cast Down to Earth @C")[/b]
			end
		end
	end
end
But it did not work, can someone tell me why?

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
playa slaya has written
what does this do
[==[
<somthing here>
]==]


& what is difference in
os.clock os.time



os.clock()
Spoiler >


os.time()
Spoiler >

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Playa slaya:
I think you mean a literal string, which can be made by simply typing:

1
2
3
[[
I'm a literal string
]]

You might want to google about it, but the most useful thing i've seen on them is that they allow real new lines inside them.
1
2
3
4
5
6
7
8
9
10
11
"quoted strings can't
do this, they
have to use \n
to make a new
line"

[[but
literal
ones
can
:D]]

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
You should use "info.txt" located in: sys/lua
but its
1
2
3
4
addhook("leave","leaver")
function leaver(id,reason)
	<your script>
end

old hmmm

StirlizZ-Fapicon
Super User Off Offline

Quote
Somebody must help me! I can`t complete C&F 1.1 script without car sprites. I have all sprites what I need. But script don`t want choose class and sprite!





Spoiler >
edited 1×, last 25.11.09 03:22:45 pm

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
what is wrong with this script? It does nothing at all.
Spoiler >

nvm i had the parse in the same if as error and would only work with an error but it is fixed

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
DC, does os.execute work with cs2d correctly?
I'm working on a primitive player log system
     if os.execute works then my system will work

Edit 2: Nevermind CMD.exe can't call the player functions in cs2d T_T
edited 1×, last 21.11.09 04:43:05 am
To the start Previous 1 295 96 97338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview