• Hat system not drawing hats
    3 replies, posted
Hello, I recently tried to make a hat system but the hats dont seem to be drawn on the player :/ here is my code [lua] hats = {} players_have_hats = {} function AddHat( unique , model, offsetV, offsetA , bone , scale) hats[unique] = hats[unique] or {} hats[unique].model = model hats[unique].offsetV = offsetV hats[unique].offsetA = offsetA hats[unique].bone = bone hats[unique].scale = scale end function SpawnHat(player , unique) if !player:IsPlayer() then return end if !player:IsValid() then return end if !hats[unique] then return end local index = player:EntIndex() players_have_hats[index] = players_have_hats[index] or {} players_have_hats[index].hat = unique end function SetHat(player,hat) hat:SetOwner(player) end function GetHat(player) for k,v in pairs(ents.GetAll()) do if v:GetOwner() == player then return v else return false end end end AddHat("Barrel","models/props_c17/oildrum001_explosive.mdl",Vector(0,0,0), Angle(0,0,0),"ValveBiped.Bip01_Head1",45) function DrawHats(ply) local index = ply:GetIndex() local Player = ply if !players_have_hats[index] then return end local unique = players_have_hats[index].hat local BoneIndx = Player:LookupBone(hats[unique].bone) local BonePos, BoneAng = Player:GetBonePosition( BoneIndx ) local offsetV = BonePos + hats[unique].offsetV local offsetA = BoneAng + hats[unique].offsetA local scale = hats[unique].scale //* Player:GetNetworkedFloat("PlScale") local hat = hat or ClientsideModel(hats[unique].model, RENDERGROUP_OPAQUE) hat:SetPos(offsetV) hat:SetAngles(offsetA) hat:SetModelScale(Vector(scale,scale,scale)) SetHat(Player,hat) hat:SetNoDraw(true) end hook.Add("PostPlayerDraw","hat.draw",function(ply) DrawHats(ply) local hat = GetHat(ply) hat:DrawModel() end) [/lua] There are no erorrs at all. To Add a hat to somone i did [code] lua_run SpawnHat(Entity(1),"Barrel") [/code] Please help D:
[B][URL="http://wiki.garrysmod.com/?title=Gamemode.PostPlayerDraw"]Gamemode.PostPlayerDraw [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B] is only for clients
I tried differant hooks but Nothing works. I even tried the think hook
bumbty bumb , realy need this to work
Sorry, you need to Log In to post a reply to this thread.