forked from VANCOLD/fm_drive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FM_ENTMOD_LASER.sma
114 lines (84 loc) · 3.33 KB
/
FM_ENTMOD_LASER.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "feckinmad/fm_global"
#include "feckinmad/fm_point" // fm_GetAimEntity() && fm_GetAimOrigin()
#include "feckinmad/entmod/fm_entmod_base" // fm_SetCachedEntKey()
#include "feckinmad/entmod/fm_entmod_access" // fm_CheckUserEntAccess()
#include "feckinmad/entmod/fm_entmod_misc"
#include <fakemeta>
new g_sLaserEntity[] = "env_laser"
new g_sInfoTarget[] = "info_target"
public plugin_init()
{
fm_RegisterPlugin()
register_clcmd("fm_ent_startlaser", "Player_CreateLaserStart")
register_clcmd("fm_ent_endlaser", "Player_CreateLaserEnd")
}
public plugin_precache()
engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr")
public Player_CreateLaserStart(id)
{
if (!fm_CheckUserEntAccess(id))
return PLUGIN_HANDLED
new sArgs[32]; read_args(sArgs, charsmax(sArgs))
trim(sArgs)
if (!sArgs[0])
{
console_print(id, "You must supply a name for the laser")
return PLUGIN_HANDLED
}
new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, g_sLaserEntity))
if (!iEnt)
{
console_print(id, "Failed to create \"%s\" entity", g_sLaserEntity)
return PLUGIN_HANDLED
}
console_print(id, "Created laser \"%s\" start entity (#%d)", sArgs, iEnt)
fm_SetCachedEntKey(iEnt, "classname", g_sLaserEntity) // Store classname
fm_SetKeyValue(iEnt, g_sLaserEntity, "spawnflags", "1") // Start On
fm_SetCachedEntKey(iEnt, "spawnflags", "1")
fm_SetKeyValue(iEnt, g_sLaserEntity, "renderamt", "100")
fm_SetCachedEntKey(iEnt, "renderamt", "100")
fm_SetKeyValue(iEnt, g_sLaserEntity, "rendercolor", "255 0 0")
fm_SetCachedEntKey(iEnt, "rendercolor", "255 0 0")
fm_SetKeyValue(iEnt, g_sLaserEntity, "width", "25")
fm_SetCachedEntKey(iEnt, "width", "25")
fm_SetKeyValue(iEnt, g_sLaserEntity, "TextureScroll", "35")
fm_SetCachedEntKey(iEnt, "TextureScroll", "35")
fm_SetKeyValue(iEnt, g_sLaserEntity, "texture", "sprites/laserbeam.spr")
fm_SetCachedEntKey(iEnt, "texture", "sprites/laserbeam.spr")
fm_SetKeyValue(iEnt, g_sLaserEntity, "damage", "0")
fm_SetCachedEntKey(iEnt, "damage", "0")
fm_SetKeyValue(iEnt, g_sLaserEntity, "LaserTarget", sArgs)
fm_SetCachedEntKey(iEnt, "LaserTarget", sArgs)
new Float:fOrigin[3]; fm_GetAimOrigin(id, fOrigin)
new sBuffer[64]; formatex(sBuffer, charsmax(sBuffer), "%0.4f %0.4f %0.4f", fOrigin[0], fOrigin[1], fOrigin[2])//floatround(fOrigin[0]), floatround(fOrigin[1]), floatround(fOrigin[2]))
fm_SetKeyValue(iEnt, g_sLaserEntity, "origin", sBuffer)
fm_SetCachedEntKey(iEnt, "origin", sBuffer)
dllfunc(DLLFunc_Spawn, iEnt)
return PLUGIN_HANDLED
}
public Player_CreateLaserEnd(id)
{
if (!fm_CheckUserEntAccess(id))
return PLUGIN_HANDLED
new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, g_sInfoTarget))
if (!iEnt)
{
console_print(id, "Failed to create \"%s\" entity", g_sInfoTarget)
return PLUGIN_HANDLED
}
fm_SetCachedEntKey(iEnt, "classname", g_sInfoTarget) // Store classname
new sArgs[32]; read_args(sArgs, charsmax(sArgs))
trim(sArgs)
if (!sArgs[0])
{
console_print(id, "You must supply a name for the laser")
return PLUGIN_HANDLED
}
set_pev(iEnt, pev_targetname, sArgs)
fm_SetCachedEntKey(iEnt, "targetname", sArgs)
new Float:fOrigin[3]; fm_GetAimOrigin(id, fOrigin)
set_pev(iEnt, pev_origin, fOrigin)
fm_SetCachedEntKeyVector(iEnt, "origin", fOrigin)
console_print(id, "Created laser \"%s\" end entity (#%d)", sArgs, iEnt)
return PLUGIN_HANDLED
}