English Deagle HP Script Wrong

6 replies
Goto Page
To the start Previous 1 Next To the start
07.07.11 07:35:04 pm
Up
KaTiL
User
Offline Off
What's wrong?
Code:
1
2
3
4
5
6
addhook('hit', 'hp')
function hp(id,wpn)
if wpn = 3 then
parse("sethealth "..id.." "..player(id,"health")+25)
end
end


>Help me
07.07.11 08:18:33 pm
Up
EngiN33R
Moderator
Offline Off
Code:
1
2
3
4
5
6
addhook('hit', 'hp')
function hp(id,src,wpn)
if wpn = 3 then
parse("sethealth "..id.." "..player(id,"health")+25)
end
end


You have to keep the order of the arguments, if e.g. you have the arguments id,src,wpn you can't throw away src.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
07.07.11 09:44:26 pm
Up
IWhoopedPythagoras
BANNED
Offline Off
user EngiN33R has written:
Code:
1
2
3
4
5
6
addhook('hit', 'hp')
function hp(id,src,wpn)
if wpn = 3 then
parse("sethealth "..id.." "..player(id,"health")+25)
end
end


You have to keep the order of the arguments, if e.g. you have the arguments id,src,wpn you can't throw away src.


Don't forget the difference between = and ==. A beginner mistake that many people overlook.
07.07.11 10:39:14 pm
Up
EngiN33R
Moderator
Offline Off
@IWhoopedPythagoras
Whoops, you're right, didn't see that. Thanks for fixing.

The final code:
Code:
1
2
3
4
5
6
7
addhook('hit', 'hp')
function hp(id,src,wpn)
     if wpn == 3 then
          parse("sethealth "..id.." "..player(id,"health")+25)
          return 1
     end
end


Spoiler >
edited 2×, last 07.07.11 10:52:45 pm
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
07.07.11 10:50:48 pm
Up
Unknown_Soldier
User
Offline Off
user EngiN33R, The final code is your first code with tabbing, the "==" mistake is still there

btw that script should heal your teammates (with Friendly fire off, since you can't damage allies) but will reduce the damage of the deagle if you shoot the enemy, I don't know what is the purpose of this script.
Should I come back and make one last map for CS2D?
07.07.11 10:54:03 pm
Up
EngiN33R
Moderator
Offline Off
I'm sorry Unknown, I'm malfunctioning when it gets midnight and when I only got 5 hours of sleep. I also put a return 1 to negate the actual hurting damage.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
08.07.11 12:03:38 am
Up
KaTiL
User
Offline Off
Thank you .
Work!
To the start Previous 1 Next To the start