Advertisement
Guest User

Code

a guest
Jun 5th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1.  
  2. TOOL.Category = "Render"
  3. TOOL.Name = "Ragdoll color"
  4.  
  5. TOOL.ClientConVar[ "r" ] = 255
  6. TOOL.ClientConVar[ "g" ] = 0
  7. TOOL.ClientConVar[ "b" ] = 255
  8. TOOL.ClientConVar[ "multi" ] = 1
  9.  
  10. if CLIENT then
  11. language.Add("ragdollcolor", "Ragdoll color")
  12. language.Add("tool.ragdollcolor.name", "Ragdoll color")
  13. language.Add("tool.ragdollcolor.desc", "Set a color for that ragdoll")
  14. language.Add("tool.ragdollcolor.0", "Apply the color")
  15.  
  16. end
  17.  
  18. if SERVER then
  19. util.AddNetworkString("SendToRagdollClient")
  20. end
  21.  
  22. net.Receive("SendToRagdollClient",function()
  23.  
  24. local tbl = net.ReadTable()
  25. local color = tbl[2]
  26. 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
  27.  
  28. end)
  29.  
  30. local function SetColour( Entity, color,ply )
  31.  
  32. if SERVER then
  33. net.Start("SendToRagdollClient")
  34. net.WriteTable({Entity,color})
  35. net.Send(ply)
  36. end
  37.  
  38. Entity.GetPlayerColor = function() return Vector( color.r/255, color.g/255, color.b/255) end
  39.  
  40. if ( SERVER ) then
  41. duplicator.StoreEntityModifier( Entity, "ragdolcolor", color )
  42. end
  43.  
  44. end
  45. duplicator.RegisterEntityModifier( "ragdolcolor", SetColour )
  46.  
  47. function TOOL:LeftClick( trace )
  48.  
  49. local ent = trace.Entity
  50. if ( IsValid( ent.AttachedEntity ) ) then ent = ent.AttachedEntity end
  51.  
  52. if IsValid( ent ) then -- The entity is valid and isn't worldspawn
  53.  
  54. if ( CLIENT ) then return true end
  55.  
  56. local r = self:GetClientNumber( "r", 0 )
  57. local g = self:GetClientNumber( "g", 0 )
  58. local b = self:GetClientNumber( "b", 0 )
  59.  
  60. SetColour( ent, Color( r, g, b ),self:GetOwner() )
  61.  
  62. return true
  63.  
  64. end
  65.  
  66. end
  67.  
  68. function TOOL:RightClick( trace )
  69.  
  70. local ent = trace.Entity
  71. if ( IsValid( ent.AttachedEntity ) ) then ent = ent.AttachedEntity end
  72.  
  73. if IsValid( ent ) then -- The entity is valid and isn't worldspawn
  74.  
  75. SetColour( ent, Color( 255, 255, 255 ),self:GetOwner() )
  76.  
  77. return true
  78.  
  79. end
  80.  
  81. end
  82.  
  83. function TOOL.BuildCPanel( CPanel )
  84.  
  85. CPanel:AddControl( "Color", { Label = "Player color", Red = "ragdollcolor_r", Green = "ragdollcolor_g", Blue = "ragdollcolor_b", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )
  86. CPanel:AddControl( "Slider", { Label = "Color multiplier", Type = "Float", Command = "ragdollcolor_multi", Min = "-1", Max = "5", Help = true } )
  87.  
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement