Prop Hunt Prop Orientation/Rotation HELP!

Hey guys,

So I’m coding a new Prop Hunt server, but I’d like the props to be able to rotate on the x-axis when they hold down their right mouse button. However, no matter how deep I go into the internet, I can’t find any straight forward answer. Does anyone know of any code that could do this?

Any help would be great, honestly.

Thanks!

I honestly hate right click, so I’m gonna use context menu for this
Use v:GetAngles and v:SetAngles to set the player’s prop’s position*, and then use


concommand.Add( "+context_menu", PropOrientationLock )

To make it lock while holding C. If you want right click I think it should be +mouse2, but don’t count on it.

*Should look like this


function PropOrientationLock( ply )
          local propang = ply:GetAngles()
                ply:SetAngles( propang )
end 

This is just some random stuff, and it’s obviously not everything, but that’s pretty much it (Correct me if I’m wrong, just trying to help =3)

EDIT: Woops, I mixed Pos with Ang.
Fixed.

+attack2 is what it is. Personally I don’t like overwriting the default cvars so I’d use something like PlayerBindPress hook.

ex with your code:



hook.Add("PlayerBindPress","PH_Orientation",function(ply, bind, pressed)
	if pressed and bind == "+attack2" then
		PropOrientationLock()
	end
end)


Where does this go? I’ll test it out once I know where to put the code.

Also, is it possible that props could be automatically locked, but when the right mouse button is held they can rotate on the x-axis?

Thanks so much for your help as well guys!



function PropOrientationLock( ply )
          local yaxis = ply:GetAngles().y
          local zaxis = ply:GetAngles().z
          local axislock = Vector(ply:GetAngles().x,yaxis+0,zaxis+0)
                ply:SetAngles( axislock)
end


Untested, might not work as expected. I’m bad with angle stuff

File placement I don’t know as it’s a clientside hook running serverside code. Might need to mess a bit with netmessages (which I’m also bad at)

Hey, so I just got back here. Right so none of the codes above seem to actually work, wherever I put them. Including shared filed and init files.

This seems to be proving difficult.

I shall have a go at the code myself as well and see if I can get anything from it.

[editline]7th September 2014[/editline]

Actually, surely the first place to start would be to allow the props to see themselves as how they appear to the hunters, instead of seeing the prop rotating wherever they look.

I don’t know if that made sense or not, but yeah.

Once this has been achieved then it would be easier to figure out a way to rotate the prop using a specific key by finding the position of the crosshair and rotating the prop accordingly to match with the crosshair (along the x-axis of course). That should make things easier to go with.

Anyone got anything?