Just a small command that throws a shoe towards whoever/whatever.
local function ThrowShoe( Ply, Args )
-- // Run checks here
if !Ply:Alive() then return end
if Ply.ShoeThrowDelay && Ply.ShoeThrowDelay >= CurTime() then return end
-- // Prevent stopping the player during velocity and from getting stuck if spawned underneath themselves
if Ply:EyeAngles().p > 60 then return end
local Shoe = ents.Create( "prop_physics" )
Shoe:SetModel( "models/props_junk/shoe001a.mdl" )
-- // Make sure it does not get stuck on the player when throwing by pushing it forward
Shoe:SetPos( Ply:EyePos() + ( Ply:GetAimVector() * 35 ) )
Shoe:SetAngles( Ply:GetAngles() )
Shoe:Spawn()
Shoe:SetCollisionGroup( 4 )
Ply.ShoeThrowDelay = CurTime() + 3
local Phys = Shoe:GetPhysicsObject()
if IsValid( Phys ) then
Phys:SetVelocity( Ply:GetAimVector() * 650 )
end
-- // Delete shoe after a few seconds.
timer.Simple( 5, function()
if !IsValid( Shoe ) then return end
Shoe:Remove()
end)
end
-- // Replace with whatever chat function the server uses.
ChatCommand.Add( "/shoe", ThrowShoe )