Forum

> > CS2D > Scripts > Kill with granate...
Forums overviewCS2D overview Scripts overviewLog in to reply

English Kill with granate...

14 replies
To the start Previous 1 Next To the start

old Kill with granate...

Sudden Death
User Off Offline

Quote
Hello i try to make script, and i got problem <look title>
here script:
1
2
3
4
5
6
7
8
addhook("die","killexp")
function killexp(id,killer,weapon)
exp[killer]=exp[killer]+100
if player(killer,"weapon")==51 then
exp[killer]=exp[killer]+50
msg2(killer,"©250000000Killed with granate! Bonus 50exp!")
end
end
and whats don't work: when i kill with he then i don't have that granate, and script think i kill with knife i think that should be no if player weapon but weapon with what player kill, but no idea how to write it ::
plis help

old Re: Kill with granate...

Surplus
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("die","killexp")
	function killexp(id,killer,weapon)
		if player(killer,"weapon")==51 then
			exp[killer]=exp[killer]+150
			msg2(killer,"©250000000Killed with grenade! Bonus 50exp!")
		end
		elseif player(killer,"weapon")~=51 then
			exp[killer]=exp[killer]+100
		end
	return 0
end

Might work. Prob. Wrong

old Re: Kill with granate...

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("die","killexp")
     function killexp(id,killer,weapon)
          if weapon==51 then
               exp[killer]=exp[killer]+150
               msg2(killer,"©250000000Killed with grenade! Bonus 50exp!")
          end
          else
               exp[killer]=exp[killer]+100
          end
     return 0
end

No?

old Re: Kill with granate...

Sudden Death
User Off Offline

Quote
@Engin33r no no no you think bad, its same what write PartyPooPer, its got problem when player throw he granade then he lose it, script see player got knife and when player is killed then got bonus point for killing with knife

@DarkLight66 Yes, I try but then lua don't work like what i want :l

Edit: Don't waste your time guys i try to make it myself

old I think i solved it.

troctor
User Off Offline

Quote
> I DONT KNOW IF YOU ALREADY SOLVED IT

Well.. try with this..

I replaced this things:

(I dont know if this is really necessary, but i always put the original parameters)
Function fix has written
function killexp(id,killer,weapon)

To

function killexp(victim,killer,weapon,x,y)

------------------------------------

Now you won't use "id" you will use "victim" (That is the guy who died)



(I think this make all your problems)
Killer ERROR fix has written
if player(killer,"weapon")==51 then

To

if weapon==51 then

------------------------------------

The problem is that in the parameters you ALREADY have "weapon" so you only need to put weapon==51 and it will take it that the killer weapon.
The problem with "weapontype" is because when u fire the grenade, you get setted the knife, and when the lua watches your weapontype (when you dont have the grenade because you fired it) you have the knife and it reads it like weapon==50.


Now try with this:

1
2
3
4
5
6
7
8
addhook("die","killexp")
function killexp(victim,killer,weapon,x,y)
	exp[killer]=exp[killer]+100
	if weapon==51 then
		exp[killer]=exp[killer]+50
		msg2(killer,"©250000000Killed with granade! Bonus 50exp!")
	end
end

Quote
ATTENTION: Remember that the word is "grenade" not "grenate"


I deleted the "exp" things to test it, and it works well with the grenade, i hope it works for you

Tell me how it works
edited 1×, last 16.11.11 12:59:14 am

old Re: Kill with granate...

Apache uwu
User Off Offline

Quote
Why not use the kill hook instead?

1
2
3
4
5
6
7
8
9
addhook("kill","_kill")

function _kill(killer,victim,weapon)
	exp[killer]=exp[killer]+100
	if weapon==51 then
		exp[killer]=exp[killer]+50
		msg2(killer,"©250000000Killed with grenade! Bonus 50exp!")
	end
end

Oh and PartyPooper, you ended the if statement, so you can't use else :).

old Re: Kill with granate...

Apache uwu
User Off Offline

Quote
So reverse the logic.

1
2
3
4
5
6
7
8
9
addhook("die","killexp")

function killexp(victim,killer,weapon)
	exp[killer]=exp[killer]+100
	if weapon==51 then
		exp[killer]=exp[killer]+50
		msg2(killer,string.char(169).."250000000Killed with grenade! Bonus 50exp!")
	end
end

The reason your script fails is because you're checking the killer's weapon after he throws the grenade-the weapon is most likely the knife or the primary weapon.

If you check the weapon that the death was caused by it should work.

old Re: Kill with granate...

EngiN33R
Moderator Off Offline

Quote
Derp, I wrote exactly what Troctor wrote and was told that it was incorrect? What the hell man? Are you blind or stupid?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview