forked from ben-watch/feckinmad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FM_PMODEL_CAMERA.sma
83 lines (64 loc) · 1.59 KB
/
FM_PMODEL_CAMERA.sma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "feckinmad/fm_global"
#include "feckinmad/fm_playermodel_api"
#include <fakemeta>
new g_iPlayerCameraEnt[MAX_PLAYERS + 1] // Entity ID of their camera
public fm_PlayerModelMenuEnter(id)
{
CreateCamera(id)
}
public fm_PlayerModelMenuExit(id, sMenuSelection[MENU_TYPE_COUNT])
{
ResetView(id)
}
CreateCamera(id)
{
DestroyCamera(id)
new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if (!iEnt)
{
fm_WarningLog(FM_ENT_WARNING)
return PLUGIN_HANDLED
}
g_iPlayerCameraEnt[id] = iEnt
engfunc(EngFunc_SetModel, iEnt, "models/backpack.mdl") // Must have a model or setview doesn't work.
set_pev(iEnt, pev_rendermode, kRenderTransTexture)
set_pev(iEnt, pev_renderamt, 0.0)
new Float:fOrigin[3]; pev(id, pev_origin, fOrigin)
new Float:fAngle[3]; pev(id, pev_v_angle, fAngle)
fAngle[0] = 0.0
fAngle[2] = 0.0
new Float:fVBack[3]; angle_vector(fAngle, ANGLEVECTOR_FORWARD, fVBack)
fOrigin[0] += (fVBack[0] * 64.0)
fOrigin[1] += (fVBack[1] * 64.0)
fOrigin[2] += (fVBack[2] * 64.0)
engfunc(EngFunc_SetOrigin, iEnt, fOrigin)
// Reverse angle
if (fAngle[1] < 0.0)
{
fAngle[1] += 180.0
}
else
{
fAngle[1] -=180.0
}
set_pev(iEnt, pev_angles, fAngle)
engfunc(EngFunc_SetView, id, iEnt)
return PLUGIN_HANDLED
}
DestroyCamera(id)
{
if (g_iPlayerCameraEnt[id])
{
engfunc(EngFunc_RemoveEntity, g_iPlayerCameraEnt[id])
g_iPlayerCameraEnt[id] = 0
}
}
public ResetView(id)
{
engfunc(EngFunc_SetView, id, id)
DestroyCamera(id)
}
public client_disconnected(id)
{
DestroyCamera(id)
}