forked from VANCOLD/fm_drive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FM_ENTMOD_CREATE.sma
48 lines (37 loc) · 1.11 KB
/
FM_ENTMOD_CREATE.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
#include "feckinmad/fm_global"
#include "feckinmad/entmod/fm_entmod_misc"
#include "feckinmad/entmod/fm_entmod_base"
#include "feckinmad/entmod/fm_entmod_access"
#include <fakemeta>
public plugin_init()
{
fm_RegisterPlugin()
register_clcmd("fm_ent_create", "Player_CreateEnt")
}
public Player_CreateEnt(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 specify a classname")
return PLUGIN_HANDLED
}
new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sArgs))
if (!iEnt)
{
console_print(id, "Failed to create entity")
return PLUGIN_HANDLED
}
console_print(id, "Created entity: %d %s", iEnt, sArgs)
fm_SetCachedEntKey(iEnt, "classname", sArgs)
new Float:fOrigin[3]; pev(id, pev_origin, fOrigin)
new sBuffer[64]; formatex(sBuffer, charsmax(sBuffer), "%d %d %d", floatround(fOrigin[0]), floatround(fOrigin[1]), floatround(fOrigin[2]))
fm_SetCachedEntKey(iEnt, "origin", sBuffer)
fm_SetKeyValue(iEnt, sArgs, "origin", sBuffer)
return PLUGIN_HANDLED
}