Forum

> > CS2D > Scripts > Lua Question - Knife Kill Hook
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Question - Knife Kill Hook

16 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Lua Question - Knife Kill Hook

Anders4000
User Off Offline

Zitieren
Hello! (:

I've made a kill where a variable get increased by 1 and equip some things, when you kill one with knife. (if weapon is knife)
But it only works when i rightclick with the knife, and there is no errors in console, any ideas?
Here is the script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
parse("mp_wpndmg knife 100")
parse("mp_wpndmg_z1 knife 100")
BulletsPos		= "50 65"
Bullets = Array(game("sv_maxplayers"),StartingBullets)

addhook("kill","OnKill")
function OnKill(killer)
	Bullets[killer] = Bullets[killer] + 1
	parse("equip "..killer.." 3")
	parse("setweapon "..killer.." 3")
	parse('hudtxt2 '..killer..' 4 "©000255000Bullets: '..Bullets[killer]..'" '..BulletsPos)
	for b = 1, game("sv_maxplayers"), 1 do
		if Lives[b] == 0 then
			if #player(0,"tableliving") == 1 then
				AutoSpec(killer)
				NextMap()
			end
		end
	end
end

Only posted the importent code...
Tell me if it's not enough.

Thanks in advance!
- Anders4000
1× editiert, zuletzt 06.01.11 18:11:19

alt Re: Lua Question - Knife Kill Hook

Geez
GAME BANNED Off Offline

Zitieren
== EDIT 11.01.2011 ==

Moved to another topic.


Original post:
Mehr >
1× editiert, zuletzt 11.01.11 20:09:56

alt Re: Lua Question - Knife Kill Hook

Anders4000
User Off Offline

Zitieren
@Headhunter, my idea is that i want 1 more bullet when i kill someone with knife, or any weapon. But if i knife, it only works if i rightclick...

@Qrchack, I could make it, but it will be when i'm done with my One in the Chamber mod.
So if you don't wanna wait, ask Blazzing, maybe he want some work (:

You could ask out loud on the Script forum too
1× editiert, zuletzt 06.01.11 21:39:15

alt Re: Lua Question - Knife Kill Hook

Banaan
User Off Offline

Zitieren
I have the feeling that this is not all of the (for this problem) important code. The thing where it goes wrong, the weapon checking, is not included in the snippet you posted. So we can't help you.

alt Re: Lua Question - Knife Kill Hook

Anders4000
User Off Offline

Zitieren
There is no weapon check
Cus it's the deagle and knife that gives extra bullet, everything else is stripped on spawn (:
So there is no need for a weaponcheck..

Sry i made wrong @s in my last post :p

alt Re: Lua Question - Knife Kill Hook

Lee
Moderator Off Offline

Zitieren
Anders4000 hat geschrieben
That doesn't matter, there is no check code!


If you still want to have only knife-2 trigger the event, this is how:

1
2
3
4
5
6
7
8
9
10
11
12
13
att2 = {}
addhook("attack2", "att2_on")
function att2_on(id) att2[id] = true end

addhook("attack", "att2_off")
function att2_off(id) att2[id] = false end

addhook("kill", "knife2_kill")
function knife2_kill(id, v, w)
	if w == 50 and att2[id] then
		-- Code to give bullets and etc
	end
end

alt Re: Lua Question - Knife Kill Hook

Lee
Moderator Off Offline

Zitieren
Anders4000 hat geschrieben
Sorry man, I think you can't understand me I want Knife1 to work with my hook. Hook only get executed on Knife2 but i want it on Knife1 too!


That's impossible, either you're doing something wrong or you've used the wrong hooks.

alt Re: Lua Question - Knife Kill Hook

Anders4000
User Off Offline

Zitieren
Lol.. So it's not possible to have an event executed on a simple knife kill, Hmm s:
That sucks?
Gonna try to make a new script only with Killhook now, and see if i can get that working.

EDIT:
I fixed it. When you hold down mousekey1 you automaticly fire 1 shot when you get the pistol equiped. So i have to give the player 2 shots instead of 1 when he kill with knife.
It will be a problem though. Cus if the player kills 1 with knife he automaticly gets the pistol equiped, fires 1 shot, and the other now know where he is if they listen. He will still have 1 shot left though, because he gets 2 bullets for the knife kill with mouse1.

Confusing i know, sorry
- Anders4000

Ps. Thanks for the post with the kill1 or kill2 hooks Lee, I will be using them, so the player only get 1 bullet when "Rightclick Knifing" (:

EDIT2:
Ohh x.x Things just still don't wanna work :p
4× editiert, zuletzt 08.01.11 16:15:23

alt Re: Lua Question - Knife Kill Hook

KimKat
GAME BANNED Off Offline

Zitieren
Perhaps this Lua script works...
1
2
3
4
5
6
7
8
9
10
addhook("kill","kill_event")
function kill_event(killer,victim,weapon,x,y)
	if (player(killer,"exists")) then
		if(weapon == 50) then
			-- code
		end
	elseif (player(victim,"exists")==false) then
		-- do nothing
	end
end
This Lua script will check if the killer exists then also checks if the killer has weapon knife equipped and then the code will execute. But if there is no victim on kill script will do nothing, in example; if the victim leaves server or something. This will work using both attack(left click) and attack2(right click).

I am not entirely sure it works but my logic tells me it will. Lol.

alt Re: Lua Question - Knife Kill Hook

Anders4000
User Off Offline

Zitieren
Hah, i've just f*cked it all up, everything is a mess and now bullets starts to count down and such when i knife with leftclick

If there is a kind person who has no life, go ahead and look through my code

Mehr >


PS. DC get those tabing errors fixed, and allowed more than 1 space in a row in [ code ] tags (:
(Gonna keep remind you untill you fix it xD)
2× editiert, zuletzt 10.01.11 15:16:04

alt Re: Lua Question - Knife Kill Hook

DannyDeth
User Off Offline

Zitieren
Anders4000 hat geschrieben
@Qrchack, I could make it, but it will be when i'm done with my One in the Chamber mod.
So if you don't wanna wait, ask Blazzing, maybe he want some work (:

A: Blazz doesn't have that much spare time, he is already working on 2 projects ( last time I checked, that is ).
B: It isn't that complex, lol. You don't need some expert to do it for you.

alt Re: Lua Question - Knife Kill Hook

Anders4000
User Off Offline

Zitieren
DannyDeth hat geschrieben
Anders4000 hat geschrieben
@Qrchack, I could make it, but it will be when i'm done with my One in the Chamber mod.
So if you don't wanna wait, ask Blazzing, maybe he want some work (:

A: Blazz doesn't have that much spare time, he is already working on 2 projects ( last time I checked, that is ).
B: It isn't that complex, lol. You don't need some expert to do it for you.


Heh.. Blazzing is just the only moddername I remember (: Could have told him to just ask another 1... But I didn't :s


∗√ EDIT:

What does the parameter "mode" do in the function Attack2 do? There is no explanation in the info.txt file (:
1× editiert, zuletzt 12.01.11 20:14:24
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht