Forum

> > CS2D > Scripts > Return flag to its Place
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Return flag to its Place

19 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Return flag to its Place

The Camo
User Off Offline

Zitieren
Hey guys, I was wondering, is there a way to return a flag once its on the ground via lua command?

Or is that piece of lua missing?

Thanks.
-Camo

alt Re: Return flag to its Place

DC
Admin Off Offline

Zitieren
lol that moving thing should actually work. the player would not even notice it because it happens in the same frame.

alt Re: Return flag to its Place

Yates
Reviewer Off Offline

Zitieren
Couldn't you check if the item is dropped and then remove it? Or would the flag not respawn at it's original spot?

alt Re: Return flag to its Place

EngiN33R
Moderator Off Offline

Zitieren
user Yates hat geschrieben
Couldn't you check if the item is dropped and then remove it? Or would the flag not respawn at it's original spot?


Yeah, that's the point - it wouldn't.

alt Re: Return flag to its Place

Leiche
Moderator Off Offline

Zitieren
user DC hat geschrieben
lol that moving thing should actually work. the player would not even notice it because it happens in the same frame.

Wasn't there a problem with the Teamgates?
Where it couldn't get picked up anymore because of the Teamgate entity overlaying the "hitbox" of the flag?
Or is that a completely different story now?

alt Re: Return flag to its Place

The Camo
User Off Offline

Zitieren
Well, it would be much easier if there was a com for that. I'll think about the teleport thing, but it announces to everyone who picked it up, so when someone sees that they picked up the flag without being near it would go all derp'n'herp...

alt Re: Return flag to its Place

CmDark
User Off Offline

Zitieren
You could always just make a bot as a 'placeholder' which you could manipulate the team of and teleport and reteleport to a point in a map where it do nothing.

Possibly create two bots and leave them in respective bases and name them guardian or something of the respective teams and back to step 1.

alt Re: Return flag to its Place

Apache uwu
User Off Offline

Zitieren
This does work, however you will need at least one player on the team of the flag you are returning.

Oh and it gives the player 1k for returning.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("say","_say")

function _say(id,message)
	if string.lower(message)=="return flag" then
		returnFlag(player(id,"team"))
	end
end

function returnFlag(team)
	tmp=player(0,"team"..team.."living")
	tmp2={player(tmp[1],"x"),player(tmp[1],"y")}
	for _,key in ipairs(item(0,"table")) do
		if item(key,"type")==69+team then
			parse("setpos "..tmp[1].." "..(item(key,"x")*32).." "..(item(key,"y")*32))
		end
	end
	parse("setpos "..tmp[1].." "..tmp2[1].." "..tmp2[2])
end

Screenshots:

IMG:https://img803.imageshack.us/img803/9439/ctfcs2dfortress00154.jpg

IMG:https://img828.imageshack.us/img828/6867/ctfcs2dfortress00155.jpg

alt Re: Return flag to its Place

DarkLight66
User Off Offline

Zitieren
@user Jynxxx: i remember a friend "fixed" that glitch, just spawning another flag on the floor when someone leaves with it, so you´ll see the flag that was spawn, tought passing over it will trigger two "flag taken by ..." messages.

alt Re: Return flag to its Place

The Camo
User Off Offline

Zitieren
Well, I finally started on this part of script.I remade user Apache uwu's to something 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
function ctfe.returnflag(id)
	for _,key in ipairs(item(0,"table")) do
		if (player(id,"health"))>=1 then
			if (player(id,"team"))==1 then
			ttmpmoney={player(id,"money")}
			ttmppos={player(id,"x"),player(id,"y")}
				if item(key,"type")==70 then
				parse("setpos "..id.." "..(item(key,"x")*32).." "..(item(key,"y")*32))
				msg("©200200200ID "..id.." returns the flag. @C")
				end
			parse("setmoney "..id.." "..ttmpmoney[1])
			parse("setpos "..id.." "..ttmppos[1].." "..ttmppos[2])
			end
		end
		if (player(id,"health"))>=1 then
			if (player(id,"team"))==2 then
			cttmpmoney={player(id,"money")}
			cttmppos={player(id,"x"),player(id,"y")}
				if item(key,"type")==71 then
				parse("setpos "..id.." "..(item(key,"x")*32).." "..(item(key,"y")*32))
				msg("©200200200ID "..id.." returns the flag. @C")
				end
			parse("setmoney "..id.." "..cttmpmoney[1])
			parse("setpos "..id.." "..cttmppos[1].." "..cttmppos[2])
			end
		end
	end
end

user Apache uwu's
1
2
3
4
5
6
7
8
9
10
11
12
function ctfe.returnflag(team)
tmp=player(0,"team"..team.."living")
tmpmoney={player(tmp[1],"money")}
tmp2={player(tmp[1],"x"),player(tmp[1],"y")}
	for _,key in ipairs(item(0,"table")) do
		if item(key,"type")==69+team then
		parse("setpos "..tmp[1].." "..(item(key,"x")*32).." "..(item(key,"y")*32))
		end
	end
	parse("setmoney "..tmp[1].." "..tmpmoney[1])
	parse("setpos "..tmp[1].." "..tmp2[1].." "..tmp2[2])
end

Since I want it to be timed by ms100 hook Which has ctfe.returnflag(id) that starts it. But only works for 1vs1(like user Apache uwu's when timed - using 'ctfe.returnflag(team)') instead of 1+vs1+. Any ideas of why is this happening, or a fix, would be appreciated.

alt Re: Return flag to its Place

DC
Admin Off Offline

Zitieren
you can actually use cs2d cmd trigger to reset the flag entity - but this will only work if the flag entity has a name so you can trigger it. next version of cs2d will have the command cs2d cmd triggerposition which allows you to trigger every entity - but this is not implemented in the current version so you can't use it. you also have to remove the flag item then by using cs2d cmd removeitem (it has to be on the ground for this). you can use the Lua command cs2d lua cmd item to get a list of items and to find the flag item

alt Re: Return flag to its Place

The Camo
User Off Offline

Zitieren
So then I could use..

1
2
3
4
5
for _,key in ipairs(item(0,"table")) do
	if item(key,"type")==70 then
	parse("triggerposition "..(item(key,"x")*32).." "..(item(key,"y")*32))
	end
end

Will it remove guns and all other stuff people drop along with flag? I don't mind though, just asking.
Would have to use "spawnitem" with a table or "mp_deathdrop" 0 then 1 in a frame. would mp_deathdrop cause problems occasional?

alt Re: Return flag to its Place

Apache uwu
User Off Offline

Zitieren
@DC, using removeitem would completely remove it from play, no team can score now.

What about this?

triggeritem

Parameters

• item (0-X): id of an item on the map

Info
Trigger an item/weapon from the map (as server only).

So triggering a flag would return it.

alt Re: Return flag to its Place

The Camo
User Off Offline

Zitieren
@user Apache uwu:
Well, that would be only for flag then, would be easier to understand it if it is named "flagreturn" ..

But triggerposition seems it triggers every entity, not remove it. like, HEs will explode on touchdown, flags will be removed instantly, maybe rockets won't be able to pass.. who knows.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht