Hi , i tried to change the alpha of a View Model when i call a function
I tried this in the function :
if CLIENT then
ply:GetViewModel():SetRenderMode( RENDERMODE_TRANSALPHA )
ply:GetViewModel():SetColor( ColorAlpha( ply:GetViewModel():GetColor(), 50 ) )
end
But the weapon disappear and reappears less than a second after
Need help plz
Colors is something stored serverside. Try setting the color of any other prop or entity on client and you'll notice the same happens. You need to set it on serverside too.
I tried as you said :
if SERVER then
ply:GetViewModel():SetRenderMode( RENDERMODE_TRANSALPHA )
ply:GetViewModel():SetColor( ColorAlpha( ply:GetViewModel():GetColor(), 50 ) )
else
ply:GetViewModel():SetRenderMode( RENDERMODE_TRANSALPHA )
ply:GetViewModel():SetColor( ColorAlpha( ply:GetViewModel():GetColor(), 50 ) )
end
But it still doing the same thing
https://files.facepunch.com/forum/upload/154619/c7094d2e-b320-44ca-9124-4e4c0be63834/2018.02.03-17.35.mp4
Uh...
ply:GetViewModel():SetRenderMode( RENDERMODE_TRANSALPHA )
ply:GetViewModel():SetColor( ColorAlpha( ply:GetViewModel():GetColor(), 50 ) )
Just do that. You're running it twice for client and server when it's a shared file (i presume).
Also this might be helpful IsFirstTimePredicted
Oh, sorry i'm a beginner, but i came here to to ask for help because I searched a lot without success
But it it still doing the same thing :
https://www.youtube.com/watch?v=xla1QIwEvxY&feature=youtu.be
Are you running it with the lua_openscript_cl command?
No, it's a SWEP that i'm running on a server
local yourViewmodelMaterialPath = "models/weapons/v_models/pist_deagle/deagle_skin1"
function SWEP:PreDrawViewModel( vm ) -- Paint the deagle before drawing it
Material(yourViewmodelMaterialPath):SetFloat("$alpha", 0.5 )
end
function SWEP:PostDrawViewModel( vm ) -- Paint it back
Material(yourViewmodelMaterialPath):SetFloat("$alpha", 1 )
end
This example works for the css deagle. Change the path to your vmodel texture.
Or also try this:
local yourViewmodelMaterialPath = "models/weapons/v_models/pist_deagle/deagle_skin1"
function SWEP:PreDrawViewModel( vm ) -- Paint the deagle before drawing it
render.SetBlend(0.5)
end
function SWEP:PostDrawViewModel( vm ) -- Paint it back
render.SetBlend(1)
end
Thanks, the second code worked !
Sorry, you need to Log In to post a reply to this thread.