Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hook.Add("KeyPress", "surface_sit", function(ply, key)
- if not ply:GetVehicle():IsValid() and key == IN_USE and ply:KeyDown(IN_WALK) then
- local trace = util.QuickTrace(ply:EyePos(), ply:GetAimVector() * 100, ply)
- if trace.Hit and not trace.Entity:IsPlayer() and not trace.Entity:IsNPC() then
- local angle = trace.HitNormal:Angle()
- angle:RotateAroundAxis(angle:Up(), 90)
- angle:RotateAroundAxis(angle:Forward(), 90)
- angle:RotateAroundAxis(trace.HitNormal, math.AngleDifference(ply:EyeAngles().y, 180))
- print(math.Round(angle.p), math.Round(angle.y), math.Round(angle.r))
- --if math.abs(angle.r) > 45 then return end
- local ent = ents.Create("weapon_seat")
- ent:SetModel("models/nova/airboat_seat.mdl")
- ent:SetPos(trace.HitPos - (trace.HitNormal * 2))
- ent:SetAngles(angle)
- ent.up_offset = 43.5
- ent.right_offset = 1.75
- ent.forward_offset = 0
- ent.surface_sit = true
- ent:Spawn()
- ent:SetStoolSeat(true)
- ply:EnterVehicle(ent)
- if trace.Entity:IsValid() and not trace.Entity:IsWorld() then
- ent:GetPhysicsObject():EnableMotion(true)
- constraint.Weld(trace.Entity, ent, 0, 0, 0, true)
- trace.Entity:CallOnRemove("surface_sit"..ply:UniqueID(), function()
- if ent:IsVehicle() then
- ent:Remove()
- end
- end)
- else
- ent:SetMoveType(MOVETYPE_NONE)
- end
- end
- end
- end)
- hook.Add("PlayerLeaveVehicle", "surface_sit", function(ply, ent)
- if ent.surface_sit then
- ent:Remove()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment