Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TOOL.Category = "Render"
- TOOL.Name = "Ragdoll color"
- TOOL.ClientConVar[ "r" ] = 255
- TOOL.ClientConVar[ "g" ] = 0
- TOOL.ClientConVar[ "b" ] = 255
- TOOL.ClientConVar[ "multi" ] = 1
- if CLIENT then
- language.Add("ragdollcolor", "Ragdoll color")
- language.Add("tool.ragdollcolor.name", "Ragdoll color")
- language.Add("tool.ragdollcolor.desc", "Set a color for that ragdoll")
- language.Add("tool.ragdollcolor.0", "Apply the color")
- end
- if SERVER then
- util.AddNetworkString("SendToRagdollClient")
- end
- net.Receive("SendToRagdollClient",function()
- local tbl = net.ReadTable()
- local color = tbl[2]
- tbl[1].GetPlayerColor = function() return Vector( color.r/255*LocalPlayer():GetInfo("ragdollcolor_multi"), color.g/255*LocalPlayer():GetInfo("ragdollcolor_multi"), color.b/255*LocalPlayer():GetInfo("ragdollcolor_multi")) end
- end)
- local function SetColour( Entity, color,ply )
- if SERVER then
- net.Start("SendToRagdollClient")
- net.WriteTable({Entity,color})
- net.Send(ply)
- end
- Entity.GetPlayerColor = function() return Vector( color.r/255, color.g/255, color.b/255) end
- if ( SERVER ) then
- duplicator.StoreEntityModifier( Entity, "ragdolcolor", color )
- end
- end
- duplicator.RegisterEntityModifier( "ragdolcolor", SetColour )
- function TOOL:LeftClick( trace )
- local ent = trace.Entity
- if ( IsValid( ent.AttachedEntity ) ) then ent = ent.AttachedEntity end
- if IsValid( ent ) then -- The entity is valid and isn't worldspawn
- if ( CLIENT ) then return true end
- local r = self:GetClientNumber( "r", 0 )
- local g = self:GetClientNumber( "g", 0 )
- local b = self:GetClientNumber( "b", 0 )
- SetColour( ent, Color( r, g, b ),self:GetOwner() )
- return true
- end
- end
- function TOOL:RightClick( trace )
- local ent = trace.Entity
- if ( IsValid( ent.AttachedEntity ) ) then ent = ent.AttachedEntity end
- if IsValid( ent ) then -- The entity is valid and isn't worldspawn
- SetColour( ent, Color( 255, 255, 255 ),self:GetOwner() )
- return true
- end
- end
- function TOOL.BuildCPanel( CPanel )
- CPanel:AddControl( "Color", { Label = "Player color", Red = "ragdollcolor_r", Green = "ragdollcolor_g", Blue = "ragdollcolor_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
- CPanel:AddControl( "Slider", { Label = "Color multiplier", Type = "Float", Command = "ragdollcolor_multi", Min = "-1", Max = "5", Help = true } )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement