mirror of
https://github.com/celisej567/source-sdk-2013.git
synced 2026-09-23 20:09:45 +03:00
Added logic_script_client entity and a user message for calling a client-side function
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
#include "saverestore_utlvector.h"
|
||||
#include "props_shared.h"
|
||||
#include "utlbuffer.h"
|
||||
#include "usermessages.h"
|
||||
#ifdef CLIENT_DLL
|
||||
#include "hud_closecaption.h"
|
||||
#include "panelmetaclassmgr.h"
|
||||
#include "c_soundscape.h"
|
||||
#include "hud_macros.h"
|
||||
#else
|
||||
#include "soundscape_system.h"
|
||||
#include "AI_ResponseSystem.h"
|
||||
@@ -616,3 +618,48 @@ BEGIN_DATADESC( CMapbaseManifestEntity )
|
||||
|
||||
END_DATADESC()
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
void __MsgFunc_CallClientScriptFunction( bf_read &msg )
|
||||
{
|
||||
char szFunction[64];
|
||||
if (!msg.ReadString( szFunction, sizeof( szFunction ) ))
|
||||
{
|
||||
CGMsg( 0, CON_GROUP_VSCRIPT, "Unable to read function string\n" );
|
||||
}
|
||||
|
||||
int idx = msg.ReadByte();
|
||||
C_BaseEntity *pEntity = CBaseEntity::Instance( idx );
|
||||
|
||||
if (pEntity)
|
||||
{
|
||||
if (pEntity->m_ScriptScope.IsInitialized())
|
||||
{
|
||||
//CGMsg( 0, CON_GROUP_VSCRIPT, "%s calling function \"%s\"\n", pEntity->GetDebugName(), szFunction );
|
||||
pEntity->CallScriptFunction( szFunction, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
CGMsg( 0, CON_GROUP_VSCRIPT, "%s scope not initialized\n", pEntity->GetDebugName() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGMsg( 0, CON_GROUP_VSCRIPT, "Clientside entity not found for script function (index %i)\n", idx );
|
||||
}
|
||||
}
|
||||
|
||||
void HookMapbaseUserMessages( void )
|
||||
{
|
||||
HOOK_MESSAGE( CallClientScriptFunction );
|
||||
}
|
||||
#endif
|
||||
|
||||
void RegisterMapbaseUserMessages( void )
|
||||
{
|
||||
usermessages->Register( "CallClientScriptFunction", -1 );
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
HookMapbaseUserMessages();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user