• Holster weapons system problem
    4 replies, posted
Hey I have addon for holster weapons. And I have the error : [CODE] [ERROR] /lua/autorun/client/holster.lua:211: ')' expected near '|' 1. unknown - /lua/autorun/client/holster.lua:0 [/CODE] Line 211 : [CODE] pl.CL_CS_WEPS[v:GetClass()].AttachedModel:AddEffects( EF_BONEMERGE | EF_BONEMERGE_FASTCULL | EF_PARENT_ANIMATES) [/CODE] The full code : [CODE]/* Jvs:this script will allow you to see your/others weapons directly on the body when in thirdperson every weapon needs a different bone/drawfunction/boneoffset,however,drawfunction can be nil boneoffsets will be retrieved from a custom table,so,if there's a pistol,it will draw it on the hips,heavy weapons on the back etc etc WARNING:drawfunction will NOT draw the model,it will draw an effect or whatever you want,the model is drawn before this function gets called i know,there's no gui/derma to modify the bones,i'm used to modify them directly in the .lua file,just look at the these hl2 weapons examples */ local holsteredgunsconvar = CreateConVar( "cl_holsteredguns", "1", { FCVAR_ARCHIVE, }, "Enable/Disable the rendering of the weapons on any player" ) local NEXT_WEAPONS_UPDATE=CurTime(); local weaponsinfos={} weaponsinfos["weapon_physcannon"]={} weaponsinfos["weapon_physcannon"].Model="" weaponsinfos["weapon_physcannon"].Bone="ValveBiped.Bip01_Spine1" weaponsinfos["weapon_physcannon"].BoneOffset={Vector(6,15,0),Angle(90,180,0)}//offset,weapon angle weaponsinfos["weapon_physcannon"].Priority="weapon_physgun" //this means that if the weapon_physgun can be drawn,we will not weaponsinfos["weapon_physgun"]={} weaponsinfos["weapon_physgun"].Model="" weaponsinfos["weapon_physgun"].Bone="ValveBiped.Bip01_Spine1" weaponsinfos["weapon_physgun"].DrawFunction=function(ent) end /* draw custom core to make it look like it's on */ weaponsinfos["weapon_physgun"].BoneOffset={Vector(6,15,0),Angle(90,180,0)}//offset,weapon angle weaponsinfos["weapon_physgun"].Skin=1; //we can set custom skin too,but only once,remember that weaponsinfos["weapon_physgun"].DrawFunction=function(ent) local attachment=ent:GetAttachment( 1) local StartPos = attachment.Pos + attachment.Ang:Forward()*4 render.SetMaterial(physgunmat) render.DrawSprite(attachment.Pos,20,20,Color(255,255,255,255)); render.SetMaterial(physgunmat1) render.DrawSprite(StartPos,20,20,Color(255,255,255,255)); end weaponsinfos["weapon_pistol"]={} weaponsinfos["weapon_pistol"].Model="models/weapons/W_pistol.mdl" weaponsinfos["weapon_pistol"].Bone="ValveBiped.Bip01_Pelvis" weaponsinfos["weapon_pistol"].BoneOffset={Vector(0,-8,0),Angle(0,90,0)}//offset,weapon angle weaponsinfos["weapon_cc_pistol"]={} weaponsinfos["weapon_cc_pistol"].Model="models/weapons/W_pistol.mdl" weaponsinfos["weapon_cc_pistol"].Bone="ValveBiped.Bip01_Pelvis" weaponsinfos["weapon_cc_pistol"].BoneOffset={Vector(0,-8,0),Angle(0,90,0)}//offset,weapon angle weaponsinfos["weapon_357"]={} weaponsinfos["weapon_357"].Model="models/weapons/W_357.mdl" weaponsinfos["weapon_357"].Bone="ValveBiped.Bip01_Pelvis" weaponsinfos["weapon_357"].BoneOffset={Vector(-5,8,0),Angle(0,270,0)}//offset,weapon angle weaponsinfos["weapon_357"].Priority="gmod_tool" weaponsinfos["weapon_frag"]={} weaponsinfos["weapon_frag"].Model="models/Items/grenadeAmmo.mdl" weaponsinfos["weapon_frag"].Bone="ValveBiped.Bip01_Pelvis" weaponsinfos["weapon_frag"].BoneOffset={Vector(3,-5,6),Angle(-95,0,0)}//offset,weapon angle weaponsinfos["weapon_slam"]={} weaponsinfos["weapon_slam"].Model="models/weapons/w_slam.mdl" weaponsinfos["weapon_slam"].Bone="ValveBiped.Bip01_Spine2" weaponsinfos["weapon_slam"].BoneOffset={Vector(-9,0,-7),Angle(270,90,-25)}//offset,weapon angle weaponsinfos["weapon_crowbar"]={} weaponsinfos["weapon_crowbar"].Model="models/weapons/w_crowbar.mdl" weaponsinfos["weapon_crowbar"].Bone="ValveBiped.Bip01_Spine1" weaponsinfos["weapon_crowbar"].BoneOffset={Vector(3,0,0),Angle(0,0,45)}//offset,weapon angle weaponsinfos["weapon_stunstick"]={} weaponsinfos["weapon_stunstick"].Model="models/weapons/W_stunbaton.mdl" weaponsinfos["weapon_stunstick"].Bone="ValveBiped.Bip01_Spine1" weaponsinfos["weapon_stunstick"].BoneOffset={Vector(3,0,0),Angle(0,0,-45)}//offset,weapon angle weaponsinfos["weapon_shotgun"]={} weaponsinfos["weapon_shotgun"].Model="models/weapons/W_shotgun.mdl" weaponsinfos["weapon_shotgun"].Bone="ValveBiped.Bip01_R_Clavicle" weaponsinfos["weapon_shotgun"].BoneOffset={Vector(10,5,2),Angle(0,90,0)}//offset,weapon angle weaponsinfos["weapon_rpg"]={} weaponsinfos["weapon_rpg"].Model="models/weapons/w_rocket_launcher.mdl" weaponsinfos["weapon_rpg"].Bone="ValveBiped.Bip01_L_Clavicle" weaponsinfos["weapon_rpg"].BoneOffset={Vector(-16,5,0),Angle(90,90,90)}//offset,weapon angle weaponsinfos["weapon_smg1"]={} weaponsinfos["weapon_smg1"].Model="models/weapons/w_smg1.mdl" weaponsinfos["weapon_smg1"].Bone="ValveBiped.Bip01_Spine1" weaponsinfos["weapon_smg1"].BoneOffset={Vector(5,0,-5),Angle(0,0,230)}//offset,weapon angle weaponsinfos["weapon_ar2"]={} weaponsinfos["weapon_ar2"].Model="models/weapons/W_irifle.mdl" weaponsinfos["weapon_ar2"].Bone="ValveBiped.Bip01_R_Clavicle" weaponsinfos["weapon_ar2"].BoneOffset={Vector(-5,0,7),Angle(0,270,0)}//offset,weapon angle weaponsinfos["weapon_crossbow"]={} weaponsinfos["weapon_crossbow"].Model="models/weapons/W_crossbow.mdl" weaponsinfos["weapon_crossbow"].Bone="ValveBiped.Bip01_L_Clavicle" weaponsinfos["weapon_crossbow"].BoneOffset={Vector(0,5,-5),Angle(180,90,0)}//offset,weapon angle function LPGB(dotrace) if !dotrace then for i=0,LocalPlayer():GetBoneCount()-1 do print(LocalPlayer():GetBoneName(i)) end else local entity=LocalPlayer():GetEyeTrace().Entity if !IsValid(entity) then return end for i=0,entity:GetBoneCount()-1 do print(entity:GetBoneName(i)) end end end local function CalcOffset(pos,ang,off) return pos + ang:Right() * off.x + ang:Forward() * off.y + ang:Up() * off.z; end local function clhasweapon(pl,weaponclass) for i,v in pairs(pl:GetWeapons()) do if string.lower(v:GetClass())==string.lower(weaponclass) then return true end end return false; end local function clgetweapon(pl,weaponclass) for i,v in pairs(pl:GetWeapons()) do if string.lower(v:GetClass())==string.lower(weaponclass) then return v end end return nil; end local function playergettf2class(ply) return ply:GetPlayerClass() end local function IsTf2Class(ply) return LocalPlayer().IsHL2 && !LocalPlayer():IsHL2() end local function GetHolsteredWeaponTable(ply,indx) local class=IsTf2Class(ply) and playergettf2class(ply) or nil if !class then return weaponsinfos[indx] else return (weaponsinfos[indx] && weaponsinfos[indx][class]) and weaponsinfos[indx][class] or nil end end local function thinkholster() if !holsteredgunsconvar:GetBool() then return end for _,pl in pairs(player.GetAll()) do if !IsValid(pl) then continue end if !pl.CL_CS_WEPS then pl.CL_CS_WEPS={} end if !pl:Alive() then pl.CL_CS_WEPS={} continue end if !pl:Team() == TEAM_UNCONNECTED then pl.CL_CS_WEPS={} continue end if NEXT_WEAPONS_UPDATE<CurTime() then pl.CL_CS_WEPS={} NEXT_WEAPONS_UPDATE=CurTime()+5 end for i,v in pairs(pl:GetWeapons())do if !IsValid(v) then continue; end if pl.CL_CS_WEPS[v:GetClass()] then continue end if !pl.CL_CS_WEPS[v:GetClass()] then local worldmodel=v.WorldModelOverride or v.WorldModel //attempt to pick the model from a swep local attachedwmodel=v.AttachedWorldModel; if GetHolsteredWeaponTable(pl,v:GetClass()) && GetHolsteredWeaponTable(pl,v:GetClass()).Model then //holster,it's not a swep,then try
The bitwise or operator doesn't work in GMod. Use bit.bor.
[QUOTE=code_gs;50570025]The bitwise or operator doesn't work in GMod. Use bit.bor.[/QUOTE] Thanks!
Just a warning, these holster scripts kill fps
Yeah it's a very old script and could probably optimized in a better way.
Sorry, you need to Log In to post a reply to this thread.