Forum

> > CS2D > Scripts > About reqcld
Forums overviewCS2D overview Scripts overviewLog in to reply

English About reqcld

17 replies
To the start Previous 1 Next To the start

old About reqcld

Sudden Death
User Off Offline

Quote
Hi!~ I've a question, again.. About 'reqcld'. Is there any way to make 'hitbox' on image? I mean when you press with ya' cursor on image, it shows for example message? Thanks for answers!

PS, If ya can, please show example in code. Thanks!

old Re: About reqcld

Apache uwu
User Off Offline

Quote
Possible, however, only if your player is alive and equipped with a weapon that can attack.

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
--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.

old Re: About reqcld

Apache uwu
User Off Offline

Quote
That is also possible. Now when you spawn you see an image on your screen. Click the center of that image and it will change colors.

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
--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

old Re: About reqcld

Apache uwu
User Off Offline

Quote
Do a small for loop around the areas it checks. You might need to tweak this to the correct dimensions and coordinates.

Change the attack hook function.
1
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

old Re: About reqcld

Yates
Reviewer Off Offline

Quote
@user Apache uwu: Requesting data on the always hook would lag a lot. Shouldn't you request it when the person clicks instead?

old Re: About reqcld

Apache uwu
User Off Offline

Quote
Most players have more than 100 ping. That means, when they click and move their mouse within a tenth of a second, the coordinate the server gets is incorrect.

old Re: About reqcld

Apache uwu
User Off Offline

Quote
No matter how you look it, it will lag. Placing it on always will make the lag smoother, while on attack would be much more noticeable.

old Re: About reqcld

Snurq
BANNED Off Offline

Quote
so how does the reqcld work in mode 4?
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
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.

old Re: About reqcld

DC
Admin On Online

Quote
@user Snurq: Only works with files that are
• 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

old Re: About reqcld

VADemon
User Off Offline

Quote
I will check whether CounterStrike2D.exe is loaded - it's very important.

PS: Would be glad to see the feature that allows to check -whether- a not loaded file exists

old Re: About reqcld

DC
Admin On Online

Quote
No, it's actually a security measurement that you can only check these loaded files. Otherwise scripts could be used to analyze the whole CS2D folder of clients etc. This is a security risk and not necessary at all.

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.

old Re: About reqcld

KimKat
GAME BANNED Off Offline

Quote
What about checking if USGN login details are properly loaded and used when you are joining a server if you know what I'm saying, so that you don't become that guest player (USGN ID #0) even though you are logged into the USGN. That happens alot actually. How about double checks for USGN login details when joining a server? I'd like that to be fixed.

Admin/mod comment

Rules §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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview