Adding a tint overlay (fade user message?) on player's screen

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Adding a tint overlay (fade user message?) on player's screen

Postby Mahi » Tue Jun 30, 2015 9:35 pm

Say I want to make player's screen "bloody" by adding a red tint to it, how would this be done?

In eventscripts I would add a tint like so:

Code: Select all

es usermsg fade event_var(userid) 0 500 482 255 0 0 150
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Jun 30, 2015 10:32 pm

The Fade class has been a part of the messages package since its creation. I did test using the numbers you have, but I am receiving errors. So, I lowered the 500 and 482 down to 5 and 2, and it worked like a charm:

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))

If you do not want any fade-in, fade-out, or modulate, do not pass any flags, as in the example above. If you wish to fade-out, use the following (fade-in and modulate are very similar):

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, flags=Fade.FFADE_OUT, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))
Image
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Tue Jun 30, 2015 10:43 pm

satoon101 wrote:The Fade class has been a part of the messages package since its creation. I did test using the numbers you have, but I am receiving errors. So, I lowered the 500 and 482 down to 5 and 2, and it worked like a charm:

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))

If you do not want any fade-in, fade-out, or modulate, do not pass any flags, as in the example above. If you wish to fade-out, use the following (fade-in and modulate are very similar):

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, flags=Fade.FFADE_OUT, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))
Ah, didn't find the Fade class with GitHub's search function, must've failed something cause I find it now... But thank you very much, looks awesome! :)
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 01, 2015 6:35 pm


Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 133 guests