Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observer Reset Config Option #3

Merged
merged 3 commits into from
Jul 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local Clockwork = Clockwork;

Clockwork.config:AddToSystem("Observer Reset", "observerReset", "Whether or not observer mode resets the player's position to where they were originally.", true);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
� 2013 CloudSixteen.com do not share, re-distribute or modify
� 2013 CloudSixteen.com do not share, re-distribute or modify
without permission of its author ([email protected]).
--]]

Expand All @@ -12,4 +12,5 @@ PLUGIN:SetGlobalAlias("cwObserverMode");
--[[ You don't have to do this either, but I prefer to seperate the functions. --]]
Clockwork.kernel:IncludePrefixed("sv_plugin.lua");
Clockwork.kernel:IncludePrefixed("sv_hooks.lua");
Clockwork.kernel:IncludePrefixed("cl_hooks.lua");
Clockwork.kernel:IncludePrefixed("cl_hooks.lua");
Clockwork.kernel:IncludePrefixed("cl_plugin.lua");
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
--[[
2013 CloudSixteen.com do not share, re-distribute or modify
© 2013 CloudSixteen.com do not share, re-distribute or modify
without permission of its author ([email protected]).
--]]

Clockwork.config:Add("observerReset", true, true);

-- A function to make a player exit observer mode.
function cwObserverMode:MakePlayerExitObserverMode(player)
local observerReset = Clockwork.config:Get("observerReset"):Get()
player.cwObserverReset = true;
player:DrawWorldModel(true);
player:DrawShadow(true);
Expand All @@ -14,12 +17,14 @@ function cwObserverMode:MakePlayerExitObserverMode(player)

timer.Simple(FrameTime() * 0.5, function()
if (IsValid(player)) then
if (player.cwObserverPos) then
player:SetPos(player.cwObserverPos);
end;
if(observerReset == true) then
if (player.cwObserverPos) then
player:SetPos(player.cwObserverPos);
end;

if (player.cwObserverAng) then
player:SetEyeAngles(player.cwObserverAng);
if (player.cwObserverAng) then
player:SetEyeAngles(player.cwObserverAng);
end;
end;

if (player.cwObserverColor) then
Expand All @@ -43,4 +48,4 @@ function cwObserverMode:MakePlayerEnterObserverMode(player)
player.cwObserverColor = player:GetColor();
player.cwObserverMode = true;
player:SetMoveType(MOVETYPE_NOCLIP);
end;
end;