Material on Player

Is it possible to put a material on a player? Like if I wanted to pull out a knife and right click to make me semi-invisible. I want to know about material not 255.255.255.0. I want to apply a material to the player, and also for it to work in multilayer.

Yes you can set materials to players.

could you give me an example of a player one and not a prop_physics one?

No, it’s exactly the same. Get a player object and call the function on it.

Player object? Sorry I am not to good at remembering all the lua things. please explain in more detail.

[lua]Player:SetMaterial( “models/shiny” );
Player:SetColor( 0, 0, 200, 255 );[/lua]

Will result in:

http://img11.imageshack.us/img11/8002/shinyr.png

Hope this helps.

[lua]
local plobj = player.GetAll()[ 1 ]
// Get the player who’s EntIndex is 1.
// Doing things to this variable will effect that player

plobj:SetMaterial( “dir” )
// Change that player’s material

// Using the format ‘Variable : (colon) Function’ is called a meta or meta function
// and is also a shortcut to ‘metatable . (dot) Function ( Variable )’

[/lua]

By the way I forgot to mention, if you’re making knife (so your own SWEP) then to get the Player object you get the SWEP’s owner self:GetOwner();

so:

[lua]
local Owner = self:GetOwner();
Owner:SetMaterial( “models/shiny” );
[/lua]

ok, it works Great! but now I need it to toggle on/off, and to turn off when the player dies.

would is be like

If owner dies then
bahbah

??

[editline]04:32AM[/editline]

I would also like to so something like this. (taken from Conna’s Tools - Cloaking Tool)
[lua]
function TOOL.TakeDamage(Entity, Attacker, Inflictor, Damage)
if (Entity.Cloaking and Entity.Cloaking.Cloaked) then
if (Entity.Cloaking.Flicker) then
Cloaking.Deactivate(Entity)

			timer.Simple(0.05, Cloaking.Activate, Entity)
		end

[/lua]

Could I do this but only for a player/owner?

Thanks