Added new features and customization to base VScript functionality

This commit is contained in:
Blixibon
2020-05-27 10:22:45 -05:00
parent 6ad2745a5e
commit c12418e1ce
11 changed files with 124 additions and 0 deletions

View File

@@ -61,6 +61,12 @@ void ParseScriptTableKeyValues( CBaseEntity *pEntity, HSCRIPT hKV )
void PrecacheEntityFromTable( const char *pszClassname, HSCRIPT hKV )
{
if ( IsEntityCreationAllowedInScripts() == false )
{
Warning( "VScript error: A script attempted to create an entity mid-game. Due to the server's settings, entity creation from scripts is only allowed during map init.\n" );
return;
}
// This is similar to UTIL_PrecacheOther(), but we can't check if we can only precache it once.
// Probably for the best anyway, as similar classes can still have different precachable properties.
CBaseEntity *pEntity = CreateEntityByName( pszClassname );
@@ -79,6 +85,12 @@ void PrecacheEntityFromTable( const char *pszClassname, HSCRIPT hKV )
HSCRIPT SpawnEntityFromTable( const char *pszClassname, HSCRIPT hKV )
{
if ( IsEntityCreationAllowedInScripts() == false )
{
Warning( "VScript error: A script attempted to create an entity mid-game. Due to the server's settings, entity creation from scripts is only allowed during map init.\n" );
return NULL;
}
CBaseEntity *pEntity = CreateEntityByName( pszClassname );
if ( !pEntity )
{
@@ -108,6 +120,12 @@ inline CScriptKeyValues *ToScriptKeyValues( HSCRIPT hKV )
HSCRIPT SpawnEntityFromKeyValues( const char *pszClassname, HSCRIPT hKV )
{
if ( IsEntityCreationAllowedInScripts() == false )
{
Warning( "VScript error: A script attempted to create an entity mid-game. Due to the server's settings, entity creation from scripts is only allowed during map init.\n" );
return NULL;
}
CBaseEntity *pEntity = CreateEntityByName( pszClassname );
if ( !pEntity )
{