Or is that piece of lua missing?
Thanks.
-Camo
Scripts
Return flag to its Place
Return flag to its Place
1

Yates has written
DC has written
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

Apache uwu: Can you add that as a command to TLex would be great, because when some people have the flag, they just leave and it is hard to find
Apache uwu:
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.
Apache uwu's to something like this: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
Apache uwu'sfunction 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
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.
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
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
removeitem (it has to be on the ground for this). you can use the Lua command
item to get a list of items and to find the flag item 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
item (0-X): id of an item on the map
Apache uwu:
1
