There are two world models of this weapon, one floating and one really small. Can any of you tell what is causing this from this code? Here is an example of what I mean: [URL="http://imgur.com/a/Ny7Z5"]http://imgur.com/a/Ny7Z5[/URL]
If possible could you please help me fix it so that there is just one model rather than a floating one and a small one?
[CODE]if (SERVER) then
AddCSLuaFile( "shared.lua" )
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end
if ( CLIENT ) then
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = false
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.CSMuzzleFlashes = true
SWEP.Icon = "vgui/ttt/icon_ms_comp.png"
SWEP.EquipMenuData = {
type = "item_weapon",
desc = "The arrow arcs as it flys"
};
end
SWEP.Base = "weapon_tttbase"
SWEP.Category = "EXP 2 Weapons"
SWEP.PrintName = "Elite Bow"
SWEP.HoldType = "rpg"
SWEP.Slot = 6
SWEP.SlotPos = 6
SWEP.Author = "Mighty Lolrus"
SWEP.ViewModel = "models/weapons/v_snip_scoub.mdl"
SWEP.WorldModel = "models/weapons/w_snip_scoub.mdl"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Primary.Sound = Sound("weapons/Requests Studio/SF2/fire.wav")
SWEP.Primary.Round = ("arrow")
SWEP.Primary.RPM = 37
SWEP.Primary.ClipSize = 10
SWEP.Primary.ClipMax = 0
SWEP.Primary.DefaultClip = 10
SWEP.Primary.Delay = 1.2
SWEP.Primary.Damage = 80
SWEP.Primary.Cone = 0.00
SWEP.Primary.ConeSpray = 0.00
SWEP.Primary.ConeIncrement = 0.00
SWEP.Primary.ConeMax = 0.00
SWEP.Primary.ConeDecrement = 0.0
SWEP.Primary.KickUp = 0
SWEP.Primary.KickDown = 0
SWEP.Primary.KickHorizontal = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "arrow"
SWEP.Secondary.ClipSize = 1
SWEP.Secondary.DefaultClip = 1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""
SWEP.Secondary.IronFOV = 60
SWEP.CanBuy = {ROLE_TRAITOR}
--- TTT config values
-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8
SWEP.Kind = WEAPON_EQUIP
-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false
-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = "arrow"
-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil
-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = true
-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = true
-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = false
SWEP.LimitedStock = true
SWEP.IronSightsPos = Vector(-13.41, -13.308, 18.549)
SWEP.IronSightsAng = Vector(1.5, -0.401, -53.741)
SWEP.SightsPos = Vector(-13.41, -13.308, 18.549)
SWEP.SightsAng = Vector(1.5, -0.401, -53.741)
SWEP.RunSightsPos = Vector(0, 0, 0)
SWEP.RunSightsAng = Vector(-7.993, 6.889, 9.093)
SWEP.WElements = {
["w_model"] = { type = "Model", model = "models/weapons/w_snip_scoub.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(-5.909, 0, 0), angle = Angle(-15.341, -1.024, 30), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
function SWEP:Initialize()
if ( SERVER ) then
self:SetNPCMinBurst( 0.01 )
self:SetNPCMaxBurst( 0.04 )
self:SetNPCFireRate( 0.1 )
end
self.Weapon:SetDeploySpeed( self.WeaponDeploySpeed )
self:SetWeaponHoldType( self.HoldType )
self.Primary.Cone = 0.015
self.Weapon:SetNetworkedBool( "Ironsights", false )
gap = 05 mm = 20
if CLIENT then
// Create a new table for every weapon instance
self.VElements = table.FullCopy( self.VElements )
self.WElements = table.FullCopy( self.WElements )
self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
self:CreateModels(self.VElements) // create viewmodels
self:CreateModels(self.WElements) // create worldmodels
end
end
if CLIENT then
SWEP.vRenderOrder = nil
function SWEP:ViewModelDrawn()
local vm = self.Owner:GetViewModel()
if !IsValid(vm) then return end
if (!self.VElements) then return end
self:UpdateBonePositions(vm)
if (!self.vRenderOrder) then
// we build a render order because sprites need to be drawn after models
self.vRenderOrder = {}
for k, v in pairs( self.VElements ) do
if (v.type == "Model") then
table.insert(self.vRenderOrder, 1, k)
elseif (v.type == "Sprite" or v.type == "Quad") then
table.insert(self.vRenderOrder, k)
end
end
end
for k, name in ipairs( self.vRenderOrder ) do
local v = self.VElements[name]
if (!v) then self.vRenderOrder = nil break end
if (v.hide) then continue end
local model = v.modelEnt
local sprite = v.spriteMaterial
if (!v.bone) then continue end
local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
if (!pos) then continue end
if (v.type == "Model" and IsValid(model)) then
model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
model:SetAngles(ang)
//model:SetModelScale(v.size)
local matrix = Matrix()
matrix:Scale(v.size)
model:EnableMatrix( "RenderMultiply", matrix )
if (v.material == "") then
model:SetMaterial("")
elseif (model:GetMaterial() != v.material) then
model:SetMaterial( v.material )
end
if (v.skin and v.skin != model:GetSkin()) then
model:SetSkin(v.skin)
end
if (v.bodygroup) then
for k, v in pairs( v.bodygroup ) do
if (model:GetBodygroup(k) != v) then
model:SetBodygroup(k, v)
end
end
end
if (v.surpresslightning) then
render.SuppressEngineLighting(true)
end
render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
render.SetBlend(v.color.a/255)
model:DrawModel()
render.SetBlend(1)
render.SetColorModulation(1, 1, 1)
if (v.surpresslightning) then
render.SuppressEngineLighting(false)
end
elseif (v.type == "Sprite" and sprite) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
render.SetMaterial(sprite)
render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
elseif (v.type == "Quad" and v.draw_func) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
cam.Start3D2D(drawpos, ang, v.size)
v.draw_func( self )
cam.End3D2D()
end
end
end
SWEP.wRenderOrder = nil
function SWEP:DrawWorldModel()
if (self.ShowWorldModel == nil or self.ShowWorldModel) then
self:DrawModel()
end
if (!self.WElements) then return end
if (!self.wRenderOrder) then
self.wRenderOrder = {}
for k, v in pairs( self.WElements ) do
if (v.typ
Sorry, you need to Log In to post a reply to this thread.