Spectator Mode by menu

ZycaRZycaR Join Date: 2002-11-12 Member: 8263Members
edited August 2012 in Modding
<div class="IPBDescription">FreeLook/Overhead/Following</div>Here is simple modification of Spectator.lua file, which will give you "menu" for changing spectator Mode from these types FreeLook/Overhead/Following. Simply hit "Z" as Sectator.

NOTE: maybe someone relaize that new players will appreciate CounterStrike like menu's to change spectator view and put it into official.

Put these somewhere to Spectator.lua
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function Spectator:GetHasSayings()
    return true
end

function Spectator:GetSayings()
   if(self.showSayings) then
        if(self.showSayingsMenu == 1) then
            return {"1. Free Look", "2. Overhead", "3. Following"}
        else
            return
        end
    end
    return nil
end

function Spectator:ExecuteSaying(index, menu)
    Player.ExecuteSaying(self, index, menu)
    if Server and menu == 1 then
        if index == 1 then
            self:SetSpectatorMode(Spectator.kSpectatorMode.FreeLook)
        elseif index == 2 then
            self:SetSpectatorMode(Spectator.kSpectatorMode.Overhead)                
        elseif index == 3 then
            self:SetSpectatorMode(Spectator.kSpectatorMode.Following)
        end
    end
end<!--c2--></div><!--ec2-->

modify end of "function Spectator:OverrideInput(input)"
to make Sayings work in spectator mode

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->...
        ClampInputPitch(input)
        
        if self.OverrideSayingsMenu then
            self:OverrideSayingsMenu(input)
        end
        
        if self.OverrideMove then
            input = self:OverrideMove(input)
        end
        
        return input
        
    end<!--c2--></div><!--ec2-->

Edit: code is Free to use :D no rights of course ...
Sign In or Register to comment.