Forum

> > CS2D > General > Help with Healing Gun Lua Script
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Help with Healing Gun Lua Script

6 replies
To the start Previous 1 Next To the start

old closed Help with Healing Gun Lua Script

ProNoob
User Off Offline

Quote
Well, I wanted to make a Healing Gun for my server, but I can't seem to get it right.
Can someone tell me what's wrong on this?:
1
2
3
4
5
6
7
8
addhook("hit","heal")
function heal(id,source,weapon,hpdmg,apdmg)
     if (weapon==3) then
          if player(id,"team")==player(source,"team") then
		parse("sethealth "..id.." player(id,"health")+50")
          end
     end
end

Admin/mod comment

use the lua scripting thread! closed! /DC

old Re: Help with Healing Gun Lua Script

Mawd
User Off Offline

Quote
theres something wrong with the "heal" thing at the start, i think it should be a weapon name.
1
2
3
4
5
6
addhook("hit","deagle") 
	function deagle(id,source,weapon,hpdmg,apdmg) 
 	    if(weapon == 3) then 
parse ("sethealth "..id.." "..player(id,"health")+10) 
  	   end 
end

made a lua, here you go.
edited 1×, last 30.08.10 03:19:59 am

old Re: Help with Healing Gun Lua Script

ProNoob
User Off Offline

Quote
Mod has written
theres something wrong with the "heal" thing at the start, i think it should be a weapon name.
1
2
3
4
5
6
addhook("hit","deagle") 
	function deagle(id,source,weapon,hpdmg,apdmg) 
 	    if(weapon == 3) then 
parse ("sethealth "..id.." "..player(id,"health")+10) 
  	   end 
end

made a lua, here you go.


Didn't work.
'Heal' is the function name, it can be anything. It doesn't affect the script's behavior.

old Re: Help with Healing Gun Lua Script

Flacko
User Off Offline

Quote
Replace this line
1
2
3
parse("sethealth "..id.." player(id,"health")+50")
--BY THIS ONE
parse("sethealth " .. id .. " " .. (player(id,"health")+50))
You messed up the quotes

old Re: Help with Healing Gun Lua Script

ProNoob
User Off Offline

Quote
Flacko has written
Replace this line
1
2
3
parse("sethealth "..id.." player(id,"health")+50")
--BY THIS ONE
parse("sethealth " .. id .. " " .. (player(id,"health")+50))
You messed up the quotes


I still get this on the console:
LUA ERROR: attempt to call a nil value

Every time I try to shoot someone.

old Re: Help with Healing Gun Lua Script

Flacko
User Off Offline

Quote
Make sure the function name matches the second parameter of addhook()

Or try to copy paste this script

1
2
3
4
5
6
7
addhook("hit","_hit")
function _hit(id,src,w)
	if player(id,"team") == player(src,"team") and w==3 then
		parse("sethealth "..id.." ".. player(id,"health")+50)
		return 1
	end
end
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview