Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Commit

Permalink
Version 0.0.11
Browse files Browse the repository at this point in the history
- Implemented support of other camera entitys.
  • Loading branch information
Nord1cWarr1or committed Jan 16, 2021
1 parent 758c9a3 commit ac9db3e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripting/AFK-Protection_3D_camera.sma
Expand Up @@ -25,7 +25,7 @@
#include <msgstocks>
#include <afk_protection>

new const PLUGIN_VERSION[] = "0.0.10";
new const PLUGIN_VERSION[] = "0.0.11";

#define AUTO_CONFIG // Comment out if you don't want the plugin config to be created automatically in "configs/plugins"

Expand All @@ -48,6 +48,7 @@ new g_pCvarValue[Cvars];
new g_iCvarValue_RoundTime;
new g_iRotatingSide[MAX_PLAYERS + 1];
new g_iCameraEnt[MAX_PLAYERS + 1] = { NULLENT, ... };
new g_iPreviousPlayerView[MAX_PLAYERS + 1] = { NULLENT, ... };

public plugin_init()
{
Expand Down Expand Up @@ -104,6 +105,8 @@ public OnPlayerBack_post(const pPlayer)
public client_disconnected(pPlayer)
{
RemoveCam(pPlayer, false);

g_iPreviousPlayerView[pPlayer] = NULLENT;
}

public RG_PlayerSpawn_Post(const pPlayer)
Expand Down Expand Up @@ -151,6 +154,8 @@ CreateCam(const pPlayer)
set_entvar(iCameraEnt, var_solid, SOLID_NOT);
set_entvar(iCameraEnt, var_movetype, MOVETYPE_NOCLIP);
set_entvar(iCameraEnt, var_rendermode, kRenderTransColor);

g_iPreviousPlayerView[pPlayer] = get_viewent(pPlayer);

engset_view(pPlayer, iCameraEnt);
client_cmd(pPlayer, "stopsound");
Expand All @@ -165,7 +170,7 @@ RemoveCam(pPlayer, bool:bAttachViewToPlayer)
{
if(bAttachViewToPlayer)
{
engset_view(pPlayer, pPlayer);
engset_view(pPlayer, g_iPreviousPlayerView[pPlayer]);
client_cmd(pPlayer, "stopsound");
}

Expand All @@ -176,7 +181,7 @@ RemoveCam(pPlayer, bool:bAttachViewToPlayer)
if(!is_entity(iCameraEnt))
continue;

if(get_entvar(iCameraEnt, var_owner) == pPlayer)
if(get_entvar(iCameraEnt, var_owner) == pPlayer && g_iCameraEnt[pPlayer] == iCameraEnt)
{
set_entvar(iCameraEnt, var_flags, FL_KILLME);

Expand Down

0 comments on commit ac9db3e

Please sign in to comment.