Forum

> > CS2D > Scripts > Object Destroy
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Object Destroy

20 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: Object Destroy

Pseudon
User Off Offline

Zitieren
Well I think you can use cs2d lua hook clientdata and cs2d lua cmd reqcld to find the position of the mouse and then just do whatever you want after you have found the data. For example, check if a certain object is located in where the pointer is being held and then destroy it.

alt Re: Object Destroy

Jarates
User Off Offline

Zitieren
I need the function that destroy the object.

function destroy()
if object(id,'exists') then
?? Destroy ???

alt Re: Object Destroy

gamus
User Off Offline

Zitieren
@user Danilwra: tabbed and fixed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("serveraction","serveraction_")
addhook("clientdata","clientdata_")

function serveraction_(id,act)
	if act==3 then --this is where you made a mistake
		reqcld(id,2)
	end
end

function clientdata_(id,mode,x,y)
	if mode==2 then 
		parse("explosion "..x.." "..y.." 20 999999")
	end
end

alt Re: Object Destroy

Jarates
User Off Offline

Zitieren
1
parse("explosion "..x.." "..y.." 20 999999")
I didn't ask the object to be removed by explosion LOL

alt Re: Object Destroy

Apache uwu
User Off Offline

Zitieren
Try this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
addhook("always", "_always")
addhook("clientdata", "_clientdata")
addhook("serveraction", "_serveraction")

local mouses = {}

function _always()
    reqcld(0, 2)
end

function _clientdata(id, mode, data1, data2)
    if mode == 2 then
        mouses[id] = {data1, data2}
    end
end

function _serveraction(id, action)
    if (action == 2) then
        local objectID = objectat(math.floor(mouses[id][1] / 32 + 0.5), math.floor(mouses[id][2] / 32 + 0.5))
        if (objectID > 0) then
            parse("killobject " .. objectID)
        end
    end
end

alt Re: Object Destroy

Apache uwu
User Off Offline

Zitieren
Nevermind, I'm on my phone and didn't see that you're wrapping it with object. Anyways, there's no need to minus 16 and then round up/down.

alt Re: Object Destroy

Apache uwu
User Off Offline

Zitieren
Yep there's no difference, so there's no reason to post the same code twice. The only difference is that you're calling request data once and I'm requesting it in always.
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht