Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --新浪微博:@戈登走過去
- --Twitter:@Gordonwalkedby
- AddCSLuaFile()
- TOOL.Category = "Poser"
- TOOL.Name = "Auto Speak"
- TOOL.AddToMenu = true
- local TimerName = "GoMakeRagdollSpeak"
- if (CLIENT) then
- TOOL.Information = {
- { name = "left" },
- { name = "right" }
- }
- language.Add("tool.autospeak.name","Auto Speak Tool")
- 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.")
- language.Add("tool.autospeak.left","To make something speak.")
- language.Add("tool.autospeak.right","To make something not speak anymore.")
- end
- TOOL.ClientConVar[ "RsCount" ] = 1
- TOOL.ClientConVar[ "MinFlex" ] = 20
- TOOL.ClientConVar[ "MaxFlex" ] = 90
- TOOL.ClientConVar[ "Time" ] = 0.04
- TOOL.ClientConVar[ "En" ] = 1
- concommand.Add("AutoSpeakC", function()
- if GetConVarNumber("autospeak_En") == 1 then
- RunConsoleCommand("autospeak_En",0)
- else
- RunConsoleCommand("autospeak_En",1)
- end
- end)
- function IsGoodModel( ent )
- if ent == NULL then return false end
- if !IsValid(ent) then return false end
- if ent:GetFlexNum() < 1 then return false end
- return true
- end
- function MakeRagdollKeepSpeak( ent )
- if !(GetConVarNumber("autospeak_En") == 1) then return end
- if !IsGoodModel(ent) then return end
- local min = ent:GetNWInt("rsSpeak")
- if min < 1 then return end
- local FlexNum = ent:GetFlexNum()
- min = ent:GetNWInt("rsMin")
- local max = ent:GetNWInt("rsMax")
- if min > max then
- local t = min
- min = max
- max = t
- end
- if max > FlexNum then max = FlexNum end
- for a = min , max do
- local c,d = ent:GetFlexBounds(a)
- if d == nil then d = 1 end
- if c == nil then c = 0 end
- ent:SetFlexWeight(a, math.Rand(c, d))
- end
- end
- function TOOL:LeftClick( trace )
- local ent = trace.Entity
- if !IsGoodModel(ent) then return false end
- local m = ent:GetNWInt("rsID")
- ent:SetNWInt("rsMin", GetConVarNumber("autospeak_MinFlex"))
- ent:SetNWInt("rsMax", GetConVarNumber("autospeak_MaxFlex"))
- local min = GetConVarNumber("autospeak_Time")
- if min < 0.01 then min = 0.01 end
- if min > 0.5 then min = 0.5 end
- if m > 0 then
- timer.Adjust(TimerName .. tostring(m) , min ,0 ,function()
- MakeRagdollKeepSpeak(ent)
- end)
- else
- local rc = GetConVarNumber("autospeak_RsCount")
- rc = rc + 1
- ent:SetNWInt("rsID", rc)
- RunConsoleCommand("autospeak_RsCount",rc)
- timer.Create(TimerName .. tostring(rc) ,min , 0 ,function()
- MakeRagdollKeepSpeak(ent)
- end)
- end
- ent:SetNWInt("rsSpeak",1)
- RunConsoleCommand("autospeak_En",1)
- return true
- end
- function TOOL:RightClick( trace )
- local ent = trace.Entity
- if !IsGoodModel(ent) then return false end
- ent:SetNWInt("rsSpeak",0)
- return true
- end
- function TOOL.BuildCPanel( CPanel )
- CPanel:AddControl( "Header", { Description = "Auto Speak Tool By Gordon Walkedby" } )
- CPanel:AddControl( "slider", { label = "Flex Range Start:" , command = "autospeak_MinFlex" } )
- CPanel:AddControl( "slider", { label = "Flex Range End:" , command = "autospeak_MaxFlex" } )
- CPanel:AddControl( "slider", { type = "float" , label = "Time Interval:" , command = "autospeak_Time" , max = 0.5 , min = 0.01 } )
- CPanel:AddControl( "button", { label = "Start or Stop (For All)" , command = "AutoSpeakC"})
- end
Add Comment
Please, Sign In to add comment