• Attempting to make hats for a gamemode, they seem to be backwards.
    14 replies, posted
I'm trying to make hats but my test hat is upside down and is going opposite of the way it should be moving. I'm not too good with angles so I don't know where to start. [lua]_PlayerHat = ClientsideModel("models/player/items/heavy/heavy_ushanka.mdl") _PlayerHat:SetNoDraw(true) hook.Add("PostPlayerDraw", "hats", function(ply) local Bone = ply:LookupBone("ValveBiped.Bip01_Head1") local BonePos = ply:GetBonePosition( Bone ) local _Hat = _PlayerHat _Hat:SetModel("models/player/items/heavy/heavy_ushanka.mdl") _Hat:SetPos(BonePos + Vector(0, 0, 10)) _Hat:SetAngles(ply:EyeAngles() + Angle(0, 0, 180)) _Hat:SetColor(255, 255, 255, 255) _Hat:DrawModel() end)[/lua] [editline]20th October 2010[/editline] nevermind, it was SetAngles that was causing it, it was set to 180. [editline]20th October 2010[/editline] lock this please
You might need to adjust the angles even further to make the hat fit perfectly: [lua] local Bone = ply:LookupBone("ValveBiped.Bip01_Head1") local BonePos, BoneAng = ply:GetBonePosition( Bone ) BoneAng:RotateAroundAxis(BoneAng:Right(), 90) BoneAng:RotateAroundAxis(BoneAng:Forward(), 45) _Hat:SetAngles(BoneAng) [/lua]
[QUOTE=_nonSENSE;25527179]You might need to adjust the angles even further to make the hat fit perfectly: [lua] local Bone = ply:LookupBone("ValveBiped.Bip01_Head1") local BonePos, BoneAng = ply:GetBonePosition( Bone ) BoneAng:RotateAroundAxis(BoneAng:Right(), 90) BoneAng:RotateAroundAxis(BoneAng:Forward(), 45) _Hat:SetAngles(BoneAng) [/lua][/QUOTE] He already fixed it, 5 hours before you posted..
It was a suggestion to improve his current code after he fixed it. That's why I said [b]even further[/b] and [b]make the hat fit perfectly[/b]. Please learn to read and / or stop finding things to cry about. Better yet, take another vacation. Preferably a permanent one.
He doesn't need you're advice. :wink:
[QUOTE=_nonSENSE;25527179]You might need to adjust the angles even further to make the hat fit perfectly: [lua] local Bone = ply:LookupBone("ValveBiped.Bip01_Head1") local BonePos, BoneAng = ply:GetBonePosition( Bone ) BoneAng:RotateAroundAxis(BoneAng:Right(), 90) BoneAng:RotateAroundAxis(BoneAng:Forward(), 45) _Hat:SetAngles(BoneAng) [/lua][/QUOTE] You're right, it does fall off when I look all the way down. When I look up or straight it fits perfect.
Heh, I did state in my post that this code is just pseudo code.. I didn't expect anyone to use it. As I said in my post in the other thread, you would be better off using this code: [lua] local Hats = {} Hats["models/myhat.mdl"] = ClientsideModel("models/myhat.mdl") Hats["models/anotherhat.mdl"] = ClientsideModel("models/anotherhat.mdl") for _, hat in pairs(Hats) do hat:SetNoDraw(true) end hook.Add("PostPlayerDraw", "", function(ply) if ply._Hat then local _Hat = Hats[ply._Hat.Model] _Hat:SetPos(ply:GetPos()) -- and of course offsets _Hat:SetColor(ply._Hat.Color) -- do all sorts.. _Hat:DrawModel() end end) [/lua]
[QUOTE=notRzilla;25529565]Heh, I did state in my post that this code is just pseudo code.. I didn't expect anyone to use it. As I said in my post in the other thread, you would be better off using this code: [lua] local Hats = {} Hats["models/myhat.mdl"] = ClientsideModel("models/myhat.mdl") Hats["models/anotherhat.mdl"] = ClientsideModel("models/anotherhat.mdl") for _, hat in pairs(Hats) do hat:SetNoDraw(true) end hook.Add("PostPlayerDraw", "", function(ply) if ply._Hat then local _Hat = Hats[ply._Hat.Model] _Hat:SetPos(ply:GetPos()) -- and of course offsets _Hat:SetColor(ply._Hat.Color) -- do all sorts.. _Hat:DrawModel() end end) [/lua][/QUOTE] hmm... would you care to explain how I would set the hat for a player?
[QUOTE=Cubar;25528396]He doesn't need you're advice. :wink:[/QUOTE] [img]http://www.zaphu.com/v1/wp-content/uploads/2007/11/grammar-book.jpg[/img]
[QUOTE=Carmine3777;25532726]hmm... would you care to explain how I would set the hat for a player?[/QUOTE] [lua] ply._Hat = {Model = "models/myhat.mdl", Color = Color(255, 255, 255, 255), posOffset = Vector(0, 0, 0), angOffset = Angle(0, 0, 0)} [/lua] [QUOTE=Cubar;25528396]you're advice[/QUOTE] No [b]you are[/b] advice.
Enough with the jokes, now how would I set the hat for a player? I'm guessing I have to use something like ply._Hat = "models/player/items/heavy/heavy_ushanka.mdl" to set it. damn :ninja:
doesn't seem to work... [lua]local CHats = {} CHats["models/player/items/heavy/heavy_ushanka.mdl"] = ClientsideModel("models/player/items/heavy/heavy_ushanka.mdl") CHats["models/error.mdl"] = ClientsideModel("models/error.mdl") for _, hat in pairs(CHats) do hat:SetNoDraw(true) end hook.Add("PostPlayerDraw", "HATS", function(ply) local Bone = ply:LookupBone("ValveBiped.Bip01_Head1") local BonePos = ply:GetBonePosition( Bone ) if ply._Hat then local _Hat = CHats[ply._Hat.Model] _Hat:SetPos(BonePos + Vector(0, 0, 0)) _Hat:SetAngles(ply:EyeAngles() + Angle(0, 0, 0)) _Hat:SetColor(ply._Hat.Color) _Hat:DrawModel() end end)[/lua] [lua]p._Hat = {Model = Hats[i].model, Color = Color(255,255,255,255)} p:ChatPrint("You put on: "..Hats[i].name)[/lua] It does print "You put on: Officer's Ushanka" but I don't see anything on my head. [editline]20th October 2010[/editline] I'm assuming you have to set it clientside, right? [editline]20th October 2010[/editline] Is there any more efficient way to do it than making a usermessage hook for every hat?
Ofc you have to set it client side, just use a usermessage to send this to clients.
[QUOTE=notRzilla;25549404]Ofc you have to set it client side, just use a usermessage to send this to clients.[/QUOTE] Thanks, I just used a table then used for k,v in pairs() do to make usermessages and CModels for every one. Also, when I was playing with my friends, I asked if I had a hat on and they said no. I went into third person mode and I had the hat on but they cant see it. Any suggestions?
I've had this problem too.
Sorry, you need to Log In to post a reply to this thread.