Hello, I made ​​an Alyx's Gun for my PR, but I am having some problems when I made ​​a cade, I see not just the hands and the weapon, I should certainly wrong somewhere. But I can not, therefore, someone could esque me to sort the main and reload please? I just want it to be a automatic pistol but I do not want you see the viewfinder. Here is the code with the Wmodel and Vmodel:
[quote]
if (SERVER) then
AddCSLuaFile( "shared.lua" )
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end
SWEP.HoldType = "melee"
function SWEP:Initialize()
self:SetWeaponHoldType( self.HoldType )
end
if ( CLIENT ) then
SWEP.PrintName = "Alyx's Gun"
SWEP.Author = "Lyc@n"
SWEP.Contact = ""
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBonescales = {["ValveBiped.clip"] = Vector(0.009, 0.009, 0.009), ["ValveBiped.hammer"] = Vector(0.009, 0.009, 0.009), ["ValveBiped.base"] = Vector(0.009, 0.009, 0.009), ["ValveBiped.square"] = Vector(0.009, 0.009, 0.009)}
SWEP.HoldType = "pistol"
SWEP.CSMuzzleFlashes = false
end
SWEP.Category = "RP Weapons"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/Weapons/W_Alyx_Gun.mdl"
SWEP.IronSightsPos = Vector(-6.921, 8.319, 7.4)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.VElements = {
}
SWEP.WElements = {
["walyxgun"] = { type = "Model", model = "models/Weapons/W_Alyx_Gun.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(5.693, 2.299, -4.439), angle = Angle(174.705, 1.205, 10.237), size = Vector(1.103, 1.103, 1.103), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.Primary.ClipSize = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = false
SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0
function SWEP:Reload()
end
function SWEP:PrimaryAttack()
end
function SWEP:SecondaryAttack()
end
function SWEP:Think()
end
function SWEP:Initialize()
self.HoldType = "pistol" //Sets their holdtype to that of the AR2
self:SetWeaponHoldType( self.HoldType )
// other initialize code goes here
if CLIENT then
self:CreateModels(self.VElements) // create viewmodels
self:CreateModels(self.WElements) // create worldmodels
// init view model bone build function
self.BuildViewModelBones = function( s )
if LocalPlayer():GetActiveWeapon() == self and self.ViewModelBonescales then
for k, v in pairs( self.ViewModelBonescales ) do
local bone = s:LookupBone(k)
if (!bone) then continue end
local m = s:GetBoneMatrix(bone)
if (!m) then continue end
m:Scale(v)
s:SetBoneMatrix(bone, m)
end
end
end
end
end
function SWEP:OnRemove()
// other onremove code goes here
if CLIENT then
self:RemoveModels()
end
end
if CLIENT then
SWEP.vRenderOrder = nil
function SWEP:ViewModelDrawn()
local vm = self.Owner:GetViewModel()
if !ValidEntity(vm) then return end
if (!self.VElements) then return end
if vm.BuildBonePositions ~= self.BuildViewModelBones then
vm.BuildBonePositions = self.BuildViewModelBones
end
if (self.ShowViewModel == nil or self.ShowViewModel) then
vm:SetColor(255,255,255,255)
else
// we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
vm:SetColor(255,255,255,1)
end
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
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 ValidEntity(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)
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.type == "Model") then
table.insert(self.wRenderOrder, 1, k)
Sorry please clean your code and sort it.
This looks very useless ...
[code]
self.BuildViewModelBones = function( s )
if LocalPlayer():GetActiveWeapon() == self and self.ViewModelBonescales then
for k, v in pairs( self.ViewModelBonescales ) do
local bone = s:LookupBone(k)
if (!bone) then continue end
local m = s:GetBoneMatrix(bone)
if (!m) then continue end
m:Scale(v)
s:SetBoneMatrix(bone, m)
end
end
end
end
end
[/code]
???
[code]
if CLIENT then
self:RemoveModels()
end
end
if CLIENT then
///...
[/code]
That looks like C&P
If I clean up these codes the weapon don't work, it's not useless, I have tried to remove them, but that don't work.
Can someone help me please? Thanks!
Sorry, you need to Log In to post a reply to this thread.