Forum

> > CS2D > Scripts > New Shield System
Forums overviewCS2D overview Scripts overviewLog in to reply

English New Shield System

3 replies
To the start Previous 1 Next To the start

moved New Shield System

PhantomZ
User Off Offline

Quote
Hello there my name is PhantomZ

I have 1 idea Umm...

Shield can break by any gun

Shield heath : 200

M4A1 HIT : 30 (200-30= 170 :D)

AK47 HIT: 27

If u have any idea

Comment

Admin/mod comment

Wrong section entry. Moved! / user GeoB99

old Re: New Shield System

Yunuu
User Off Offline

Quote
i do this before but a bit different you can edit it and use cs2d cmd strip


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
dmg = 1
ho = {}


addhook("join","jh")
function jh(id)
ho[id] = 0
end
addhook("second","sch")
function sch()
for _,id in pairs(player(0,"tableliving")) do
if ho[id]>0 then
ho[id]=ho[id]-0.5
parse("sethealth "..id.." "..(player(id,"health")-dmg).."")
parse("shake "..id.." 1")
end
end
end


addhook("shieldhit","shh")
function shh(id,sc,wp,a)
if wp == 46 then
ho[id] = ho[id] + 0.5
end
end


addhook("drop","dh")
function dh(id,iid,typ)
if typ == 41 then
ho[id] = 0
end
end

old Re: New Shield System

Rainoth
Moderator Off Offline

Quote
@user PhantomZ: Begin by taking a number and changing it. That will be your first edit √
I suppose it's a bit too advanced if you're completely fresh on the topic. In that case, you should look at samples in your CS2D folder as well as thread cs2d [GUIDE] How to script.

I'll provide you an example of what I think should work but it won't do you any good if you don't understand it when you'll want to make something else.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
shield = {}
addhook("spawn","_s")
function _s(id)
	shield[id] = 200 -- *
	return 41
end

addhook("shieldhit","_sh") -- sh is the name of function that is called whenever the shield is hit
function _sh(id,source,weapon,direction,objectID)
	shield[id] = shield[id] - itemtype(weapon,"dmg")
	if shield[id] <= 0 then
		parse("strip "..id.." 41")
	end
end
* - assuming player gets a shield on spawn

The script doesn't handle these points when you pick/drop the shield and works regardless of direction the shield is hit from.

I might make a proper script when I have time since it's a pretty neat idea or someone else might.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview