Forum

> > CS2D > Scripts > Screen after killing
Forums overviewCS2D overview Scripts overviewLog in to reply

English Screen after killing

10 replies
To the start Previous 1 Next To the start

old Screen after killing

tos12345678
User Off Offline

Quote
I need some help.
Script which will reveal blue screen (e.g. block.bmp - blue) for a moment on the player screen when he killed someone player.
after this, blue screen should then slowly disappear untill moment in which block.bmp full vanish/die.

old Re: Screen after killing

Casper-
User Off Offline

Quote
To understand a bit better :

When someone kills a player,
that someone gets the blue (fullscreen?) screen.
When he gets that screen, it will slowly fade away like a flashbang ?

old Re: Screen after killing

Rainoth
Moderator Off Offline

Quote
1. use cs2d lua cmd image with mode as HUD image
2. set alpha to 0
3. use cs2d lua hook kill hook and in the function attached to it:
3.1 set alpha to 1
3.2 use cs2d lua cmd tween_alpha to bring it back to 0

I did not use tween_alpha enough to know so I'll just make an assumption that you might run into problems when you kill during the timeframe of tween_alpha and run a new tween_alpha (Say your image disappears in 3 seconds and you kill someone during that time. You'd probably want to have the image at full alpha and then reduce it again from the beginning but the old call to tween_alpha might still be running or not). If this assumption is wrong, the solution above should work, otherwise, you'll need to have a variable for alpha and then use cs2d lua cmd imagealpha with a time hook to reduce alpha "manually".

Good luck.

old Re: Screen after killing

Masea
Super User Off Offline

Quote
This would do:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
parse("mp_hudscale 1")

timeToFade = 1000 --1000 = 1 second.
screenColour = {0, 0, 0}

--To make sure the given ID be a number since timers do give output as string far as I remember
_freeimage = freeimage
function freeimage(id)
    tonumber(id)

    _freeimage(id)
end

addhook("kill", "_kill")
function _kill(killer)
    local blueScreen = image("gfx/block.bmp", 425, 240, 2, id)
    imagecolor(blueScreen, unpack(screenColour))
    imagescale(blueScreen, 27, 15)
    tween_alpha(blueScreen, timeToFade, 0)
    timer(timeToFade, "freeimage", blueScreen)
end
You can either change
timeToFade
or
screenColour
variables for your own taste.

old Re: Screen after killing

Bowlinghead
User Off Offline

Quote
You forgot to declare "id" in kill hook.
A little change in line 15 should do:
1
function _kill(killer,id)

And did you just overwrite a Cs2D function? You are a bad boy!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview