Alpha color player

Hi, FacePunch.
Again I ask at you for help.
It is a script doesn’t work correctly.
The player doesn’t become transparent.



local function skinalfa( ply )
        ply:SetPlayercolor( Color( 0, 17, 255, 100 ):ToVector( ) );
end
		
hook.Add( "PlayerSetModel", "skinalfa", skinalfa );


p.s mcd1992 - Dumb

You have to set their render mode, add this to your code:

[lua]
ply:SetRenderMode( RENDERMODE_TRANSALPHA )
[/lua]

As seen here: http://wiki.garrysmod.com/page/Enums/RENDERMODE

Also, I think you want to use ply:SetColor instead of ply:SetPlayerColor, since the latter doesn’t affect transparency.



local function skinalfa( ply )
        ply:SetColor( Color( 0, 17, 255, 100 ) );


ply:SetRenderMode( RENDERMODE_TRANSALPHA )

end
		
hook.Add( "PlayerSetModel", "skinalfa", skinalfa );


[editline]14th April 2015[/editline]

Doesnt work. =(

(SetPlayerColor … not SetPlayercolor) btw

But that is not how SetPlayerColor works (I think).
SetPlayercolor sets the mask color of the player-texture (r,g,b)
SetColor draws the material (r,g,b,a)
So you need todo:



ply:SetRenderMode( RENDERMODE_TRANSALPHA )
ply:SetColor(Color(255,255,255,<Any alpha>))

It doesn’t work



local function skinalfa( ply )

ply:SetRenderMode( RENDERMODE_TRANSALPHA )
ply:SetColor(Color(255,255,255,50))
		
end
		
hook.Add( "PlayerSetModel", "skinalfa", skinalfa );


Works for me. Run it server side.

It and so Run server side

[editline]14th April 2015[/editline]

I found a problem: The matter is that it works in the SandBox mode. A in the ZombieSurvival mode - doesn’t work. How to correct?

Something in ZombieSurvival is setting the player’s color after you are. Add the code inside the hook into a timer with a really small delay (eg, 0.1 ).



local _time = "0.1"; --Protection in seconds for the human

local function skinalfa( ply )
timer.Simple( _time, function()
ply:PS_Notify( "Защита выключена!" )
ply:PS_Notify( "Защита выключена!" )
ply:SetRenderMode( RENDERMODE_TRANSALPHA )
ply:SetColor(Color(255,255,255,50))
end)
end
		
hook.Add( "PlayerSetModel", "skinalfa", skinalfa );


Doesn’t work in ZombieSurvial

timer.Simple doesn’t take a string as the first argument.

I tried it and with digit

What’s the error?

There are no errors

Have you tried increasing the delay?

Yes

It’s possible that ZombieSurvival is setting the playercolor in a think hook. If you send me the source code I can look through the code and tell you what you need to change.



local alpha = 50 -- 0-255
hook.Add("PrePlayerDraw","Potatos",function(ply)
        render.SetBlend(alpha/255) -- 0-1
end)
hook.Add("PostPlayerDraw","PotatosPost",function(ply)
        render.SetBlend(1)
end)


If that doesn’t work … then idk what will.

You very much will help me.
http://forum.facepunch.com/showthread.php?t=1160198

Have you tried the post above’s solution first?

Have you tried not using ; in gLua