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 287 88 89338 339 Next To the start

old PLS HELP

udinrock
User Off Offline

Quote
Guys i need a lua scrippter tutor cause im trying to make a script but idk wat thing to do?
PLS HEELP

old Need a bit help!

GreenDevil
User Off Offline

Quote
Okay i know how to write the hook but i don't know what to write in the script if i want to make something like if i say "spawn" i spawn somewhere or at the ct spawn?

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
playa slaya has written
why this shall never work
1
2
3
4
5
6
7
8
9
10
11
12
13
14
os.draw = image
function playa.slaya.startround(id)
	if (player(id,"team")==1) then
		pl_t = os.draw("gfx/sprites/flare4.bmp",0,0,100)
		imagecolor(pl_t,255,0,0)
		imageblend(pl_t,1)
		imagealpha(pl_t,0.4)
	else
		pl_ct = os.draw("gfx/sprites/flare4.bmp",0,0,100)
		imagecolor(pl_ct,0,0,255)z
		imageblend(pl_ct,1)
		imagealpha(pl_ct,0.4)
	end
end
i have also tried without os.draw still did not work
Try this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[spoiler]function playa.slaya.startround(id)
	if (player(id,"team")==1) then
		pl_t = image("gfx/sprites/flare4.bmp",0,0,100)
		imagecolor(pl_t,255,0,0)
		imageblend(pl_t,1)
		imagealpha(pl_t,0.4)
	elseif (player(id,"team")==2) then
		pl_ct = os.draw("gfx/sprites/flare4.bmp",0,0,100)
		imagecolor(pl_ct,0,0,255)
		imageblend(pl_ct,1)
		imagealpha(pl_ct,0.4)
	else
		-- Do nothing
	end
end[/spoiler]

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Replace your glow function with this one
1
2
3
4
5
6
7
8
9
10
11
12
13
function sample.glowing.makeallglow()
   for i=1,32,1 do
      id1=image("gfx/sprites/flare2.bmp",0,0,100+i)
      imagescale(id1,1,1)
      imageblend(id1,1)
      imagealpha(id1,0.7)     
      if (player(i,"team") == 1) then
         imagecolor(id1,255,0,0)
      else
         imagecolor(id1,0,0,255)
      end
   end
end
It's a bit shorter.
Tell me if it still doesn't work for you :S Because both work for me.

old My Broadcast script

Toa Hero 92
User Off Offline

Quote
Hello, I Know this script could be better because :
1)It displays the !b
2)It does not print capital letters(it prints letters typed as capitals as lower case)
3)You can put the !b anywhere in the message

It is like this because all I did was adapt the "badwords" script to look for "!b" and display the message as a server message(I'm sure this is all apparent to you)
So here is the
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook ("say","saytoall")
	function saytoall(id,bm)
		
	bmw = {"!b"}
		
	bm=string.lower(bm)
		
		for i = 1,#bmw do
			if (string.find(bm,bmw[i])~=nil) then
				parse("msg ©000255000"..player(id,"name").." "..bm)
				break
			end
		end
	end

If you, the good people of the forum, could help me better my lua skills in these ways I would be forever grateful:
1) Please tell me how to take a variable from a message
EXAMPLE I want to be able to take a number or a name from a message like this "!find #player-id/name#"
2) I want to be able to take the !b out of the message
3) If anyone know of a comprehensive lesson or tutorial on Lua OTHER THAN the Reference Manual http://www.lua.org/manual/5.1/
OR the TheKilledDeath Lua Scripting
Tutorial
http://www.cs2d.com/tut/tkdlua/luatut.html

Because I've read both extensively and they just don't provide the information and details I need. I need a tutorial like this one for C++ http://www.cprogramming.com/tutorial.html , I mean there has got to be one somewhere?
And I don't have the money to buy the official book so please if you could help me that would be great; also, if you have a better lua broadcast script, could you put it up?

Thank you for your time and patience.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
The lua reference manual is all you need to find the function you need.
All that is left to you is thinking about how will you use that function to remove text from a message (if that's what you want to do)

old Re: Lua Scripts/Questions/Help

Heartless Soldier
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
[TIMERS]
- timer(time,"func",["p"],[c])	Create a timer which will call the Lua
				function "func" after a certain time
				in milliseconds (time).
				Moreover it can pass a string parameter (p)
				to this function when calling it.
				The timer calls the function once by default.
				However you can call it several times by
				entering a count value (c). Using 0 or lower
				count values will make the timer call the
				function infinite times.
- freetimer(["func"],["p"])	Remove a timer which calls a certain function
				with a certain parameter.
				Call this function without parameters or empty
				strings as parameters to remove all timers.

[IMAGES]
- image("path",x,y,mode)	Creates an image (dynamic object) on the map.
				Mode 0 for floor image, mode 1 for top image and
				mode 2 for HUD image.
				Mode 101-132: draw under this player
				Mode 201-232: draw over this player
				When drawing at player, x and y are used this way:
				x<=0: do not rotate with player, x>0: rotate img with player
				y<=0: only draw if not covered by fog of war, y>0: draw always
				Returns the ID of the dynamic object image.
- imagecolor(id,red,green,blue)	Changes color of an image
- imagealpha(id,alpha)		Changes opacity (0.0-1.0) of an image
- imageblend(id,mode)		Changes blendmode of an image: 0 for normal,
				1 for light, 2 for shade and 3 for solid
- imagescale(id,x,y)		Changes image scale factors
- imagepos(id,x,y,rot)		Changes position and rotation of an image
- freeimage(id)			Removes an image

A part from info.txt for lazy people

good luck

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
So to put server skins(skins that only woekr in that server) it's like on the glowing players sample ??

Spoiler >

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
-WiLSoN- has written
So to put server skins(skins that only woekr in that server) it's like on the glowing players sample ??

Spoiler >


Yes, but they will not be perfect...

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
what do you mean with that it won't be perfect ?
they won't be as good as the default ones ?
EDIT(because of the multi post warning):
i'm getting an error that says :
1
LUA ERROR: dir:bad argument #1 to 'player' (number expected,got nil)
that line says that:
1
if (player(id,"exists")) then
the line before it says;
1
for i = 1, 32 do
:S please answer me
edited 1×, last 12.11.09 11:37:20 pm

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
-WiLSoN- has written
what do you mean with that it won't be perfect ?
they won't be as good as the default ones ?


he said that because, for example if u reload it doesnt do nothing.
But i think u can make it better with lua script, for eg using reload hook...

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
Made a new script

test it out for me will you guys?

Main Idea of this script is to tele another person to ur pos
Spoiler >

Also i'm planning to make a attack2 opens building menu script(just like wrench)

old Re: Lua Scripts/Questions/Help

CarbonLord
User Off Offline

Quote
Hey,
Do you know How to do, that CT and TT have got other classes? I know only how to do, that CT and TT have got the same (Pyro etc)
And How to do, that all classes have got other weapons on the start?
Please help
~Carbon

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
Spoiler >


Edit: Fixed with on spawn instead.

old :D

GreenDevil
User Off Offline

Quote
Nice glow function. I want to ask how to script i don't know i only know that:

1
2
3
4
addhook("startround","lol")
function lol
	----Here i need to add the script----
end

So i want to script something like "When i go to a new tile that i getting a new weapon or something..." Need Help...
To the start Previous 1 287 88 89338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview