PDA

View Full Version : Security Camera Mode (TF2)


Smith_EG
07-22-2016, 12:51
Just thought of an idea for anyone that wants to take this on.
I don't know how the code would look like, or if its even possible, but the idea is the player can set a point on the map that will act as their field of vision, once you set the spot you can only see through that spot untill you delete it. I can imagine players on pub and trade servers using this mod to have a bird's eye view of the map while trading.
I know there's a spectator mode, but the point of this is you can still interact with other players.

Arkarr
07-22-2016, 14:47
Yeah, totally possible. The question is this one : How should it work ?
Like, the player walk somewhere, and type "sm_camera" and then what ? They can't move and just look around ?

Smith_EG
07-22-2016, 14:57
Yeah, totally possible. The question is this one : How should it work ?
Like, the player walk somewhere, and type "sm_camera" and then what ? They can't move and just look around ?

Player walks to whatever spot in the map, they set the command off, then the camera is set stay to wherever the player was looking.
The player on the other hand can still free roam, but will not be able to look at where the player is looking until the command is deactivated
Kind of how third person works, but this camera won't follow you.

That's how I imagined the mod would function

Arkarr
07-22-2016, 15:02
Player walks to whatever spot in the map, they set the command off, then the camera is set stay to wherever the player was looking.
The player on the other hand can still free roam, but will not be able to look at where the player is looking until the command is deactivated
Kind of how third person works, but this camera won't follow you.

That's how I imagined the mod would function
Oh fine, sure I got it. I'll do it if you let me a bit of time.

Smith_EG
07-22-2016, 15:22
Oh fine, sure I got it. I'll do it if you let me a bit of time.

Oh of course man, its really cool you'll take on this project, i'm sure a lot of people will love it!

Arkarr
07-22-2016, 15:27
Oh of course man, its really cool you'll take on this project, i'm sure a lot of people will love it!
Not tested through :

sm_camera - "Enable / Disable camera mode"



#include <sourcemod>
#include <sdktools>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.00"

bool InCameraMode[MAXPLAYERS + 1];
float CameraPosition[MAXPLAYERS + 1][3];

public Plugin myinfo =
{
name = "[ANY] Security Camera",
author = PLUGIN_AUTHOR,
description = "Freeze your view on a specific position",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
};

public void OnPluginStart()
{
RegConsoleCmd("sm_camera", CMD_BecomeCamera, "Start the camera mode");
}

public void OnGameFrame()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && InCameraMode[i])
TeleportEntity(i, NULL_VECTOR, CameraPosition[i], NULL_VECTOR);
}
}

public void OnClientConnected(int client)
{
InCameraMode[client] = false;
}

public Action CMD_BecomeCamera(int client, int args)
{
SetCameraMode(client);
PrintToChat(client, "[SM] Camera mode is now %s", InCameraMode[client] ? "ENABLED" : "DISABLED");

return Plugin_Continue;
}

public void SetCameraMode(int client)
{
InCameraMode[client] = !InCameraMode[client];
if(InCameraMode[client])
GetClientEyePosition(client, CameraPosition[client]);
}

Smith_EG
07-22-2016, 15:43
Not tested through :

sm_camera - "Enable / Disable camera mode"


#include <sourcemod>
#include <sdktools>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.00"

bool InCameraMode[MAXPLAYERS + 1];
float CameraPosition[MAXPLAYERS + 1][3];

public Plugin myinfo =
{
name = "[ANY] Security Camera",
author = PLUGIN_AUTHOR,
description = "Freeze your view on a specific position",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
};

public void OnPluginStart()
{
RegConsoleCmd("sm_camera", CMD_BecomeCamera, "Start the camera mode");
}

public void OnGameFrame()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && InCameraMode[i])
TeleportEntity(i, NULL_VECTOR, CameraPosition[i], NULL_VECTOR);
}
}

public void OnClientConnected(int client)
{
InCameraMode[client] = false;
}

public Action CMD_BecomeCamera(int client, int args)
{
SetCameraMode(client);
PrintToChat(client, "[SM] Camera mode is now %s", InCameraMode[client] ? "ENABLED" : "DISABLED");

return Plugin_Continue;
}

public void SetCameraMode(int client)
{
InCameraMode[client] = !InCameraMode[client];
if(InCameraMode[client])
GetClientEyePosition(client, CameraPosition[client]);
}


That was quick nice, i'll try it out when I get home.

Powerlord
07-25-2016, 02:51
Not tested through :

sm_camera - "Enable / Disable camera mode"


#include <sourcemod>
#include <sdktools>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.00"

bool InCameraMode[MAXPLAYERS + 1];
float CameraPosition[MAXPLAYERS + 1][3];

public Plugin myinfo =
{
name = "[ANY] Security Camera",
author = PLUGIN_AUTHOR,
description = "Freeze your view on a specific position",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
};

public void OnPluginStart()
{
RegConsoleCmd("sm_camera", CMD_BecomeCamera, "Start the camera mode");
}

public void OnGameFrame()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && InCameraMode[i])
TeleportEntity(i, NULL_VECTOR, CameraPosition[i], NULL_VECTOR);
}
}

public void OnClientConnected(int client)
{
InCameraMode[client] = false;
}

public Action CMD_BecomeCamera(int client, int args)
{
SetCameraMode(client);
PrintToChat(client, "[SM] Camera mode is now %s", InCameraMode[client] ? "ENABLED" : "DISABLED");

return Plugin_Continue;
}

public void SetCameraMode(int client)
{
InCameraMode[client] = !InCameraMode[client];
if(InCameraMode[client])
GetClientEyePosition(client, CameraPosition[client]);
}


I don't think GetClientEyePosition can be used to change where someone is looking and there is no SetClientEyePosition.

Arkarr
07-25-2016, 03:40
I don't think GetClientEyePosition can be used to change where someone is looking and there is no SetClientEyePosition.
Uh... I should take more time to read. Anyway, if this function doesn't exist, how can we achieve that (if it's even possible). The view is client sided ?

EDIT:
I could create an entity for exemple 10-15 meters away, and force the client to watch it, wich could do the trick but not sure that's the best way.

ddhoward
07-25-2016, 04:32
It would certainly be the easiest way.

https://sm.alliedmods.net/new-api/sdktools_engine/SetClientViewEntity

also https://forums.alliedmods.net/showthread.php?t=262557

Arkarr
07-25-2016, 04:48
It would certainly be the easiest way.

https://sm.alliedmods.net/new-api/sdktools_engine/SetClientViewEntity

also https://forums.alliedmods.net/showthread.php?t=262557
Yeah, I saw, I ran in the same problem before. The thing is that you can't "split" the body from the eyes.

ddhoward
07-25-2016, 05:23
The only problem I'm experiencing is that the player's body can't turn without also turning the camera. Other than that, my dude runs around just fine while my camera stays put.

Try setting the player to third-person mode, and you'll get as far as I have gotten.

Arkarr
07-25-2016, 06:09
The only problem I'm experiencing is that the player's body can't turn without also turning the camera. Other than that, my dude runs around just fine while my camera stays put.

Try setting the player to third-person mode, and you'll get as far as I have gotten.
Right. Also, the angle I believe, that's what make the camera move up down left right, can be set with TeleportEntity, can't it ?

EDIT:
Also, upgrading the FOV might make the view area bigger.