Lua Help
#1
So.. I'm here, mainly in this forum because I need help.. and you guys are cool.. facepunch is interesting and I'd rather not go there.

Anyway, here is the code for my combine thrower. My question is, how do I applyForce to all the ragdoll bones?

Code:
if SERVER then
    // Serverside Code
        AddCSLuaFile ("shared.lua") // Adds to server download
        SWEP.Weight = 5 // Weight of SWEP
        SWEP.AutoSwitchTo = true // Switching TO the SWEP
        SWEP.AutoSwitchFrom = true // Switching AWAY the SWEP to another SWEP

elseif CLIENT then
    // Clientside Code
        SWEP.PrintName = "Combine Thrower" // Name of the Gun in the Weapons Tab
        SWEP.Slot = 4 // Position on the Weapon Menu
        SWEP.SlotPos = 1
        SWEP.DrawAmmo = false // To have the ammo HUD or not
        SWEP.Crosshair = true // Enables or disables the crosshair
        
        language.Add("Undone_Aoix's_Gun_Entity","Undone Aoix's Gun Entity")
    
end
SWEP.Category = "Aoix's Weapons"
SWEP.Author = "Aoixifcation"
SWEP.Contact = "[email protected]"
SWEP.Purpose = "Throws Combine"
SWEP.Instructions = "Primary Fire for Combine Solider | Secondary Fire for Elite Combine"

    SWEP.Spawnable = false // Can regular players spawn it?
    SWEP.AdminSpawnable = true // Can admins spawn it?
    
    SWEP.ViewModel = "models/weapons/v_toolgun.mdl" // How it looks to the client
    SWEP.WorldModel = "models/weapons/w_toolgun.mdl" // How it looks to other
    
    SWEP.Primary.ClipSize = -1
    SWEP.Primary.DefaultClip = -1
    SWEP.Primary.Automatic = false
    SWEP.Primary.Ammo = "none"
    
    SWEP.Secondary.ClipSize = -1
    SWEP.Secondary.DefaultClip = -1
    SWEP.Secondary.Automatic = false
    SWEP.Secondary.Ammo = "none"
    
    local ShootSound = Sound("/buttons/combine_button_locked.wav")
    

        function SWEP.Think()
            end
    function SWEP:throw_attack (model_file)
    
        local tr = self.Owner:GetEyeTrace()
        self:EmitSound(ShootSound)
        self.BaseClass.ShootEffects(self)
        
        if (!SERVER) then return end
        
        ent = ents.Create("prop_ragdoll")
        ent:SetModel(model_file)
        
        ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
        ent:SetAngles(self.Owner:EyeAngles())
        ent:Spawn()
        
        local phys = ent:GetPhysicsObject()
        
        if!(phys && IsValid(phys)) then ent:Remove() return end
        
        phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3))
        SafeRemoveEntityDelayed(ent,3)
        cleanup.Add(self.Owner, "props", ent)

    undo.Create ("Combine_Ragdoll_Gun")
        undo.AddEntity (ent)
        undo.SetPlayer (self.Owner)
        undo.Finish()
    end
function SWEP:PrimaryAttack()
    self:throw_attack("models/combine_soldier.mdl")
end
function SWEP:SecondaryAttack()
    self:throw_attack("models/combine_super_soldier.mdl")
end
function SWEP:Reload()
        end
Also, if you would like to test it, download it here;

http://www.2shared.com/file/jWquLHkz/com...ncher.html
FUMUKU
WAS THE BEST THING TO EVER HAPPEN TO FEARLESS RP


UNBAN BLACKDOG


Forum Jump:


Users browsing this thread: 1 Guest(s)