Forum

> > CS2D > Scripts > Kill message Script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Kill message Script

6 replies
To the start Previous 1 Next To the start

old Kill message Script

Jededias
User Off Offline

Quote
If CT (Neymar) Kill Terrorist (Messi)
A message appears in the middle of the screen
Neymar killed jason (Messi)

old Re: Kill message Script

THEMUD
User Off Offline

Quote
It can be done easily by using the kill hook.
Here it is:
1
2
3
4
5
6
addhook("kill", "_kill")
function _kill(id, victim, weapon, x, y)
	if player(victim, "team") == 1 and player(id, "team") == 2 then
		msg("Neymar killed jason (Messi)@C");
	end
end

Which I put the second statement of that if on a purpose.
So it implements a must, that it should work only if a Counter-Terrorist killed a Terrorist.

old Re: Kill message Script

GeoB99
Moderator Off Offline

Quote
@user THEMUD: Neymar and Messi are only examples.
1
2
3
4
5
function die_(victim, killer)
     msg(string.char(169).."255255255Player named "..player(victim, "name").." has been killed by "..player(killer, "name").." @C")
end

addhook("die","die_")
I used cs2d lua hook die instead of kill but it does the same effect.

old Re: Kill message Script

Mami Tomoe
User Off Offline

Quote
Try this one if you want too

1
2
3
4
5
6
7
addhook("kill","killmsg")

function killmsg(k,v)
	if k ~= nil and v ~= nil and k ~= v and v ~= k then
		msg("\169192192192"..player(k,"name").." killed "..player(v,"name"))
	end
end

old Re: Kill message Script

GeoB99
Moderator Off Offline

Quote
@user Mami Tomoe: Dunno why you defined killer and victim as opposite to nil, but you forgot to make it appear in the middle of the screen in your msg parameter.

P.S: You can use my code instead, there's no necessary for if statement and / or extra lines. Besides, such things like this is pretty basic and you could have doing that yourself.

old Re: Kill message Script

Cure Pikachu
User Off Offline

Quote
@user GeoB99: Actually for the cs2d lua hook die hook, you have to also check if the "killer" is actually a player that exists or not (A simple killer > 0 check will do), as I don't think player(0,"name") has a value.
cs2d lua hook die has written
killer is the player ID of the player who performed the kill (can also be 0 if the death was not caused by another player)

The cs2d lua hook kill hook is better for this scenario because you can bypass this check completely.

old Re: Kill message Script

GeoB99
Moderator Off Offline

Quote
@user Cure Pikachu: Oh yeah, I didn't actually pay lots of attention about this. Often, I used cs2d lua hook die than kill since it does same effect though it can also leads to unexpected behaviours if a player wasn't killed by an enemy.

Anyways, I guess he knows somehow how to replace the die hook with kill, the function name (optional) and so forth.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview