Forum

> > CS2D > Scripts > [Request]Instauild-button
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch [Request]Instauild-button

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt [Request]Instauild-button

Flametail
User Off Offline

Zitieren
Hi! this might sound like a weird request, but I'm looking for a script where a player pressess a button on their keyboard, and a "Wall 1" is placed at their cursor position. And if they press another key, any "Wall 1" under their cursor just disappears.


Kinda like a speed-build for fortress making?

alt Re: [Request]Instauild-button

EP
User Off Offline

Zitieren
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
function Array(s,v)
local array = {}
	for i = 1,s do
	array[i] = v
	end
	return array
end

wall = Array(32,false) addhook("join","lol") function lol(id) wall[id] = false end

addhook("clientdata","asd")
function asd(id,mode,x,y)
	if mode == 2 then
		if wall[id] == true then
			parse("spawnobject 3 "..(x/32).." "..(y/32).." "..player(id,"rot").." 0 "..player(id,"team").." "..id)
			wall[id] = false
		end
	end
end
addhook("use","a")
function a(id)
	if player(id,"health") > 0 then
		wall[id] = true
		reqcld(id,2)
	end
end
the delete thingy is a bit difficult, but im trying to make it

alt Re: [Request]Instauild-button

Apache uwu
User Off Offline

Zitieren
Like 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
25
26
27
28
29
30
31
32
33
34
addhook("serveraction","_serveraction")
addhook("always","_always")
addhook("clientdata","_clientdata")

function _serveraction(id,action)
	local objid=objectid(mouse[id][1],mouse[id][2])
	if objid and action==2 then
		if object(objid,"type")==3 then
			parse("killobject "..objid)
		end
	elseif not objid and action==1 then
		parse("spawnobject 3 "..mouse[id][1].." "..mouse[id][2].." 0 0 "..player(id,"team").." "..id)
	end
end

function _always()
	reqcld(0,2)
end

function _clientdata(id,mode,x,y)
	mouse=mouse or {}
	if mode==2 then
		mouse[id]={math.floor(x/32),math.floor(y/32)}
	end
end

function objectid(x,y)
	for _,id in pairs(object(0,"table")) do
		if object(id,"tilex")==x and object(id,"tiley")==y then
			return id
		end
	end
	return false
end

F2: Build 'Wall I' under cursor
F3: Delete 'Wall I' under cursor

alt Re: [Request]Instauild-button

EP
User Off Offline

Zitieren
instead of using hook always you can just call the reqcld when pressing the serveraction and so get the values:
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
addhook("serveraction","_serveraction")
addhook("clientdata","_clientdata")

function _serveraction(id,action)
	reqcld(0,2)
     local objid=objectid(mouse[id][1],mouse[id][2])
     if objid and action==2 then
          if object(objid,"type")==3 then
               parse("killobject "..objid)
          end
     elseif not objid and action==1 then
          parse("spawnobject 3 "..mouse[id][1].." "..mouse[id][2].." 0 0 "..player(id,"team").." "..id)
     end
end


function _clientdata(id,mode,x,y)
     mouse=mouse or {}
     if mode==2 then
          mouse[id]={math.floor(x/32),math.floor(y/32)}
     end
end

function objectid(x,y)
     for _,id in pairs(object(0,"table")) do
          if object(id,"tilex")==x and object(id,"tiley")==y then
               return id
          end
     end
     return false
end

alt Re: [Request]Instauild-button

Apache uwu
User Off Offline

Zitieren
I used to host servers, from my experience I can say that your method is less server extensive; but slower.

People with say 200+ ping will have their mouse position taken from seconds after the button is pressed. By saving their mouse positions every frame -- fastest as possible, it's saving time.

It's really how you balance server power and speed. I've not noticed any difference in bandwidth usage or connection rates. However I have seen a difference in speed. Thus, I have chosen to use my method simply for that reason.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht