English What is wrong with this script?

3 replies
Goto Page
To the start Previous 1 Next To the start
Up
Jenko63
User
Offline Off
Code:
1
2
3
4
5
6
addhook("attack","attack")
function attack(killer,victim)
if killer ~= victim then
parse("setmaxhealth "..victim.." 100")
end
end


what is wrong with this script?
JENKO
05.06.18 03:53:10 pm
Up
Rainoth
Moderator
Offline Off
"attack" hook only supplies the "id" of the person who made the attack. It does not supply the id of killer or victim because these things don't happen during "attack" but during the "kill".
If you want this to work, you should replace "attack" with "kill" or "die", whichever you prefer.

Additionally, you'd set max health of the person who dies to 100.
This won't achieve any effect unless you modified max health values before that with other conditions.
05.06.18 04:09:14 pm
Up
Jenko63
User
Offline Off
@user Rainoth:

Thanks
JENKO
06.06.18 01:38:43 am
Up
Masea
Super User
Offline Off
In fact, nothing is wrong with this script but the knowledge of yours. Why you ended up seeing no differences is because the players have default 100 max health anyway.

Also, I want to plus to user Rainoth's suggest. I'd rather go for cs2d lua hook hit hook which however will make god mode on for the victim and pretty sure you don't want something like this.

We could've been more helpful if you had mentioned what you actually want.

And by the way that if statement is almost for nothing unless friendly fire is enabled.
Create and design your GUI easy and fast: file cs2d GUI Framework (12) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
To the start Previous 1 Next To the start