Forum

> > CS2D > Scripts > Team build lua
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Team build lua

9 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Team build lua

RIP-HereRestsPlookerbooy
BANNED Off Offline

Zitieren
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..

alt Re: Team build lua

GeoB99
Moderator Off Offline

Zitieren
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?

alt Re: Team build lua

Cure Pikachu
User Off Offline

Zitieren
@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 >
1× editiert, zuletzt 03.12.15 22:09:39

alt Re: Team build lua

_Yank
User Off Offline

Zitieren
@user Cure Pikachu: There's a quickier way to achieve that,
1
parse("damageobject "..o.." -"..math.abs(d).." "..p)
Just a quick tip
1× editiert, zuletzt 03.12.15 18:19:01

alt Re: Team build lua

RIP-HereRestsPlookerbooy
BANNED Off Offline

Zitieren
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht