player.Alpha

Started by KAKAN, Oct 07, 2015, 08:40 AM

Previous topic - Next topic

KAKAN

Hmm, if player.Alpha is set to 0, then the player would be invisible, if set to 255, it would be normal.
So, I want something which can gently reduce the alpha, I thought a way, but it would use many timers, so thought not to use it.
Any ways to do it?
oh no

DizzasTeR

local playerAlpha = array( GetMaxPlayers(), null );

function onPlayerCommand( i_Player, str_Command, Arguments )
{
    if( str_Command == "alpha" ) { playerAlpha[ i_Player.ID ] = NewTimer( "polatePlayerAlpha", 1000, 0, i_Player.ID ); }
}

function polatePlayerAlpha( id_Player )
{
    local i_Player = FindPlayer( id_Player );
    if( i_Player )
    {
        if( i_Player.Alpha <= 0 ) { playerAlpha[ i_Player.ID ].Delete(); return }
        i_Player.Alpha = i_Player.Alpha - 1;
    }
}

Just an example so you should know that there is no need of "too many timers" just to do a simple thing.

Human.

player.SetAlpha( 0, 5000 );For 5 seconds.

EK.IceFlake

By the way, SetAlpha:
CPlayer.SetAlpha(int alpha, int time_ms);

KAKAN

Quote from: Human. on Oct 07, 2015, 11:49 AMplayer.SetAlpha( 0, 5000 );For 5 seconds.
I never asked about this. Anyways thanks.
Quote from: NE.CrystalBlue on Oct 07, 2015, 11:51 AMBy the way, SetAlpha:
CPlayer.SetAlpha(int alpha, int time_ms);
nor this^^

Quote from: Doom_Killer on Oct 07, 2015, 10:51 AM<snip>
Just an example so you should know that there is no need of "too many timers" just to do a simple thing.
Thanks a lot.!
Locked, Solved
oh no

Thijn

Quote from: KAKAN on Oct 07, 2015, 01:16 PM
Quote from: Human. on Oct 07, 2015, 11:49 AMplayer.SetAlpha( 0, 5000 );For 5 seconds.
I never asked about this. Anyways thanks.
Quote from: NE.CrystalBlue on Oct 07, 2015, 11:51 AMBy the way, SetAlpha:
CPlayer.SetAlpha(int alpha, int time_ms);
nor this^^
Why not? Why on earth would you use a timer for this if it's build in?
If you want to make it take longer for higher Alpha you can just do something like floor((player.Alpha / 255) * 5) which will mean 5 seconds for 255 and gently reduced for lower for that.