PS, If ya can, please show example in code. Thanks!
Forum
CS2D Scripts About reqcldAbout reqcld
17 replies 1
PS, If ya can, please show example in code. Thanks!
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
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
--first get the coords of everyone's mouse on the map addhook("always","_always") addhook("clientdata","_clientdata") mouse={} function _always() 	reqcld(0,2) end function _clientdata(id,_mode,data1,data2) 	if _mode==2 then 		mouse[id]={x=data1,y=data2} 	end end --now check if they clicked with the attack hook addhook("attack","_attack") images={} function _attack(id) 	if math.floor(mouse[id].x/32+16)==44 and math.floor(mouse[id].y/32+16)==99 then 		if images[id]~=nil then 			freeimage(images[id]) 		end 		images[id]=image("gfx/sprites/flare2.bmp",mouse[id].x,mouse[id].y,3) 		imagescale(images[id],2,2) 	end end
Now load the map de_dust and spawn as a terrorist. Find the tree that's directly below and a little to the right and click. An image should appear where your mouse is.
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
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
--first get the coords of everyone's mouse on the map addhook("always","_always") addhook("clientdata","_clientdata") addhook("spawn","_spawn") images={} function _spawn(id) 	if images[id]~=nil then 		freeimages(images[id]) 	end 	images[id]=image("gfx/sprites/flare2.bmp",128,128,2) end mouse={} function _always() 	reqcld(0,0) end function _clientdata(id,_mode,data1,data2) 	if _mode==0 then 		mouse[id]={x=data1,y=data2} 	end end --now check if they clicked with the attack hook addhook("attack","_attack") function _attack(id) 	if math.floor(mouse[id].x/32+16)==20 and math.floor(mouse[id].y/32+16)==20 then 		imagecolor(images[id],math.random(0,255),math.random(0,255),math.random(0,255)) 	end end
but about the 'hitbox .. How to make bigger this square?
Change the attack hook function.
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
function _attack(id) 	for x=19,21 do 		for y=19,21 do 			if math.floor(mouse[id].x/32+16)==x and math.floor(mouse[id].y/32+16)==y then 				imagecolor(images[id],math.random(0,255),math.random(0,255),math.random(0,255)) 				break 			end 		end 	end end
Always hook will still make everything worse, attack hook is better.
from the docs:
Quote
Mode 4: 1 if the file specified with parameter (relative to the CS2D folder) has been loaded, 0 otherwise (second value always 0)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
addhook("join","myjoin") function myjoin(id) 	reqcld(id,4,"sys/server.cfg") 	reqcld(id,4,"Readme.txt") 	reqcld(id,4,"gfx/pointer.bmp") end addhook("clientdata","my_clientdata") function my_clientdata(id,mode,data1,data2) 	msg(id..' '..mode..' '..data1..' '..data2) end
i get output 1 4 0 0 for all requests.
used by entities in the map
or specified in sys/servertransfer.lst
It doesn't make much sense to test if pointer.bmp is loaded anyway. It is always loaded
PS: Would be glad to see the feature that allows to check -whether- a not loaded file exists
Checking loaded stuff on the other hand can be important to see if certain images, which are used in Lua scripts and which influence the gameplay, are actually loaded.
Admin/mod comment
§4.5 - Stick to the point! No off-topic posts! - This is totally unrelated! Also it's a known problem. Never post it again please. 1