We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8068245 commit 4fec545Copy full SHA for 4fec545
4 files changed
src/core/core/sp_main.cpp
@@ -137,7 +137,7 @@ InterfaceHelper_t gGameInterfaces[] = {
137
{INTERFACEVERSION_PLAYERBOTMANAGER, (void **)&botmanager},
138
{IEFFECTS_INTERFACE_VERSION, (void **)&effects},
139
{INTERFACEVERSION_SERVERGAMEDLL, (void **)&servergamedll},
140
-#if( SOURCE_ENGINE >= 2 )
+#if( SOURCE_ENGINE >= 1 )
141
{VSERVERTOOLS_INTERFACE_VERSION, (void **)&servertools},
142
#endif
143
{NULL, NULL}
src/core/modules/entities/entities_wrap.cpp
@@ -134,6 +134,13 @@ void CEdictExt::SetPropVector( edict_t* pEdict, const char* prop_name, Vector ve
134
prop.Set<Vector>(vecValue);
135
}
136
+const char* CEdictExt::GetKeyValue(edict_t* pEdict, const char* szName)
+{
+ char szResult[1024];
+ CBaseEntity* pEntity = pEdict->GetUnknown()->GetBaseEntity();
+ servertools->GetKeyValue(pEntity, szName, szResult, 1024);
+ return szResult;
+}
144
145
//-----------------------------------------------------------------------------
146
// CSendProp code.
src/core/modules/entities/entities_wrap.h
@@ -32,7 +32,10 @@
32
#include "edict.h"
33
#include "server_class.h"
34
#include <cstdint>
35
+#include "toolframework/itoolentity.h"
36
37
+// Externals
38
+extern IServerTools* servertools;
39
40
//---------------------------------------------------------------------------------
41
// edict_t extension
@@ -49,6 +52,15 @@ class CEdictExt
49
52
static void SetPropFloat( edict_t* pEdict, const char* prop_name, float flValue );
50
53
static void SetPropString( edict_t* pEdict, const char* prop_name, const char* szValue );
51
54
static void SetPropVector( edict_t* pEdict, const char* prop_name, Vector vecValue );
55
+
56
+ static const char* GetKeyValue(edict_t* pEdict, const char* szName);
57
58
+ template<class T>
59
+ static void SetKeyValue(edict_t* pEdict, const char* szName, T value)
60
+ {
61
62
+ servertools->SetKeyValue(pEntity, szName, value);
63
+ }
64
};
65
66
src/core/modules/entities/entities_wrap_python.cpp
@@ -416,6 +416,36 @@ void export_edict()
416
args("prop_name", "value")
417
)
418
419
+ .def("get_key_value",
420
+ &CEdictExt::GetKeyValue,
421
+ "Returns the value of the given field name.",
422
+ args("field_name")
423
+ )
424
425
+ .def("set_key_value_int",
426
+ &CEdictExt::SetKeyValue<int>,
427
+ "Sets a field to the given value.",
428
+ args("field_name", "value")
429
430
431
+ .def("set_key_value_float",
432
+ &CEdictExt::SetKeyValue<float>,
433
434
435
436
437
+ .def("set_key_value_string",
438
+ &CEdictExt::SetKeyValue<const char *>,
439
440
441
442
443
+ .def("set_key_value_vector",
444
+ &CEdictExt::SetKeyValue<Vector>,
445
446
447
448
449
// Class attributes
450
/*
451
// TODO: Missing on CS:GO
0 commit comments