English About reqcld

17 replies
Goto Page
To the start Previous 1 Next To the start
03.08.12 09:16:47 pm
Up
Sudden Death
User
Offline Off
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!
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
03.08.12 09:18:34 pm
Up
krabob
User
Offline Off
More information about the 'image' is needed
People help the people
03.08.12 09:20:44 pm
Up
Sudden Death
User
Offline Off
Hmm.. For example we have image 128x128 with png format.
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
03.08.12 09:28:35 pm
Up
PyKemis
User
Offline Off
Possible, however, only if your player is alive and equipped with a weapon that can attack.

Code:
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.
03.08.12 09:32:32 pm
Up
Mechanolith
User
Offline Off
user PyKemis, use the attack hook. Using the always hook with requestdata will lag like hell.
03.08.12 09:34:25 pm
Up
Sudden Death
User
Offline Off
Yea Thanks for quick answer, but how about a hud image?
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
03.08.12 09:48:04 pm
Up
PyKemis
User
Offline Off
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.

Code:
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
03.08.12 10:07:47 pm
Up
Sudden Death
User
Offline Off
Thanks you a lot,
but about the 'hitbox .. How to make bigger this square?
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
04.08.12 03:20:22 am
Up
PyKemis
User
Offline Off
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.
Code:
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
04.08.12 03:23:56 am
Up
Yates
Reviewer
Offline Off
@user PyKemis: Requesting data on the always hook would lag a lot. Shouldn't you request it when the person clicks instead?
04.08.12 03:28:42 am
Up
PyKemis
User
Offline Off
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.
04.08.12 10:04:27 am
Up
Infinite Rain
Reviewer
Offline Off
@user PyKemis:
Always hook will still make everything worse, attack hook is better.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
04.08.12 10:31:57 am
Up
PyKemis
User
Offline Off
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.
04.08.12 10:37:17 am
Up
Snurq
BANNED
Offline Off
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)


Code:
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.
04.08.12 12:30:57 pm
Up
DC
Admin
Offline Off
@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
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
04.08.12 02:54:45 pm
Up
VADemon
User
Offline Off
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
04.08.12 03:29:09 pm
Up
DC
Admin
Offline Off
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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
12.08.12 08:36:13 pm
Up
KimKat
GAME BANNED
Offline Off
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! Do not write stuff which is not related to the original topic! - This is totally unrelated! Also it's a known problem. Never post it again please.
To the start Previous 1 Next To the start