Forum

> > CS2D > Scripts > Team build lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Team build lua

9 replies
To the start Previous 1 Next To the start

old Team build lua

RIP-HereRestsPlookerbooy
BANNED Off Offline

Quote
I was doing a lua that repair/upgrade my build if my teammate hit my build but i stucked here...

1
2
3
4
5
6
7
8
9
10
11
function hc.teammate.team_objectdamage_hook(o,d,p)
	local t = player_team(p)
	if t then
		for id, _ in pairs(server_team[t].members) do
			if object(o,"player") == id then	
				parse("damageobject "..o.." "..d.." "..p)
				return 1
			end
		end
	end
end

Can you help me with it? please..

old Re: Team build lua

GeoB99
Moderator Off Offline

Quote
1
2
parse("damageobject "..o.." "..d.." "..p)
return 1
The "return 1" is completely useless as cs2d cmd damageobject doesn't return any kind of values so you have to remove it. And by the way, what exactly it doesn't work? Would you mind check the Console if it prints a LUA ERROR message?

old Re: Team build lua

Cure Pikachu
User Off Offline

Quote
@user GeoB99: The return 1 is for what I think is the cs2d lua hook objectdamage hook, not the cs2d cmd damageobject command itself.

My version:
1
2
3
4
5
6
7
8
9
10
11
12
13
-- addhook("objectdamage","hc.teammate.team_objectdamage_hook")
-- I am assuming you already have the hook, but if you don't, remove the first two --
function hc.teammate.team_objectdamage_hook(o,d,p)
	if object(o,"type") > 0 and object(o,"type") < 16 then
		if math.min(object(o,"team"),2) == math.min(player(p,"team"),2) then
			-- local fd = d
			-- if fd > 0 then fd = (d * -1) end
			-- parse("damageobject "..o.." "..fd.." "..p)
			parse("damageobject "..o.." -"..math.abs(d).." "..p)
			return 1
		end
	end
end
Like what user Talented Doge said, cs2d cmd damageobject can't upgrade objects, but can repair damaged buildings, except there's this problem:
Error >
edited 1×, last 03.12.15 10:09:39 pm

old Re: Team build lua

_Yank
User Off Offline

Quote
@user Cure Pikachu: There's a quickier way to achieve that,
1
parse("damageobject "..o.." -"..math.abs(d).." "..p)
Just a quick tip
edited 1×, last 03.12.15 06:19:01 pm

old Re: Team build lua

RIP-HereRestsPlookerbooy
BANNED Off Offline

Quote
So,its impossible or not?

Here's is the code:

1
2
3
4
5
6
7
8
function hc.teammate.team_objectupgrade_hook(o,p,pr,t)
	msg("Upgrade value") 
	msg(object(o,"upgrade")+1)
	parse("damageobject "..o.." -1 "..p)
	msg("Needed")
	msg(t)
	return 1
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview