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 2332 333 334338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Quote
@DannyDeth

But i want it with Timer function. I am not really good at your type and i know little bit about timers so it will be easier for me to understand...

old Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Quote
@DennyDeth any1 like that:
1 End round - music
2 End round - second music, but 1 music is steel playing...
i want:
1 End round - 1 music
2 End round - second music and 1 music is stopped.

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
OK, i will make you a timer function, here you go:
1
2
3
4
5
6
7
function Timer(time)
	finish-time = os.clock + time
	while(os.clock < finish-time)
		-- Wait until it finishes
	end
	return 1;
end

You would use it like this:
1
2
3
4
5
6
7
function speed-potion(id)
	parse("speedmod "..id.." 50")
	while(Timer(5) < 1)
		-- Wait until timer is finished
	end
	parse("speedmod "..id.." 0")
end
Hopefully this will quit you better, lol.

@Yamato: Still busy I will probably finish soon

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
BureX has written
1
2
3
addhook("ai_goto","zmgo")
function zmgo(id,32,64)
end

Can i make "ai_goto" more of them ? like every random bot goes to random "ai_goto" and starts to attack when destination is reached ?


@DannyDeth somebody gotta explain me this "Seriously"
P.S. i am not in the mood (i waited to get on MY own computer for weeks. I couldnt get on my pc cuz of an F's)
edited 1×, last 23.12.10 02:46:43 pm

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
Can you even hook ai_goto? I didn't know that ..
Just:
1
ai_goto(BOT ID,X,Y)
BOT ID = The ID of the bot.
X = Tile X or X, idk
Y = Tile Y or Y, idk

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
Maybe you can, maybe you can't. EXPERIMENT!

Stop being a wimp and actually do something! I am not going to spend my time checking shit you could of done yourself! So stop asking us about it an try it out, live dangerous!

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
@Yasday yeah but how can i do it for one team ?

@DannyDeth maybe cuz i cant turn on cs2d ?? IS THIS THE F***ING PROBLEM YOU ARE MAD OF ?

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
1
2
3
4
5
6
7
function ai_gotot(id,x,y)
	if player(id,"bot") then
		if player(id,"team") == 1 then
			ai_goto(id,x,y)
		end
	end
end

now use
1
ai_gotot(id,x,y)

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
BureX has written
@maybe cuz i cant turn on cs2d ?? IS THIS THE F***ING PROBLEM YOU ARE MAD OF ?

Then why the heck you're asking?

Seriously, recent questions are way too simple.
I doubt that people under 13 would ask such a things.
The questions thread has become a request one.
edited 1×, last 23.12.10 03:20:00 pm

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
when my dad gets the cd for windows xp sp3 he shall uninstall all files from C:/ so im making this stuff so i dont need to do it later

P.S. im 14 (23.4.1996)

old Stupid Error

Fehu
User Off Offline

Quote
I have error with hudtxt but this no have sense!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function initArray(m)
	local array = {}
	for id = 1, m do
		array[id]=0
	end
	return array
end

lvl=initArray(32)
xp=initArray(32)
xpm=initArray(32)
mp=initArray(32)
mpm=initArray(32)
hp=initArray(32)
hpm=initArray(32)

addhook([[ms100]],[[lol_huds]])
function lol_huds(id)
	for id=1,32 do
		parse('hudtxt2 '..id..' 1 "©255000000Health "..hp[id].."/"..hpm[id].."" 360 430')
	end
end

And screen:
IMG:https://img41.imageshack.us/img41/5048/92179280.jpg


Dont show hp/hpmax and bad position...
In console is one error (spam):
IMG:https://img24.imageshack.us/img24/948/dedust200003.jpg


Can anyone help?

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
1
addhook([[ms100]],[[lol_huds]])
That is your problem, there is something that is ceing done by the lol_huds funtion that is calling a nil value every 100ms ( hence the spamming thing ). That is also why the actual health is not showing, only Helath: and then nothingness...

So here is an un-tested version of your code that should hopefully fix the problem:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function initArray(m)
     local array = {}
     for id = 1, m do
          array[id]=0
     end
     return array
end

lvl=initArray(32)
xp=initArray(32)
xpm=initArray(32)
mp=initArray(32)
mpm=initArray(32)
hp=initArray(32)
hpm=initArray(32)

addhook("ms100","lol_huds")
function lol_huds()
     for i=1,32,1 do
          parse('hudtxt2 '..id..' 1 "©255000000Health "..hp[id].."/"..hpm[id].."" 360 430')
     end
end



However I cannot say it will work asi i do not have the full script

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Dont work...
Here is full script:
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%% FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



function lol_reset(id)
	lvl[id]=1
	xp[id]=0
	xpm[id]=250
	mpm[id]=5
	mp[id]=mpm[id]
	hpm[id]=30
	hp[id]=hpm[id]
end

function lol_icons(id)
	img1=image("gfx/(F)ehuziom Folder Sprite/rpg_mod/Okienko prawo dol.png",0,0,2,id)
	imagepos(img1,610,430,0)
	imagealpha(img1,0.9)
	img2=image("gfx/(F)ehuziom Folder Sprite/rpg_mod/Okienko prawo gora.png",0,0,2,id)
	imagepos(img2,582,45,0)
	imagealpha(img2,0.9)
	img3=image("gfx/(F)ehuziom Folder Sprite/rpg_mod/Okienko lewo gora.png",0,0,2,id)
	imagepos(img3,58,45,0)
	imagealpha(img3,0.9)
	img4=image("gfx/(F)ehuziom Folder Sprite/rpg_mod/Okienko lewo dol.png",0,0,2,id)
	imagepos(img4,30,430,0)
	imagealpha(img4,0.9)
	img5=image("gfx/(F)ehuziom Folder Sprite/rpg_mod/pasek hp.png",0,0,2,id)
	imagepos(img5,350,430,0)
	imagealpha(img5,0.9)
	img6=image("gfx/(F)ehuziom Folder Sprite/rpg_mod/pasek mp.png",0,0,2,id)
	imagepos(img6,350,450,0)
	imagealpha(img6,0.9)
end


--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%% MAIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function initArray(m)
	local array = {}
	for id = 1, m do
		array[id]=0
	end
	return array
end

lvl=initArray(32)
xp=initArray(32)
xpm=initArray(32)
mp=initArray(32)
mpm=initArray(32)
hp=initArray(32)
hpm=initArray(32)

for id=1,32 do
	lol_reset(id)
	lol_icons(id)
end


--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%% ENGINE %%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

addhook("join","lol_welcome")
function lol_welcome(id)
	lol_reset(id)
	lol_icons(id)
end

addhook("say","lol_text")
function lol_text(id,txt)
	if player(id,"team")<=2 then
		name=player(id,"name")
		msg([[©255255255]]..name..[[(LV.]]..lvl[id]..[[): ]]..txt)
	end
	return 1
end

addhook("ms100","lol_huds")
function lol_huds(id)
	for id=1,32 do
		parse('hudtxt2 '..id..' 1 "©255000000Health "..hp[id].."/"..hpm[id].."" 360 430')
	end
end

Okay i change all and no spam errors in console, but hudtxt dont work

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("ms100","lol_huds")
function lol_huds(id)
	for id = 1,32 do
		if player(id,"exists") then
			parse('hudtxt2 '..id..' 1 "©255000000Health '..hp[id]..'/'..hpm[id]..'" 360 430 0')
		end
	end
end
Should work like this, try it.

Edit:
@DannyDeth
You can use [[]], too.
These are all strings:
1
2
3
lol = 'lol'
lol = "lol"
lol = [[lol]]
and addhook just uses two strings, so it's no matter.
edited 1×, last 23.12.10 05:08:41 pm

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
It is happening because all the array knows is that each array item = 0, so it cannot display anything! You need to include a script that will make it correct! like this:
1
2
3
4
5
6
addhook("ms100","get_hp")
function get_hp()
	for i=1,32,1 do
		hp[i]=player(i,"health")
	end
end
This code will get the players current health every 100ms and put it in the correct place in the array.
Here is a proper correctio n of the code, it was because of confused " and ' thingies.
1
2
3
4
5
6
addhook("ms100","lol_huds")
function lol_huds()
     for i=1,32,1 do
          parse('hudtxt2 '..id..' 1 "©255000000Health '..hp[i]..'/'..hpm[i]..'" 360 430')
     end
end
Hope it works properly this time

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
It can display 0's, too.
The only thing it can't display is nil values.
But if you use nil as string(txt = "nil") it works too.

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
I'm not stupid, and btw, "nil" isn't nil, so obviously it wont work. I'm just a bit drunk or something probably, that's what you get for drinking whine with supper, lol.
To the start Previous 1 2332 333 334338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview