Guest User

Untitled

a guest
Jun 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. --新浪微博:@戈登走過去
  2. --Twitter:@Gordonwalkedby
  3.  
  4. AddCSLuaFile()
  5.  
  6. TOOL.Category = "Poser"
  7. TOOL.Name = "Auto Speak"
  8. TOOL.AddToMenu = true
  9.  
  10. local TimerName = "GoMakeRagdollSpeak"
  11.  
  12. if (CLIENT) then
  13. TOOL.Information = {
  14. { name = "left" },
  15. { name = "right" }
  16. }
  17.  
  18. language.Add("tool.autospeak.name","Auto Speak Tool")
  19. language.Add("tool.autospeak.desc","Choose a range of flex and then left click a ragdoll or a NPC or a Player to make it auto change its flex.")
  20. language.Add("tool.autospeak.left","To make something speak.")
  21. language.Add("tool.autospeak.right","To make something not speak anymore.")
  22. end
  23.  
  24. TOOL.ClientConVar[ "RsCount" ] = 1
  25. TOOL.ClientConVar[ "MinFlex" ] = 20
  26. TOOL.ClientConVar[ "MaxFlex" ] = 90
  27. TOOL.ClientConVar[ "Time" ] = 0.04
  28. TOOL.ClientConVar[ "En" ] = 1
  29.  
  30. concommand.Add("AutoSpeakC", function()
  31. if GetConVarNumber("autospeak_En") == 1 then
  32. RunConsoleCommand("autospeak_En",0)
  33. else
  34. RunConsoleCommand("autospeak_En",1)
  35. end
  36. end)
  37.  
  38. function IsGoodModel( ent )
  39. if ent == NULL then return false end
  40. if !IsValid(ent) then return false end
  41. if ent:GetFlexNum() < 1 then return false end
  42. return true
  43. end
  44.  
  45. function MakeRagdollKeepSpeak( ent )
  46. if !(GetConVarNumber("autospeak_En") == 1) then return end
  47. if !IsGoodModel(ent) then return end
  48.  
  49. local min = ent:GetNWInt("rsSpeak")
  50. if min < 1 then return end
  51.  
  52. local FlexNum = ent:GetFlexNum()
  53.  
  54. min = ent:GetNWInt("rsMin")
  55. local max = ent:GetNWInt("rsMax")
  56.  
  57. if min > max then
  58. local t = min
  59. min = max
  60. max = t
  61. end
  62.  
  63. if max > FlexNum then max = FlexNum end
  64.  
  65. for a = min , max do
  66. local c,d = ent:GetFlexBounds(a)
  67. if d == nil then d = 1 end
  68. if c == nil then c = 0 end
  69. ent:SetFlexWeight(a, math.Rand(c, d))
  70. end
  71. end
  72.  
  73. function TOOL:LeftClick( trace )
  74. local ent = trace.Entity
  75.  
  76. if !IsGoodModel(ent) then return false end
  77.  
  78. local m = ent:GetNWInt("rsID")
  79.  
  80. ent:SetNWInt("rsMin", GetConVarNumber("autospeak_MinFlex"))
  81. ent:SetNWInt("rsMax", GetConVarNumber("autospeak_MaxFlex"))
  82.  
  83. local min = GetConVarNumber("autospeak_Time")
  84.  
  85. if min < 0.01 then min = 0.01 end
  86. if min > 0.5 then min = 0.5 end
  87.  
  88. if m > 0 then
  89. timer.Adjust(TimerName .. tostring(m) , min ,0 ,function()
  90. MakeRagdollKeepSpeak(ent)
  91. end)
  92. else
  93. local rc = GetConVarNumber("autospeak_RsCount")
  94. rc = rc + 1
  95. ent:SetNWInt("rsID", rc)
  96. RunConsoleCommand("autospeak_RsCount",rc)
  97. timer.Create(TimerName .. tostring(rc) ,min , 0 ,function()
  98. MakeRagdollKeepSpeak(ent)
  99. end)
  100. end
  101.  
  102. ent:SetNWInt("rsSpeak",1)
  103. RunConsoleCommand("autospeak_En",1)
  104.  
  105. return true
  106. end
  107.  
  108. function TOOL:RightClick( trace )
  109. local ent = trace.Entity
  110.  
  111. if !IsGoodModel(ent) then return false end
  112.  
  113. ent:SetNWInt("rsSpeak",0)
  114.  
  115. return true
  116. end
  117.  
  118. function TOOL.BuildCPanel( CPanel )
  119. CPanel:AddControl( "Header", { Description = "Auto Speak Tool By Gordon Walkedby" } )
  120. CPanel:AddControl( "slider", { label = "Flex Range Start:" , command = "autospeak_MinFlex" } )
  121. CPanel:AddControl( "slider", { label = "Flex Range End:" , command = "autospeak_MaxFlex" } )
  122. CPanel:AddControl( "slider", { type = "float" , label = "Time Interval:" , command = "autospeak_Time" , max = 0.5 , min = 0.01 } )
  123. CPanel:AddControl( "button", { label = "Start or Stop (For All)" , command = "AutoSpeakC"})
  124. end
Add Comment
Please, Sign In to add comment