Forum

> > CS2D > Scripts > About reqcld
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch About reqcld

17 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt About reqcld

Sudden Death
User Off Offline

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

alt Re: About reqcld

Apache uwu
User Off Offline

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

alt Re: About reqcld

Apache uwu
User Off Offline

Zitieren
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

alt Re: About reqcld

Apache uwu
User Off Offline

Zitieren
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

alt Re: About reqcld

Yates
Reviewer Off Offline

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

alt Re: About reqcld

Apache uwu
User Off Offline

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

alt Re: About reqcld

Apache uwu
User Off Offline

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

alt Re: About reqcld

Snurq
BANNED Off Offline

Zitieren
so how does the reqcld work in mode 4?
from the docs:
Zitat
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.

alt Re: About reqcld

DC
Admin Off Offline

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

alt Re: About reqcld

VADemon
User Off Offline

Zitieren
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

alt Re: About reqcld

DC
Admin Off Offline

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

alt Re: About reqcld

KimKat
GAME BANNED Off Offline

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

Regeln §4.5 - Bleibe beim Thema! Keine "off-Topic"-Beiträge! - This is totally unrelated! Also it's a known problem. Never post it again please.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht