Open Glebux opened 3 weeks ago
per player or globally? Also I think setting the spectator should already be possible like this:
-- Note: This is just and Idea and untested
hook.Add("HolyLib:OnSourceTVCommand", "Example", function(client, name, args, argString)
if name == "Spectate" then
local event = gameevent.Create("hltv_changed_target")
event:SetInt("mode", OBS_MODE_CHASE)
event:SetInt("obs_target", player.GetBySteamID(args[1]))
event:SetInt("old_target", 0) -- Is this even required? idk
client:FireEvent(event)
return true
end
end)
But I will definetly add a proper function so that the engine won't override anything possibly.
The function should set the camera man globally, yes. But if the user wants more control then something like the pseudo code you provided would certainly do.
I've done some testing, and it turns out that "hltv_changed_target" fails to initiate, and "hltv_cameraman" is what exactly needed. Also after a few seconds the autodirector regains control of the camera, so a think function for hltv clients would be also required.
I added the HolyLib:OnSourceTVStartNewShot
to allow one to cancel it changing the shot.
Simply return true
in the hook to cancel it.
So a while ago I added HLTVClient:SetCameraMan
and sourcetv.SetCameraMan
which should work but I didn't test it yet.
Make it possible to properly set the current camera man with
sourcetv.SetCameraMan
, And also call a hook "HolyLib:ShouldBecomeCameraMan" when a spectator presses the USE key, as the valve dev wiki stated.