Refactoring of CLuaArgument, CLuaArguments and CLuaFunctionDefinitions.

Fixed memory leaks.
Fixed some performance issues.
Fixed CMonoFunctions::Element::GetByType.
This commit is contained in:
Kernell 2015-12-27 19:41:07 +03:00
parent 9809a54479
commit f395553923
13 changed files with 1137 additions and 1087 deletions

View File

@ -60,36 +60,46 @@ public:
MonoString* NewString ( const char* szText ); MonoString* NewString ( const char* szText );
MonoString* NewString ( string strText ); MonoString* NewString ( string strText );
template <class T, int LuaType> template <class T, int iLuaType>
MonoArray* NewArray ( MonoClass* pMonoClass, CLuaArguments* pLuaArguments = NULL ) MonoArray* NewArray ( MonoClass* pMonoClass, CLuaArgumentsVector* pLuaArguments = nullptr )
{ {
MonoArray* pArray = mono_array_new( this->m_pDomain, pMonoClass, pLuaArguments ? pLuaArguments->Count() : 0 ); MonoArray* pArray = mono_array_new( this->m_pDomain, pMonoClass, pLuaArguments ? pLuaArguments->size() : 0 );
if( pLuaArguments ) if( pLuaArguments )
{ {
int i = 0; int i = 0;
for( auto iter : pLuaArguments->GetArguments() ) for( const auto& pArgument : *pLuaArguments )
{ {
if( LuaType == LUA_TBOOLEAN ) switch( iLuaType )
{ {
mono_array_set( pArray, T, i++, (T)( iter->GetBoolean() ) ); case LUA_TBOOLEAN:
} {
else if( LuaType == LUA_TLIGHTUSERDATA ) mono_array_set( pArray, T, i++, (T)( pArgument.GetBoolean() ) );
{
mono_array_set( pArray, T, i++, (T)( iter->GetLightUserData() ) ); break;
} }
else if( LuaType == LUA_TNUMBER ) case LUA_TNUMBER:
{ {
mono_array_set( pArray, T, i++, iter->GetNumber< T >() ); mono_array_set( pArray, T, i++, pArgument.GetNumber< T >() );
}
else if( LuaType == LUA_TSTRING ) break;
{ }
mono_array_set( pArray, T, i++, (T)( iter->GetString() ) ); case LUA_TSTRING:
} {
else if( LuaType == LUA_TUSERDATA ) MonoString* msValue = this->NewString( pArgument.GetString() );
{
mono_array_set( pArray, T, i++, (T)( iter->GetLightUserData() ) ); mono_array_set( pArray, MonoString*, i++, msValue );
break;
}
case LUA_TLIGHTUSERDATA:
case LUA_TUSERDATA:
{
mono_array_set( pArray, T, i++, reinterpret_cast< T >( pArgument.GetLightUserData() ) );
break;
}
} }
} }
} }

View File

@ -815,22 +815,22 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
LuaTable pLuaTable = CLuaFunctionDefinitions::GetVersion( RESOURCE->GetLua() ); CLuaArgumentsMap pLuaTable = CLuaFunctionDefinitions::GetVersion( RESOURCE->GetLua() );
if( !pLuaTable.empty() ) if( pLuaTable.size() >= 8 )
{ {
unsigned long ulNumber = pLuaTable[ "number" ]->GetNumber< unsigned long >(); unsigned long ulNumber = pLuaTable[ "number" ].GetNumber< unsigned long >();
const char* szString = pLuaTable[ "mta" ]->GetString(); const char* szString = pLuaTable[ "mta" ].GetString();
const char* szName = pLuaTable[ "name" ]->GetString(); const char* szName = pLuaTable[ "name" ].GetString();
const char* szBuildType = pLuaTable[ "type" ]->GetString(); const char* szBuildType = pLuaTable[ "type" ].GetString();
unsigned long ulNetcode = pLuaTable[ "netcode" ]->GetNumber< unsigned long >(); unsigned long ulNetcode = pLuaTable[ "netcode" ].GetNumber< unsigned long >();
const char* szOS = pLuaTable[ "os" ]->GetString(); const char* szOS = pLuaTable[ "os" ].GetString();
const char* szBuildTag = pLuaTable[ "tag" ]->GetString(); const char* szBuildTag = pLuaTable[ "tag" ].GetString();
const char* szSortable = pLuaTable[ "sortable" ]->GetString(); const char* szSortable = pLuaTable[ "sortable" ].GetString();
CMonoCorlib* pLib = RESOURCE->GetDomain()->GetCorlib(); CMonoCorlib* pLib = RESOURCE->GetDomain()->GetCorlib();
PVOID* args = new PVOID[ 8 ]; PVOID* args = new PVOID[ pLuaTable.size() ];
MonoObject* pNumber = pLib->Class[ "uint64" ]->Box( &ulNumber ); MonoObject* pNumber = pLib->Class[ "uint64" ]->Box( &ulNumber );
MonoString* pString = RESOURCE->GetDomain()->NewString( szString ); MonoString* pString = RESOURCE->GetDomain()->NewString( szString );
@ -850,11 +850,15 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
args[ 6 ] = pBuildTag; args[ 6 ] = pBuildTag;
args[ 7 ] = pSortable; args[ 7 ] = pSortable;
return RESOURCE->GetDomain()->GetMTALib()->GetClass( "ServerVersion" )->New( args, 8 ); MonoObject* pObject = RESOURCE->GetDomain()->GetMTALib()->GetClass( "ServerVersion" )->New( args, pLuaTable.size() );
delete [] args;
return pObject;
} }
} }
return NULL; return nullptr;
} }
MonoString* CMonoFunctions::Game::GetType( void ) MonoString* CMonoFunctions::Game::GetType( void )

View File

@ -31,9 +31,12 @@ MonoArray* CMonoFunctions::Account::GetAll( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaTable = CLuaFunctionDefinitions::GetAccounts( RESOURCE->GetLua() ); CLuaArgumentsVector pLuaTable = CLuaFunctionDefinitions::GetAccounts( RESOURCE->GetLua() );
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), pLuaTable ); if( pLuaTable.size() > 0 )
{
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaTable );
}
} }
return nullptr; return nullptr;

View File

@ -66,9 +66,12 @@ MonoArray* CMonoFunctions::Element::GetByType( MonoString* msType, DWORD pStartE
{ {
const char* szType = mono_string_to_utf8( msType ); const char* szType = mono_string_to_utf8( msType );
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetElementsByType( RESOURCE->GetLua(), szType, (void*)pStartElement ); CLuaArgumentsVector pLuaArguments = CLuaFunctionDefinitions::GetElementsByType( RESOURCE->GetLua(), szType, (PVOID)pStartElement );
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), pLuaArguments ); if( pLuaArguments.size() )
{
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaArguments );
}
} }
return nullptr; return nullptr;
@ -454,11 +457,11 @@ DWORD CMonoFunctions::Element::GetLowLod( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
void* pUserData; PVOID pLODUserData;
if( CLuaFunctionDefinitions::GetLowLodElement( RESOURCE->GetLua(), (void*)pUserData, pUserData ) ) if( CLuaFunctionDefinitions::GetLowLodElement( RESOURCE->GetLua(), (PVOID)pUserData, pLODUserData ) )
{ {
return (DWORD)pUserData; return (DWORD)pLODUserData;
} }
} }

View File

@ -124,20 +124,11 @@ MonoArray* CMonoFunctions::Player::GetAlivePlayers( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetAlivePlayers( RESOURCE->GetLua() ); CLuaArgumentsVector pLuaArguments = CLuaFunctionDefinitions::GetAlivePlayers( RESOURCE->GetLua() );
if( pLuaArguments ) if( pLuaArguments.size() > 0 )
{ {
MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_uint32_class(), pLuaArguments->Count() ); return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaArguments );
vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin();
for( unsigned int i = 0; iter != pLuaArguments->IterEnd(); iter++, i++ )
{
mono_array_set( pArray, DWORD, i, (DWORD)( *iter )->GetLightUserData() );
}
return pArray;
} }
} }
@ -148,20 +139,11 @@ MonoArray* CMonoFunctions::Player::GetDeadPlayers( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetDeadPlayers( RESOURCE->GetLua() ); CLuaArgumentsVector pLuaArguments = CLuaFunctionDefinitions::GetDeadPlayers( RESOURCE->GetLua() );
if( pLuaArguments ) if( pLuaArguments.size() > 0 )
{ {
MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_uint32_class(), pLuaArguments->Count() ); return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaArguments );
vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin();
for( unsigned int i = 0; iter != pLuaArguments->IterEnd(); iter++, i++ )
{
mono_array_set( pArray, DWORD, i, (DWORD)( *iter )->GetLightUserData() );
}
return pArray;
} }
} }
@ -337,15 +319,15 @@ MonoObject* CMonoFunctions::Player::GetACInfo( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
LuaTable pLuaTable = CLuaFunctionDefinitions::GetPlayerACInfo( RESOURCE->GetLua(), (void*)pUserData ); CLuaArgumentsMap* pLuaTable = CLuaFunctionDefinitions::GetPlayerACInfo( RESOURCE->GetLua(), (PVOID)pUserData );
if( !pLuaTable.empty() ) if( pLuaTable )
{ {
MonoString* msDetectedAC = RESOURCE->GetDomain()->NewString( pLuaTable[ "DetectedAC" ]->GetString() ); MonoString* msDetectedAC = RESOURCE->GetDomain()->NewString( (*pLuaTable)[ "DetectedAC" ].GetString() );
MonoString* msD3D9MD5 = RESOURCE->GetDomain()->NewString( pLuaTable[ "d3d9MD5" ]->GetString() ); MonoString* msD3D9MD5 = RESOURCE->GetDomain()->NewString( (*pLuaTable)[ "d3d9MD5" ].GetString() );
MonoString* msD3D9SHA256 = RESOURCE->GetDomain()->NewString( pLuaTable[ "d3d9SHA256" ]->GetString() ); MonoString* msD3D9SHA256 = RESOURCE->GetDomain()->NewString( (*pLuaTable)[ "d3d9SHA256" ].GetString() );
unsigned int iD3D9Size = pLuaTable[ "d3d9Size" ]->GetNumber< unsigned int >(); unsigned int iD3D9Size = (*pLuaTable)[ "d3d9Size" ].GetNumber< unsigned int >();
void *args[] = void *args[] =
{ {

View File

@ -177,9 +177,12 @@ MonoArray* CMonoFunctions::Resource::GetResources( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaTable = CLuaFunctionDefinitions::GetResources( RESOURCE->GetLua() ); CLuaArgumentsVector pLuaTable = CLuaFunctionDefinitions::GetResources( RESOURCE->GetLua() );
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), pLuaTable ); if( pLuaTable.size() > 0 )
{
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaTable );
}
} }
return NULL; return NULL;

View File

@ -30,7 +30,7 @@ DWORD CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObje
if( numberplate && mono_string_length( numberplate ) > 0 ) if( numberplate && mono_string_length( numberplate ) > 0 )
{ {
sNumberplate = string( mono_string_to_utf8( numberplate ) ); sNumberplate = mono_string_to_utf8( numberplate );
} }
return (DWORD)CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, sNumberplate, direction, variant1, variant2 ); return (DWORD)CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, sNumberplate, direction, variant1, variant2 );
@ -198,12 +198,15 @@ MonoArray* CMonoFunctions::Vehicle::GetOccupants( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehicleOccupants( RESOURCE->GetLua(), (void*)pUserData ); CLuaArgumentsVector pLuaArguments = CLuaFunctionDefinitions::GetVehicleOccupants( RESOURCE->GetLua(), (PVOID)pUserData );
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), pLuaArguments ); if( pLuaArguments.size() > 0 )
{
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaArguments );
}
} }
return NULL; return nullptr;
} }
DWORD CMonoFunctions::Vehicle::GetController( DWORD pUserData ) DWORD CMonoFunctions::Vehicle::GetController( DWORD pUserData )
@ -280,9 +283,12 @@ MonoArray* CMonoFunctions::Vehicle::GetOfType( unsigned int uiModel )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehiclesOfType( RESOURCE->GetLua(), uiModel ); CLuaArgumentsVector pLuaArguments = CLuaFunctionDefinitions::GetVehiclesOfType( RESOURCE->GetLua(), uiModel );
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), pLuaArguments ); if( pLuaArguments.size() > 0 )
{
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaArguments );
}
} }
return NULL; return NULL;
@ -307,9 +313,12 @@ MonoArray* CMonoFunctions::Vehicle::GetUpgrades( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehicleUpgrades( RESOURCE->GetLua(), (void*)pUserData ); CLuaArgumentsVector pLuaArguments = CLuaFunctionDefinitions::GetVehicleUpgrades( RESOURCE->GetLua(), (void*)pUserData );
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TNUMBER>( mono_get_uint32_class(), pLuaArguments ); if( pLuaArguments.size() > 0 )
{
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TNUMBER>( mono_get_uint32_class(), &pLuaArguments );
}
} }
return NULL; return NULL;
@ -334,12 +343,15 @@ MonoArray* CMonoFunctions::Vehicle::GetCompatibleUpgrades( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehicleCompatibleUpgrades( RESOURCE->GetLua(), (void*)pUserData ); CLuaArgumentsVector pLuaArguments = CLuaFunctionDefinitions::GetVehicleCompatibleUpgrades( RESOURCE->GetLua(), (void*)pUserData );
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TNUMBER>( mono_get_uint32_class(), pLuaArguments ); if( pLuaArguments.size() > 0 )
{
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TNUMBER>( mono_get_uint32_class(), &pLuaArguments );
}
} }
return NULL; return nullptr;
} }
unsigned char CMonoFunctions::Vehicle::GetDoorState( DWORD pUserData, unsigned char ucDoor ) unsigned char CMonoFunctions::Vehicle::GetDoorState( DWORD pUserData, unsigned char ucDoor )

View File

@ -2,7 +2,7 @@
* *
* Multi Theft Auto: San Andreas - Deathmatch * Multi Theft Auto: San Andreas - Deathmatch
* *
* Squirrel 3, External lua add-on module * External lua add-on module
* *
* Copyright © 2003-2008 MTA. All Rights Reserved. * Copyright © 2003-2008 MTA. All Rights Reserved.
* *
@ -23,256 +23,264 @@
using namespace std; using namespace std;
CLuaArgument::CLuaArgument ( void ) CLuaArgument::CLuaArgument( void )
{ {
m_szString = NULL; this->m_iType = LUA_TNIL;
m_iType = LUA_TNIL; this->m_szString = nullptr;
this->m_pLightUserData = nullptr;
this->m_Function = nullptr;
this->m_bBoolean = false;
this->m_Number = 0;
} }
CLuaArgument::CLuaArgument( bool bBool ) : CLuaArgument()
CLuaArgument::CLuaArgument ( bool bBool )
{ {
m_szString = NULL; this->m_iType = LUA_TBOOLEAN;
m_iType = LUA_TBOOLEAN; this->m_bBoolean = bBool;
m_bBoolean = bBool;
} }
CLuaArgument::CLuaArgument( double dNumber ) : CLuaArgument()
CLuaArgument::CLuaArgument ( double dNumber )
{ {
m_szString = NULL; this->m_iType = LUA_TNUMBER;
m_iType = LUA_TNUMBER; this->m_Number = dNumber;
m_Number = dNumber;
} }
CLuaArgument::CLuaArgument( const char* szString ) : CLuaArgument()
CLuaArgument::CLuaArgument ( const char* szString )
{ {
assert ( szString ); assert( szString );
m_iType = LUA_TSTRING; this->m_iType = LUA_TSTRING;
m_szString = new char [strlen ( szString ) + 1]; this->m_szString = new char[ strlen( szString ) + 1 ];
strcpy ( m_szString, szString );
strcpy( this->m_szString, szString );
} }
CLuaArgument::CLuaArgument( void* pUserData ) : CLuaArgument()
CLuaArgument::CLuaArgument ( void* pUserData )
{ {
m_szString = NULL; this->m_iType = LUA_TLIGHTUSERDATA;
m_iType = LUA_TLIGHTUSERDATA; this->m_pLightUserData = pUserData;
m_pLightUserData = pUserData;
} }
CLuaArgument::CLuaArgument( lua_CFunction Function ) : CLuaArgument()
CLuaArgument::CLuaArgument( lua_CFunction Function )
{ {
m_szString = NULL; this->m_szString = NULL;
m_iType = LUA_TFUNCTION; this->m_iType = LUA_TFUNCTION;
m_Function = Function; this->m_Function = Function;
} }
CLuaArgument::CLuaArgument( const CLuaArgument& Argument ) : CLuaArgument()
CLuaArgument::CLuaArgument ( const CLuaArgument& Argument )
{ {
// Initialize and call our = on the argument operator = ( Argument );
m_szString = NULL;
operator= ( Argument );
} }
CLuaArgument::CLuaArgument( lua_State* luaVM, unsigned int uiArgument ) : CLuaArgument()
CLuaArgument::CLuaArgument ( lua_State* luaVM, unsigned int uiArgument )
{ {
// Read the argument out of the lua VM this->Read( luaVM, uiArgument );
m_szString = NULL;
Read ( luaVM, uiArgument );
} }
CLuaArgument::~CLuaArgument( void )
CLuaArgument::~CLuaArgument ( void )
{ {
// Eventually destroy our string if( this->m_szString )
if ( m_szString ) {
{ delete[] this->m_szString;
delete [] m_szString; }
}
}
this->m_pArray.clear();
this->m_pTable.clear();
}
const CLuaArgument& CLuaArgument::operator = ( const CLuaArgument& Argument ) const CLuaArgument& CLuaArgument::operator = ( const CLuaArgument& Argument )
{ {
// Destroy our old string if neccessary if( this->m_szString )
if ( m_szString ) {
{ delete[] this->m_szString;
delete [] m_szString; this->m_szString = nullptr;
m_szString = NULL; }
}
// Set our variable equally to the copy class this->m_pArray.clear();
m_iType = Argument.m_iType; this->m_pTable.clear();
switch ( m_iType )
{
case LUA_TBOOLEAN:
{
m_bBoolean = Argument.m_bBoolean;
break;
}
case LUA_TLIGHTUSERDATA: this->m_iType = Argument.m_iType;
{
m_pLightUserData = Argument.m_pLightUserData;
break;
}
case LUA_TNUMBER: switch( this->m_iType )
{ {
m_Number = Argument.m_Number; case LUA_TBOOLEAN:
break; {
} this->m_bBoolean = Argument.m_bBoolean;
case LUA_TSTRING: break;
{ }
if ( Argument.m_szString ) case LUA_TLIGHTUSERDATA:
{ {
m_szString = new char [strlen ( Argument.m_szString ) + 1]; this->m_pLightUserData = Argument.m_pLightUserData;
strcpy ( m_szString, Argument.m_szString );
}
break; break;
} }
case LUA_TNUMBER:
{
this->m_Number = Argument.m_Number;
break;
}
case LUA_TSTRING:
{
if( Argument.m_szString )
{
this->m_szString = new char[ strlen( Argument.m_szString ) + 1 ];
strcpy( this->m_szString, Argument.m_szString );
}
break;
}
case LUA_TFUNCTION: case LUA_TFUNCTION:
{ {
m_Function = Argument.m_Function; this->m_Function = Argument.m_Function;
break;
}
case LUA_TTABLE:
{
if( Argument.m_pArray.size() > 0 )
{
for( const auto& _item : Argument.m_pArray )
{
CLuaArgument* item = new CLuaArgument( _item );
this->m_pArray.push_back( item );
}
}
if( Argument.m_pTable.size() > 0 )
{
for( const auto& iter : Argument.m_pTable )
{
this->m_pTable[ iter.first ] = iter.second;
}
}
break; break;
} }
default: break; default: break;
} }
// Return the given class allowing for chaining return Argument;
return Argument;
} }
bool CLuaArgument::operator == ( const CLuaArgument& Argument ) bool CLuaArgument::operator == ( const CLuaArgument& Argument )
{ {
// If the types differ, they're not matching if( Argument.m_iType != this->m_iType )
if ( Argument.m_iType != m_iType ) {
return false; return false;
}
// Compare the variables depending on the type
switch ( m_iType )
{
case LUA_TBOOLEAN:
{
return m_bBoolean == Argument.m_bBoolean;
}
case LUA_TLIGHTUSERDATA:
{
return m_pLightUserData == Argument.m_pLightUserData;
}
case LUA_TNUMBER:
{
return m_Number == Argument.m_Number;
}
case LUA_TSTRING:
{
if ( m_szString )
{
if ( Argument.m_szString )
return strcmp ( m_szString, Argument.m_szString ) == 0;
else
return false;
}
else
{
return Argument.m_szString == NULL;
}
}
switch( this->m_iType )
{
case LUA_TBOOLEAN:
{
return this->m_bBoolean == Argument.m_bBoolean;
}
case LUA_TLIGHTUSERDATA:
{
return this->m_pLightUserData == Argument.m_pLightUserData;
}
case LUA_TNUMBER:
{
return this->m_Number == Argument.m_Number;
}
case LUA_TSTRING:
{
if( this->m_szString )
{
if( Argument.m_szString )
{
return strcmp( this->m_szString, Argument.m_szString ) == 0;
}
else
{
return false;
}
}
else
{
return Argument.m_szString == NULL;
}
}
case LUA_TFUNCTION: case LUA_TFUNCTION:
{ {
return m_Function == Argument.m_Function; return this->m_Function == Argument.m_Function;
} }
} }
return true; return true;
} }
bool CLuaArgument::operator != ( const CLuaArgument& Argument ) bool CLuaArgument::operator != ( const CLuaArgument& Argument )
{ {
return !( operator == ( Argument ) ); return !( operator == ( Argument ) );
} }
void CLuaArgument::Read( lua_State* luaVM, signed int uiArgument )
void CLuaArgument::Read ( lua_State* luaVM, signed int uiArgument )
{ {
// Eventually delete our previous string if( this->m_szString )
if ( m_szString ) {
{ delete [] this->m_szString;
delete [] m_szString; }
m_szString = NULL;
}
// Grab the argument type this->m_szString = nullptr;
m_iType = lua_type ( luaVM, uiArgument ); this->m_pLightUserData = nullptr;
this->m_Function = nullptr;
if ( m_iType != LUA_TNONE ) this->m_pArray.clear();
{ this->m_pTable.clear();
// Read out the content depending on the type
switch ( m_iType )
{
case LUA_TNIL:
break;
case LUA_TBOOLEAN: this->m_iType = lua_type( luaVM, uiArgument );
{
m_bBoolean = lua_toboolean ( luaVM, uiArgument ) ? true:false;
break;
}
case LUA_TLIGHTUSERDATA: if( this->m_iType != LUA_TNONE )
{ {
m_pLightUserData = lua_touserdata ( luaVM, uiArgument ); switch( this->m_iType )
break; {
} case LUA_TNIL:
case LUA_TNUMBER:
{
m_Number = lua_tonumber ( luaVM, uiArgument );
break;
}
case LUA_TSTRING:
{
// Grab the lua string and its size
const char* szLuaString = lua_tostring ( luaVM, uiArgument );
size_t sizeLuaString = strlen ( szLuaString );
// Allocate our buffer
m_szString = new char [sizeLuaString + 1];
strcpy ( m_szString, szLuaString );
break;
}
case LUA_TFUNCTION:
{ {
m_Function = lua_tocfunction( luaVM, uiArgument ); break;
}
case LUA_TBOOLEAN:
{
this->m_bBoolean = lua_toboolean( luaVM, uiArgument ) != 0;
break; break;
} }
case LUA_TLIGHTUSERDATA:
{
this->m_pLightUserData = lua_touserdata( luaVM, uiArgument );
break;
}
case LUA_TNUMBER:
{
this->m_Number = lua_tonumber( luaVM, uiArgument );
break;
}
case LUA_TSTRING:
{
const char* szLuaString = lua_tostring( luaVM, uiArgument );
this->m_szString = new char[ strlen( szLuaString ) + 1 ];
strcpy( this->m_szString, szLuaString );
break;
}
case LUA_TFUNCTION:
{
this->m_Function = lua_tocfunction( luaVM, uiArgument );
break;
}
case LUA_TTABLE: case LUA_TTABLE:
{ {
m_pTable.clear();
m_pArray = new CLuaArguments();
lua_pushnil( luaVM ); lua_pushnil( luaVM );
uiArgument--; uiArgument--;
@ -280,84 +288,99 @@ void CLuaArgument::Read ( lua_State* luaVM, signed int uiArgument )
while( lua_next( luaVM, uiArgument ) != 0 ) while( lua_next( luaVM, uiArgument ) != 0 )
{ {
CLuaArgument pKey( luaVM, -2 ); CLuaArgument pKey( luaVM, -2 );
CLuaArgument* pValue = new CLuaArgument( luaVM, -1 ); CLuaArgument pValue( luaVM, -1 );
if( pKey.GetType() == LUA_TSTRING ) if( pKey.GetType() == LUA_TSTRING )
{ {
m_pTable[ string( pKey.GetString() ) ] = pValue; this->m_pTable[ pKey.GetString() ] = pValue;
} }
m_pArray->PushArgument( pValue ); this->m_pArray.push_back( pValue );
lua_pop( luaVM, 1 ); lua_pop( luaVM, 1 );
} }
break; break;
} }
default:
default:
{
m_iType = LUA_TNONE;
break;
}
}
}
}
void CLuaArgument::Push ( lua_State* luaVM ) const
{
// Got any type?
if ( m_iType != LUA_TNONE )
{
// Push it depending on the type
switch ( m_iType )
{
case LUA_TNIL:
{
lua_pushnil ( luaVM );
break;
}
case LUA_TBOOLEAN:
{
lua_pushboolean ( luaVM, m_bBoolean );
break;
}
case LUA_TLIGHTUSERDATA:
{
lua_pushlightuserdata ( luaVM, m_pLightUserData );
break;
}
case LUA_TNUMBER:
{
lua_pushnumber ( luaVM, m_Number );
break;
}
case LUA_TSTRING:
{
// Push the string if we got any
if ( m_szString )
{
lua_pushstring ( luaVM, m_szString );
}
else
{
lua_pushstring ( luaVM, "" );
}
break;
}
case LUA_TFUNCTION:
{ {
lua_pushcfunction( luaVM, m_Function ); this->m_iType = LUA_TNONE;
break; break;
} }
} }
} }
}
void CLuaArgument::Push( lua_State* luaVM ) const
{
if( this->m_iType != LUA_TNONE )
{
switch( this->m_iType )
{
case LUA_TNIL:
{
lua_pushnil( luaVM );
break;
}
case LUA_TBOOLEAN:
{
lua_pushboolean( luaVM, this->m_bBoolean );
break;
}
case LUA_TLIGHTUSERDATA:
{
lua_pushlightuserdata( luaVM, this->m_pLightUserData );
break;
}
case LUA_TNUMBER:
{
lua_pushnumber( luaVM, this->m_Number );
break;
}
case LUA_TSTRING:
{
lua_pushstring( luaVM, this->m_szString ? this->m_szString : "" );
break;
}
case LUA_TFUNCTION:
{
lua_pushcfunction( luaVM, this->m_Function );
break;
}
}
}
}
CLuaArgumentsVector CLuaArgument::GetArray( void ) const
{
CLuaArgumentsVector pArray;
for( const auto& arg : this->m_pArray )
{
CLuaArgument pArgument( arg );
pArray.push_back( pArgument );
}
return pArray;
}
CLuaArgumentsMap CLuaArgument::GetTable( void ) const
{
CLuaArgumentsMap pMap;
for( const auto& iter : this->m_pTable )
{
CLuaArgument pArgument( iter.second );
pMap[ iter.first.c_str() ] = pArgument;
}
return pMap;
} }

View File

@ -2,7 +2,7 @@
* *
* Multi Theft Auto: San Andreas - Deathmatch * Multi Theft Auto: San Andreas - Deathmatch
* *
* Squirrel 3, External lua add-on module * External lua add-on module
* *
* Copyright © 2003-2008 MTA. All Rights Reserved. * Copyright © 2003-2008 MTA. All Rights Reserved.
* *
@ -26,55 +26,56 @@ extern "C"
#include <lua.h> #include <lua.h>
} }
#include "CReferenceCounter.h"
#include "CLuaArguments.h" #include "CLuaArguments.h"
#include <string>
#include <map>
typedef std::map<std::string, CLuaArgument*> LuaTable; typedef vector< CLuaArgument > CLuaArgumentsVector;
typedef map< string, CLuaArgument > CLuaArgumentsMap;
class CLuaArgument class CLuaArgument
{ {
public: public:
CLuaArgument ( void ); CLuaArgument ( void );
CLuaArgument ( bool bBool ); CLuaArgument ( bool bBool );
CLuaArgument ( double dNumber ); CLuaArgument ( double dNumber );
CLuaArgument ( const char* szString ); CLuaArgument ( const char* szString );
CLuaArgument ( void* pUserData ); CLuaArgument ( void* pUserData );
CLuaArgument ( lua_CFunction Function ); CLuaArgument ( lua_CFunction Function );
CLuaArgument ( const CLuaArgument& Argument ); CLuaArgument ( const CLuaArgument& Argument );
CLuaArgument ( lua_State* luaVM, unsigned int uiArgument ); CLuaArgument ( lua_State* luaVM, unsigned int uiArgument );
~CLuaArgument ( void ); ~CLuaArgument ( void );
const CLuaArgument& operator = ( const CLuaArgument& Argument ); const CLuaArgument& operator = ( const CLuaArgument& Argument );
bool operator == ( const CLuaArgument& Argument ); bool operator == ( const CLuaArgument& Argument );
bool operator != ( const CLuaArgument& Argument ); bool operator != ( const CLuaArgument& Argument );
void Read ( lua_State* luaVM, signed int uiArgument ); void Read ( lua_State* luaVM, signed int uiArgument );
void Push ( lua_State* luaVM ) const; void Push ( lua_State* luaVM ) const;
inline int GetType ( void ) const { return m_iType; }; inline int GetType ( void ) const { return m_iType; };
inline bool GetBoolean ( void ) const { return m_bBoolean; }; inline bool GetBoolean ( void ) const { return m_bBoolean; };
inline lua_Number GetNumber ( void ) const { return m_Number; }; inline lua_Number GetNumber ( void ) const { return m_Number; };
inline const char* GetString ( void ) const { return m_szString; }; inline const char* GetString ( void ) const { return m_szString; };
inline void* GetLightUserData ( void ) const { return m_pLightUserData; }; inline PVOID GetLightUserData ( void ) const { return m_pLightUserData; };
inline CLuaArguments* GetArray ( void ) const { return m_pArray; };
inline LuaTable GetTable ( void ) const { return m_pTable; };
template <class T> T GetNumber() CLuaArgumentsVector GetArray ( void ) const;
CLuaArgumentsMap GetTable ( void ) const;
template <class T> T GetNumber() const
{ {
return static_cast< T >( m_Number ); return static_cast< T >( m_Number );
} }
private: private:
int m_iType; int m_iType;
bool m_bBoolean; bool m_bBoolean;
lua_Number m_Number; lua_Number m_Number;
char* m_szString; char* m_szString;
void* m_pLightUserData; PVOID m_pLightUserData;
lua_CFunction m_Function; lua_CFunction m_Function;
CLuaArguments* m_pArray; CLuaArgumentsVector m_pArray;
LuaTable m_pTable; CLuaArgumentsMap m_pTable;
}; };
#endif #endif

View File

@ -2,7 +2,7 @@
* *
* Multi Theft Auto: San Andreas - Deathmatch * Multi Theft Auto: San Andreas - Deathmatch
* *
* Squirrel 3, External lua add-on module * External lua add-on module
* *
* Copyright © 2003-2008 MTA. All Rights Reserved. * Copyright © 2003-2008 MTA. All Rights Reserved.
* *
@ -20,162 +20,144 @@
#include "CLuaArguments.h" #include "CLuaArguments.h"
#include <assert.h> #include <assert.h>
CLuaArguments::CLuaArguments ( const CLuaArguments& Arguments ) CLuaArguments::CLuaArguments( const CLuaArguments& Arguments )
{ {
// Copy all the arguments for( const auto& iter : Arguments.m_Arguments )
vector < CLuaArgument* > ::const_iterator iter = Arguments.m_Arguments.begin (); {
for ( ; iter != Arguments.m_Arguments.end (); iter++ ) CLuaArgument* pArgument = new CLuaArgument( *iter );
{
CLuaArgument* pArgument = new CLuaArgument ( **iter );
m_Arguments.push_back ( pArgument );
}
}
this->m_Arguments.push_back( pArgument );
}
}
const CLuaArguments& CLuaArguments::operator = ( const CLuaArguments& Arguments ) const CLuaArguments& CLuaArguments::operator = ( const CLuaArguments& Arguments )
{ {
// Clear our previous list if any this->DeleteArguments();
DeleteArguments ();
// Copy all the arguments for( const auto& iter : Arguments.m_Arguments )
vector < CLuaArgument* > ::const_iterator iter = Arguments.m_Arguments.begin (); {
for ( ; iter != Arguments.m_Arguments.end (); iter++ ) CLuaArgument* pArgument = new CLuaArgument( *iter );
{
CLuaArgument* pArgument = new CLuaArgument ( **iter );
m_Arguments.push_back ( pArgument );
}
// Return the given reference allowing for chaining this->m_Arguments.push_back( pArgument );
return Arguments; }
return Arguments;
} }
void CLuaArguments::ReadArguments( lua_State* luaVM, unsigned int uiIndexBegin )
void CLuaArguments::ReadArguments ( lua_State* luaVM, unsigned int uiIndexBegin )
{ {
// Delete the previous arguments if any this->DeleteArguments();
DeleteArguments ();
// Start reading arguments until there are none left while( lua_type( luaVM, uiIndexBegin ) != LUA_TNONE )
while ( lua_type ( luaVM, uiIndexBegin ) != LUA_TNONE ) {
{ CLuaArgument* pArgument = new CLuaArgument( luaVM, uiIndexBegin++ );
// Create an argument, let it read out the argument and add it to our vector
CLuaArgument* pArgument = new CLuaArgument ( luaVM, uiIndexBegin++ ); this->m_Arguments.push_back( pArgument );
m_Arguments.push_back ( pArgument ); }
}
} }
void CLuaArguments::PushArguments( lua_State* luaVM ) const
void CLuaArguments::PushArguments ( lua_State* luaVM ) const
{ {
// Push all our arguments for( const auto& pArg : this->m_Arguments )
vector < CLuaArgument* > ::const_iterator iter = m_Arguments.begin (); {
for ( ; iter != m_Arguments.end (); iter++ ) pArg->Push( luaVM );
{ }
(*iter)->Push ( luaVM );
}
} }
void CLuaArguments::PushArguments( CLuaArguments& Arguments )
void CLuaArguments::PushArguments ( CLuaArguments& Arguments )
{ {
vector < CLuaArgument* > ::const_iterator iter = Arguments.IterBegin (); for( const auto& iter : Arguments.m_Arguments )
for ( ; iter != Arguments.IterEnd (); iter++ ) {
{ CLuaArgument* pArgument = new CLuaArgument( *iter );
CLuaArgument* pArgument = new CLuaArgument ( **iter );
m_Arguments.push_back ( pArgument ); this->m_Arguments.push_back( pArgument );
} }
} }
bool CLuaArguments::Call( lua_State* luaVM, const char* szFunction, int iResults, int iErrorFunc ) const
bool CLuaArguments::Call ( lua_State* luaVM, const char* szFunction, int iResults, int iErrorFunc ) const
{ {
assert ( szFunction ); assert( szFunction );
assert( luaVM );
// Add the function name to the stack and get the event from the table lua_pushstring( luaVM, szFunction );
assert ( luaVM ); lua_gettable( luaVM, LUA_GLOBALSINDEX );
lua_pushstring ( luaVM, szFunction ); this->PushArguments( luaVM );
lua_gettable ( luaVM, LUA_GLOBALSINDEX );
// Push our arguments onto the stack int iret = lua_pcall( luaVM, m_Arguments.size(), iResults, iErrorFunc );
PushArguments ( luaVM );
int iret = lua_pcall ( luaVM, m_Arguments.size(), iResults, iErrorFunc ); return iret != LUA_ERRRUN && iret != LUA_ERRMEM;
if ( iret == LUA_ERRRUN || iret == LUA_ERRMEM )
{
return false; // the function call failed
}
return true;
} }
CLuaArgument* CLuaArguments::PushNil( void )
CLuaArgument* CLuaArguments::PushNil ( void )
{ {
CLuaArgument* pArgument = new CLuaArgument; CLuaArgument* pArgument = new CLuaArgument;
m_Arguments.push_back ( pArgument );
return pArgument; this->m_Arguments.push_back( pArgument );
return pArgument;
} }
CLuaArgument* CLuaArguments::PushBoolean( bool bBool )
CLuaArgument* CLuaArguments::PushBoolean ( bool bBool )
{ {
CLuaArgument* pArgument = new CLuaArgument ( bBool ); CLuaArgument* pArgument = new CLuaArgument( bBool );
m_Arguments.push_back ( pArgument );
return pArgument; this->m_Arguments.push_back( pArgument );
return pArgument;
} }
CLuaArgument* CLuaArguments::PushNumber( double dNumber )
CLuaArgument* CLuaArguments::PushNumber ( double dNumber )
{ {
CLuaArgument* pArgument = new CLuaArgument ( dNumber ); CLuaArgument* pArgument = new CLuaArgument( dNumber );
m_Arguments.push_back ( pArgument );
return pArgument; this->m_Arguments.push_back( pArgument );
return pArgument;
} }
CLuaArgument* CLuaArguments::PushString( const char* szString )
CLuaArgument* CLuaArguments::PushString ( const char* szString )
{ {
CLuaArgument* pArgument = new CLuaArgument ( szString ); CLuaArgument* pArgument = new CLuaArgument( szString );
m_Arguments.push_back ( pArgument );
return pArgument; this->m_Arguments.push_back( pArgument );
return pArgument;
} }
CLuaArgument* CLuaArguments::PushUserData( void* pUserData )
CLuaArgument* CLuaArguments::PushUserData ( void* pUserData )
{ {
CLuaArgument* pArgument = new CLuaArgument ( pUserData ); CLuaArgument* pArgument = new CLuaArgument( pUserData );
m_Arguments.push_back ( pArgument );
return pArgument;
}
this->m_Arguments.push_back( pArgument );
return pArgument;
}
CLuaArgument* CLuaArguments::PushFunction( lua_CFunction iFunction ) CLuaArgument* CLuaArguments::PushFunction( lua_CFunction iFunction )
{ {
CLuaArgument* pArgument = new CLuaArgument ( iFunction ); CLuaArgument* pArgument = new CLuaArgument( iFunction );
m_Arguments.push_back ( pArgument );
return pArgument; this->m_Arguments.push_back( pArgument );
return pArgument;
} }
CLuaArgument* CLuaArguments::PushArgument( const CLuaArgument& argument )
CLuaArgument* CLuaArguments::PushArgument ( const CLuaArgument & argument )
{ {
CLuaArgument* pArgument = new CLuaArgument (argument); // create a copy CLuaArgument* pArgument = new CLuaArgument( argument ); // create a copy
m_Arguments.push_back ( pArgument );
return pArgument; this->m_Arguments.push_back( pArgument );
return pArgument;
} }
void CLuaArguments::DeleteArguments( void )
void CLuaArguments::DeleteArguments ( void )
{ {
// Delete each item for( auto pArg : this->m_Arguments )
vector < CLuaArgument* > ::iterator iter = m_Arguments.begin (); {
for ( ; iter != m_Arguments.end (); iter++ ) delete pArg;
{ }
delete *iter;
}
// Clear the vector this->m_Arguments.clear();
m_Arguments.clear ();
} }

View File

@ -2,7 +2,7 @@
* *
* Multi Theft Auto: San Andreas - Deathmatch * Multi Theft Auto: San Andreas - Deathmatch
* *
* Squirrel 3, External lua add-on module * External lua add-on module
* *
* Copyright © 2003-2008 MTA. All Rights Reserved. * Copyright © 2003-2008 MTA. All Rights Reserved.
* *

View File

@ -496,8 +496,9 @@ PVOID CLuaFunctionDefinitions::CloneElement( lua_State* pLuaVM, PVOID pUserData,
// Element get funcs // Element get funcs
CLuaArguments* CLuaFunctionDefinitions::GetElementsByType( lua_State* pLuaVM, const char* szTypeName, PVOID pUserData ) CLuaArgumentsVector CLuaFunctionDefinitions::GetElementsByType( lua_State* pLuaVM, const char* szTypeName, PVOID pUserData )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushString( szTypeName ); pLuaArguments.PushString( szTypeName );
@ -509,12 +510,10 @@ CLuaArguments* CLuaFunctionDefinitions::GetElementsByType( lua_State* pLuaVM, co
if( pLuaArguments.Call( pLuaVM, "getElementsByType", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getElementsByType", 1 ) )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); pLuaArgument.Read( pLuaVM, -1 );
return pLuaArgument.GetArray();
} }
return nullptr; return pLuaArgument.GetArray();
} }
bool CLuaFunctionDefinitions::IsElement( lua_State* pLuaVM, PVOID pUserData ) bool CLuaFunctionDefinitions::IsElement( lua_State* pLuaVM, PVOID pUserData )
@ -647,8 +646,9 @@ string CLuaFunctionDefinitions::GetElementID( lua_State* pLuaVM, PVOID pUserData
return string(); return string();
} }
CLuaArgument* CLuaFunctionDefinitions::GetElementData( lua_State* pLuaVM, PVOID pUserData, string sKey, bool bInherit ) CLuaArgument CLuaFunctionDefinitions::GetElementData( lua_State* pLuaVM, PVOID pUserData, string sKey, bool bInherit )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData ); pLuaArguments.PushUserData( pUserData );
@ -657,13 +657,13 @@ CLuaArgument* CLuaFunctionDefinitions::GetElementData( lua_State* pLuaVM, PVOID
if( pLuaArguments.Call( pLuaVM, "getElementData", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getElementData", 1 ) )
{ {
return new CLuaArgument( pLuaVM, -1 ); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument;
} }
CLuaArguments* CLuaFunctionDefinitions::GetAllElementData( lua_State* pLuaVM, PVOID pUserData ) CLuaArguments CLuaFunctionDefinitions::GetAllElementData( lua_State* pLuaVM, PVOID pUserData )
{ {
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
@ -671,14 +671,14 @@ CLuaArguments* CLuaFunctionDefinitions::GetAllElementData( lua_State* pLuaVM, PV
if( pLuaArguments.Call( pLuaVM, "getAllElementData", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getAllElementData", 1 ) )
{ {
CLuaArguments *pLuaArguments = new CLuaArguments(); pLuaArguments.ReadArguments( pLuaVM );
}
pLuaArguments->ReadArguments( pLuaVM ); else
{
return pLuaArguments; pLuaArguments.DeleteArguments();
} }
return nullptr; return pLuaArguments;
} }
PVOID CLuaFunctionDefinitions::GetElementParent( lua_State* pLuaVM, PVOID pUserData ) PVOID CLuaFunctionDefinitions::GetElementParent( lua_State* pLuaVM, PVOID pUserData )
@ -708,9 +708,9 @@ bool CLuaFunctionDefinitions::GetElementPosition( lua_State* pLuaVM, PVOID pUser
if( pLuaArguments.Call( pLuaVM, "getElementPosition", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getElementPosition", 3 ) )
{ {
vecPosition.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); vecPosition.fX = static_cast< float >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
vecPosition.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecPosition.fY = static_cast< float >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
vecPosition.fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecPosition.fZ = static_cast< float >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -726,9 +726,9 @@ bool CLuaFunctionDefinitions::GetElementRotation( lua_State* pLuaVM, PVOID pUser
if( pLuaArguments.Call( pLuaVM, "getElementRotation", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getElementRotation", 3 ) )
{ {
vecRotation.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); vecRotation.fX = static_cast< float >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
vecRotation.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecRotation.fY = static_cast< float >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
vecRotation.fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecRotation.fZ = static_cast< float >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -745,9 +745,9 @@ bool CLuaFunctionDefinitions::GetElementVelocity( lua_State* pLuaVM, PVOID pUser
if( pLuaArguments.Call( pLuaVM, "getElementVelocity", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getElementVelocity", 3 ) )
{ {
vecVelocity.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); vecVelocity.fX = static_cast< float >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
vecVelocity.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecVelocity.fY = static_cast< float >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
vecVelocity.fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecVelocity.fZ = static_cast< float >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -997,12 +997,12 @@ bool CLuaFunctionDefinitions::GetElementAttachedOffsets( lua_State* pLuaVM, PVOI
if( pLuaArguments.Call( pLuaVM, "getElementAttachedOffsets", 6 ) ) if( pLuaArguments.Call( pLuaVM, "getElementAttachedOffsets", 6 ) )
{ {
vecPosition.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -6 ) )->GetNumber() ); vecPosition.fX = static_cast< float >( CLuaArgument( pLuaVM, -6 ).GetNumber() );
vecPosition.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -5 ) )->GetNumber() ); vecPosition.fY = static_cast< float >( CLuaArgument( pLuaVM, -5 ).GetNumber() );
vecPosition.fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); vecPosition.fZ = static_cast< float >( CLuaArgument( pLuaVM, -4 ).GetNumber() );
vecRotation.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); vecRotation.fX = static_cast< float >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
vecRotation.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecRotation.fY = static_cast< float >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
vecRotation.fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecRotation.fZ = static_cast< float >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -1634,28 +1634,30 @@ bool CLuaFunctionDefinitions::GetPlayerWantedLevel( lua_State* pLuaVM, PVOID pUs
return false; return false;
} }
CLuaArguments* CLuaFunctionDefinitions::GetAlivePlayers( lua_State* pLuaVM ) CLuaArgumentsVector CLuaFunctionDefinitions::GetAlivePlayers( lua_State* pLuaVM )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
if( pLuaArguments.Call( pLuaVM, "getAlivePlayers", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getAlivePlayers", 1 ) )
{ {
return CLuaArgument( pLuaVM, -1 ).GetArray(); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument.GetArray();
} }
CLuaArguments* CLuaFunctionDefinitions::GetDeadPlayers( lua_State* pLuaVM ) CLuaArgumentsVector CLuaFunctionDefinitions::GetDeadPlayers( lua_State* pLuaVM )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
if( pLuaArguments.Call( pLuaVM, "getDeadPlayers", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getDeadPlayers", 1 ) )
{ {
return CLuaArgument( pLuaVM, -1 ).GetArray(); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument.GetArray();
} }
bool CLuaFunctionDefinitions::GetPlayerIdleTime( lua_State* pLuaVM, PVOID pUserData, unsigned int& uiIdleTime ) bool CLuaFunctionDefinitions::GetPlayerIdleTime( lua_State* pLuaVM, PVOID pUserData, unsigned int& uiIdleTime )
@ -1853,20 +1855,23 @@ string CLuaFunctionDefinitions::GetPlayerVersion( lua_State* pLuaVM, PVOID pUser
return string(); return string();
} }
LuaTable CLuaFunctionDefinitions::GetPlayerACInfo( lua_State* pLuaVM, PVOID pUserData ) CLuaArgumentsMap* CLuaFunctionDefinitions::GetPlayerACInfo( lua_State* pLuaVM, PVOID pUserData )
{ {
map<string, CLuaArgument*> pLuaTable;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData ); pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getPlayerACInfo", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getPlayerACInfo", 1 ) )
{ {
pLuaTable = CLuaArgument( pLuaVM, -1 ).GetTable(); CLuaArgument pLuaArgument( pLuaVM, -1 );
if( pLuaArgument.GetType() == LUA_TTABLE )
{
return &pLuaArgument.GetTable();
}
} }
return pLuaTable; return nullptr;
} }
// Player set functions // Player set functions
@ -2313,8 +2318,8 @@ bool CLuaFunctionDefinitions::GetPedClothes( lua_State* pLuaVM, PVOID pUserData,
if( pLuaArguments.Call( pLuaVM, "getPedClothes", 2 ) ) if( pLuaArguments.Call( pLuaVM, "getPedClothes", 2 ) )
{ {
strOutTexture = string( ( new CLuaArgument( pLuaVM, -2 ) )->GetString() ); strOutTexture = CLuaArgument( pLuaVM, -2 ).GetString();
strOutModel = string( ( new CLuaArgument( pLuaVM, -1 ) )->GetString() ); strOutModel = CLuaArgument( pLuaVM, -1 ).GetString();
return true; return true;
} }
@ -3037,8 +3042,8 @@ bool CLuaFunctionDefinitions::GetVehicleVariant( lua_State* pLuaVM, PVOID pUserD
if( pLuaArguments.Call( pLuaVM, "getVehicleVariant", 2 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleVariant", 2 ) )
{ {
ucVariant = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucVariant = static_cast< unsigned char >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
ucVariant2 = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucVariant2 = static_cast< unsigned char >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -3138,7 +3143,12 @@ bool CLuaFunctionDefinitions::GetVehicleName( lua_State* pLuaVM, PVOID pUserData
if( pLuaArguments.Call( pLuaVM, "getVehicleName", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleName", 1 ) )
{ {
strOutName = string( CLuaArgument( pLuaVM, -1 ).GetString() ); CLuaArgument pLuaArgument( pLuaVM, -1 );
if( pLuaArgument.GetType() == LUA_TSTRING )
{
strOutName = pLuaArgument.GetString();
}
return true; return true;
} }
@ -3154,7 +3164,12 @@ bool CLuaFunctionDefinitions::GetVehicleNameFromModel( lua_State* pLuaVM, unsign
if( pLuaArguments.Call( pLuaVM, "getVehicleNameFromModel", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleNameFromModel", 1 ) )
{ {
strOutName = string( CLuaArgument( pLuaVM, -1 ).GetString() ); CLuaArgument pLuaArgument( pLuaVM, -1 );
if( pLuaArgument.GetType() == LUA_TSTRING )
{
strOutName = pLuaArgument.GetString();
}
return true; return true;
} }
@ -3182,18 +3197,19 @@ PVOID CLuaFunctionDefinitions::GetVehicleOccupant( lua_State* pLuaVM, PVOID pUse
return nullptr; return nullptr;
} }
CLuaArguments* CLuaFunctionDefinitions::GetVehicleOccupants( lua_State* pLuaVM, PVOID pUserData ) CLuaArgumentsVector CLuaFunctionDefinitions::GetVehicleOccupants( lua_State* pLuaVM, PVOID pUserData )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData ); pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getVehicleOccupants", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleOccupants", 1 ) )
{ {
return CLuaArgument( pLuaVM, -1 ).GetArray(); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument.GetArray();
} }
PVOID CLuaFunctionDefinitions::GetVehicleController( lua_State* pLuaVM, PVOID pUserData ) PVOID CLuaFunctionDefinitions::GetVehicleController( lua_State* pLuaVM, PVOID pUserData )
@ -3223,9 +3239,14 @@ bool CLuaFunctionDefinitions::GetVehicleSirensOn( lua_State* pLuaVM, PVOID pUser
if( pLuaArguments.Call( pLuaVM, "getVehicleSirensOn", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleSirensOn", 1 ) )
{ {
bSirensOn = CLuaArgument( pLuaVM, -1 ).GetBoolean(); CLuaArgument pLuaArgument( pLuaVM, -1 );
return true; if( pLuaArgument.GetType() == LUA_TBOOLEAN )
{
bSirensOn = pLuaArgument.GetBoolean();
return true;
}
} }
return false; return false;
@ -3282,18 +3303,19 @@ bool CLuaFunctionDefinitions::IsVehicleLocked( lua_State* pLuaVM, PVOID pUserDat
return false; return false;
} }
CLuaArguments* CLuaFunctionDefinitions::GetVehiclesOfType( lua_State* pLuaVM, unsigned int uiModel ) CLuaArgumentsVector CLuaFunctionDefinitions::GetVehiclesOfType( lua_State* pLuaVM, unsigned int uiModel )
{ {
CLuaArguments* pLuaArguments = new CLuaArguments(); CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments;
pLuaArguments->PushNumber( uiModel ); pLuaArguments.PushNumber( uiModel );
if( pLuaArguments->Call( pLuaVM, "getVehiclesOfType", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehiclesOfType", 1 ) )
{ {
return CLuaArgument( pLuaVM, -1 ).GetArray(); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument.GetArray();
} }
bool CLuaFunctionDefinitions::GetVehicleUpgradeOnSlot( lua_State* pLuaVM, PVOID pUserData, unsigned char ucSlot, unsigned short& usUpgrade ) bool CLuaFunctionDefinitions::GetVehicleUpgradeOnSlot( lua_State* pLuaVM, PVOID pUserData, unsigned char ucSlot, unsigned short& usUpgrade )
@ -3305,26 +3327,32 @@ bool CLuaFunctionDefinitions::GetVehicleUpgradeOnSlot( lua_State* pLuaVM, PVOID
if( pLuaArguments.Call( pLuaVM, "getVehicleUpgradeOnSlot", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleUpgradeOnSlot", 1 ) )
{ {
usUpgrade = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned short >(); CLuaArgument pLuaArgument( pLuaVM, -1 );
return true; if( pLuaArgument.GetType() == LUA_TNUMBER )
{
usUpgrade = pLuaArgument.GetNumber< unsigned short >();
return true;
}
} }
return false; return false;
} }
CLuaArguments* CLuaFunctionDefinitions::GetVehicleUpgrades( lua_State* pLuaVM, PVOID pUserData ) CLuaArgumentsVector CLuaFunctionDefinitions::GetVehicleUpgrades( lua_State* pLuaVM, PVOID pUserData )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData ); pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getVehicleUpgrades", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleUpgrades", 1 ) )
{ {
return CLuaArgument( pLuaVM, -1 ).GetArray(); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument.GetArray();
} }
bool CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( lua_State* pLuaVM, unsigned char ucSlot, string& strOutName ) bool CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( lua_State* pLuaVM, unsigned char ucSlot, string& strOutName )
@ -3335,7 +3363,7 @@ bool CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( lua_State* pLuaVM, unsi
if( pLuaArguments.Call( pLuaVM, "getVehicleUpgradeSlotName", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleUpgradeSlotName", 1 ) )
{ {
strOutName = string( CLuaArgument( pLuaVM, -1 ).GetString() ); strOutName = CLuaArgument( pLuaVM, -1 ).GetString();
return true; return true;
} }
@ -3351,7 +3379,7 @@ bool CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( lua_State* pLuaVM, unsi
if( pLuaArguments.Call( pLuaVM, "getVehicleUpgradeSlotName", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleUpgradeSlotName", 1 ) )
{ {
strOutName = string( CLuaArgument( pLuaVM, -1 ).GetString() ); strOutName = CLuaArgument( pLuaVM, -1 ).GetString();
return true; return true;
} }
@ -3359,18 +3387,19 @@ bool CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( lua_State* pLuaVM, unsi
return false; return false;
} }
CLuaArguments* CLuaFunctionDefinitions::GetVehicleCompatibleUpgrades( lua_State* pLuaVM, PVOID pUserData ) CLuaArgumentsVector CLuaFunctionDefinitions::GetVehicleCompatibleUpgrades( lua_State* pLuaVM, PVOID pUserData )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData ); pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getVehicleCompatibleUpgrades", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleCompatibleUpgrades", 1 ) )
{ {
return CLuaArgument( pLuaVM, -1 ).GetArray(); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument.GetArray();
} }
bool CLuaFunctionDefinitions::GetVehicleDoorState( lua_State* pLuaVM, PVOID pUserData, unsigned char ucDoor, unsigned char& ucState ) bool CLuaFunctionDefinitions::GetVehicleDoorState( lua_State* pLuaVM, PVOID pUserData, unsigned char ucDoor, unsigned char& ucState )
@ -3398,10 +3427,10 @@ bool CLuaFunctionDefinitions::GetVehicleWheelStates( lua_State* pLuaVM, PVOID pU
if( pLuaArguments.Call( pLuaVM, "getVehicleWheelStates", 4 ) ) if( pLuaArguments.Call( pLuaVM, "getVehicleWheelStates", 4 ) )
{ {
ucFrontLeft = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); ucFrontLeft = static_cast< unsigned char >( CLuaArgument( pLuaVM, -4 ).GetNumber() );
ucRearLeft = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); ucRearLeft = static_cast< unsigned char >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
ucFrontRight = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucFrontRight = static_cast< unsigned char >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
ucRearRight = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucRearRight = static_cast< unsigned char >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -4655,10 +4684,10 @@ bool CLuaFunctionDefinitions::GetMarkerColor( lua_State* pLuaVM, PVOID pUserData
if( pLuaArguments.Call( pLuaVM, "getMarkerColor", 4 ) ) if( pLuaArguments.Call( pLuaVM, "getMarkerColor", 4 ) )
{ {
outColor.R = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); outColor.R = static_cast< unsigned char >( CLuaArgument( pLuaVM, -4 ).GetNumber() );
outColor.G = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); outColor.G = static_cast< unsigned char >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
outColor.B = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); outColor.B = static_cast< unsigned char >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
outColor.A = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); outColor.A = static_cast< unsigned char >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -4674,9 +4703,9 @@ bool CLuaFunctionDefinitions::GetMarkerTarget( lua_State* pLuaVM, PVOID pUserDat
if( pLuaArguments.Call( pLuaVM, "getMarkerTarget", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getMarkerTarget", 3 ) )
{ {
vecTarget.fX = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); vecTarget.fX = static_cast< unsigned char >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
vecTarget.fY = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecTarget.fY = static_cast< unsigned char >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
vecTarget.fZ = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecTarget.fZ = static_cast< unsigned char >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -4908,10 +4937,10 @@ bool CLuaFunctionDefinitions::GetBlipColor( lua_State* pLuaVM, PVOID pUserData,
if( pLuaArguments.Call( pLuaVM, "getBlipColor", 4 ) ) if( pLuaArguments.Call( pLuaVM, "getBlipColor", 4 ) )
{ {
outColor.R = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); outColor.R = static_cast< unsigned char >( CLuaArgument( pLuaVM, -4 ).GetNumber() );
outColor.G = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); outColor.G = static_cast< unsigned char >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
outColor.B = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); outColor.B = static_cast< unsigned char >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
outColor.A = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); outColor.A = static_cast< unsigned char >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -5084,9 +5113,9 @@ bool CLuaFunctionDefinitions::GetObjectScale( lua_State* pLuaVM, PVOID pUserData
if( pLuaArguments.Call( pLuaVM, "getObjectScale", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getObjectScale", 3 ) )
{ {
vecScale.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); vecScale.fX = static_cast< float >( CLuaArgument( pLuaVM, -3 ).GetNumber() );
vecScale.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecScale.fY = static_cast< float >( CLuaArgument( pLuaVM, -2 ).GetNumber() );
vecScale.fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecScale.fZ = static_cast< float >( CLuaArgument( pLuaVM, -1 ).GetNumber() );
return true; return true;
} }
@ -5204,8 +5233,8 @@ bool CLuaFunctionDefinitions::GetRadarAreaSize( lua_State* pLuaVM, PVOID pUserDa
if( pLuaArguments.Call( pLuaVM, "getRadarAreaSize", 2 ) ) if( pLuaArguments.Call( pLuaVM, "getRadarAreaSize", 2 ) )
{ {
vecSize.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecSize.fX = CLuaArgument( pLuaVM, -2 ).GetNumber< float >();
vecSize.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecSize.fY = CLuaArgument( pLuaVM, -1 ).GetNumber< float >();
return true; return true;
} }
@ -5221,10 +5250,10 @@ bool CLuaFunctionDefinitions::GetRadarAreaColor( lua_State* pLuaVM, PVOID pUserD
if( pLuaArguments.Call( pLuaVM, "getRadarAreaColor", 4 ) ) if( pLuaArguments.Call( pLuaVM, "getRadarAreaColor", 4 ) )
{ {
outColor.R = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); outColor.R = CLuaArgument( pLuaVM, -4 ).GetNumber< unsigned char >();
outColor.G = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); outColor.G = CLuaArgument( pLuaVM, -3 ).GetNumber< unsigned char >();
outColor.B = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); outColor.B = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
outColor.A = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); outColor.A = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -5781,8 +5810,8 @@ bool CLuaFunctionDefinitions::GetTypeIndexFromClothes( lua_State* pLuaVM, const
if( pLuaArguments.Call( pLuaVM, "getTypeIndexFromClothes", 2 ) ) if( pLuaArguments.Call( pLuaVM, "getTypeIndexFromClothes", 2 ) )
{ {
ucTypeReturn = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucTypeReturn = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
ucIndexReturn = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucIndexReturn = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -6015,9 +6044,9 @@ bool CLuaFunctionDefinitions::GetTeamColor( lua_State* pLuaVM, PVOID pTeam, unsi
if( pLuaArguments.Call( pLuaVM, "getTeamColor", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getTeamColor", 3 ) )
{ {
ucRed = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); ucRed = CLuaArgument( pLuaVM, -3 ).GetNumber< unsigned char >();
ucGreen = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucGreen = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
ucBlue = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucBlue = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -6246,9 +6275,9 @@ bool CLuaFunctionDefinitions::GetWaterVertexPosition( lua_State* pLuaVM, PVOID p
if( pLuaArguments.Call( pLuaVM, "getWaterVertexPosition", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getWaterVertexPosition", 3 ) )
{ {
vecPosition.fX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); vecPosition.fX = CLuaArgument( pLuaVM, -3 ).GetNumber< float >();
vecPosition.fY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); vecPosition.fY = CLuaArgument( pLuaVM, -2 ).GetNumber< float >();
vecPosition.fZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); vecPosition.fZ = CLuaArgument( pLuaVM, -1 ).GetNumber< float >();
return true; return true;
} }
@ -6282,10 +6311,10 @@ bool CLuaFunctionDefinitions::GetWaterColor( lua_State* pLuaVM, unsigned char& u
if( pLuaArguments.Call( pLuaVM, "getWaterColor", 4 ) ) if( pLuaArguments.Call( pLuaVM, "getWaterColor", 4 ) )
{ {
ucRed = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); ucRed = CLuaArgument( pLuaVM, -4 ).GetNumber< unsigned char >();
ucGreen = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); ucGreen = CLuaArgument( pLuaVM, -3 ).GetNumber< unsigned char >();
ucBlue = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucBlue = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
ucAlpha = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucAlpha = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -6429,8 +6458,8 @@ bool CLuaFunctionDefinitions::GetTime( lua_State* pLuaVM, unsigned char& ucHour,
if( pLuaArguments.Call( pLuaVM, "getTime", 2 ) ) if( pLuaArguments.Call( pLuaVM, "getTime", 2 ) )
{ {
ucHour = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucHour = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
ucMinute = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucMinute = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -6444,8 +6473,8 @@ bool CLuaFunctionDefinitions::GetWeather( lua_State* pLuaVM, unsigned char& ucWe
if( pLuaArguments.Call( pLuaVM, "getWeather", 2 ) ) if( pLuaArguments.Call( pLuaVM, "getWeather", 2 ) )
{ {
ucWeather = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucWeather = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
ucWeatherBlendingTo = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucWeatherBlendingTo = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -6483,7 +6512,7 @@ bool CLuaFunctionDefinitions::GetGravity( lua_State* pLuaVM, float& fGravity )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fGravity = static_cast< float >( pLuaArgument.GetNumber() ); fGravity = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6499,7 +6528,7 @@ bool CLuaFunctionDefinitions::GetGameSpeed( lua_State* pLuaVM, float& fSpeed )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fSpeed = static_cast< float >( pLuaArgument.GetNumber() ); fSpeed = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6515,7 +6544,7 @@ bool CLuaFunctionDefinitions::GetWaveHeight( lua_State* pLuaVM, float& fHeight )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fHeight = static_cast< float >( pLuaArgument.GetNumber() ); fHeight = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6531,7 +6560,7 @@ bool CLuaFunctionDefinitions::GetFPSLimit( lua_State* pLuaVM, unsigned short& us
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
usLimit = static_cast< unsigned short >( pLuaArgument.GetNumber() ); usLimit = pLuaArgument.GetNumber< unsigned short >();
return true; return true;
} }
@ -6547,7 +6576,7 @@ bool CLuaFunctionDefinitions::GetMinuteDuration( lua_State* pLuaVM, unsigned lon
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
ulDuration = static_cast< unsigned long >( pLuaArgument.GetNumber() ); ulDuration = pLuaArgument.GetNumber< unsigned long >();
return true; return true;
} }
@ -6579,7 +6608,7 @@ bool CLuaFunctionDefinitions::GetTrafficLightState( lua_State* pLuaVM, unsigned
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
ucState = static_cast< unsigned char >( pLuaArgument.GetNumber() ); ucState = pLuaArgument.GetNumber< unsigned char >();
return true; return true;
} }
@ -6611,7 +6640,7 @@ bool CLuaFunctionDefinitions::GetJetpackMaxHeight( lua_State* pLuaVM, float& fMa
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fMaxHeight = static_cast< float >( pLuaArgument.GetNumber() ); fMaxHeight = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6627,7 +6656,7 @@ bool CLuaFunctionDefinitions::GetAircraftMaxVelocity( lua_State* pLuaVM, float&
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fVelocity = static_cast< float >( pLuaArgument.GetNumber() ); fVelocity = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6659,7 +6688,7 @@ bool CLuaFunctionDefinitions::GetRainLevel( lua_State* pLuaVM, float& fRainLevel
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fRainLevel = static_cast< float >( pLuaArgument.GetNumber() ); fRainLevel = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6675,7 +6704,7 @@ bool CLuaFunctionDefinitions::GetSunSize( lua_State* pLuaVM, float& fSunSize )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fSunSize = static_cast< float >( pLuaArgument.GetNumber() ); fSunSize = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6689,13 +6718,13 @@ bool CLuaFunctionDefinitions::GetSunColor( lua_State* pLuaVM, unsigned char& ucC
if( pLuaArguments.Call( pLuaVM, "getSunColor", 6 ) ) if( pLuaArguments.Call( pLuaVM, "getSunColor", 6 ) )
{ {
ucCoreR = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -6 ) )->GetNumber() ); ucCoreR = CLuaArgument( pLuaVM, -6 ).GetNumber< unsigned char >();
ucCoreG = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -5 ) )->GetNumber() ); ucCoreG = CLuaArgument( pLuaVM, -5 ).GetNumber< unsigned char >();
ucCoreB = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); ucCoreB = CLuaArgument( pLuaVM, -4 ).GetNumber< unsigned char >();
ucCoronaR = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); ucCoronaR = CLuaArgument( pLuaVM, -3 ).GetNumber< unsigned char >();
ucCoronaG = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); ucCoronaG = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
ucCoronaB = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); ucCoronaB = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -6709,9 +6738,9 @@ bool CLuaFunctionDefinitions::GetWindVelocity( lua_State* pLuaVM, float& fVelX,
if( pLuaArguments.Call( pLuaVM, "getWindVelocity", 3 ) ) if( pLuaArguments.Call( pLuaVM, "getWindVelocity", 3 ) )
{ {
fVelX = static_cast< float >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); fVelX = CLuaArgument( pLuaVM, -3 ).GetNumber< float >();
fVelY = static_cast< float >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); fVelY = CLuaArgument( pLuaVM, -2 ).GetNumber< float >();
fVelZ = static_cast< float >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() ); fVelZ = CLuaArgument( pLuaVM, -1 ).GetNumber< float >();
return true; return true;
} }
@ -6727,7 +6756,7 @@ bool CLuaFunctionDefinitions::GetFarClipDistance( lua_State* pLuaVM, float& fFar
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fFarClip = static_cast< float >( pLuaArgument.GetNumber() ); fFarClip = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6743,7 +6772,7 @@ bool CLuaFunctionDefinitions::GetFogDistance( lua_State* pLuaVM, float& fFogDist
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fFogDist = static_cast< float >( pLuaArgument.GetNumber() ); fFogDist = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6759,7 +6788,7 @@ bool CLuaFunctionDefinitions::GetAircraftMaxHeight( lua_State* pLuaVM, float& fM
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
fMaxHeight = static_cast< float >( pLuaArgument.GetNumber() ); fMaxHeight = pLuaArgument.GetNumber< float >();
return true; return true;
} }
@ -6791,7 +6820,7 @@ bool CLuaFunctionDefinitions::GetMoonSize( lua_State* pLuaVM, int& iSize )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); CLuaArgument pLuaArgument( pLuaVM, -1 );
iSize = static_cast< int >( pLuaArgument.GetNumber() ); iSize = pLuaArgument.GetNumber< int >();
return true; return true;
} }
@ -6904,13 +6933,13 @@ bool CLuaFunctionDefinitions::GetSkyGradient( lua_State* pLuaVM, unsigned char&
if( pLuaArguments.Call( pLuaVM, "getSkyGradient", 6 ) ) if( pLuaArguments.Call( pLuaVM, "getSkyGradient", 6 ) )
{ {
ucTopRed = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -6 ) )->GetBoolean() ); ucTopRed = CLuaArgument( pLuaVM, -6 ).GetNumber< unsigned char >();
ucTopGreen = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -5 ) )->GetBoolean() ); ucTopGreen = CLuaArgument( pLuaVM, -5 ).GetNumber< unsigned char >();
ucTopBlue = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -4 ) )->GetBoolean() ); ucTopBlue = CLuaArgument( pLuaVM, -4 ).GetNumber< unsigned char >();
ucBottomRed = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetBoolean() ); ucBottomRed = CLuaArgument( pLuaVM, -3 ).GetNumber< unsigned char >();
ucBottomGreen = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetBoolean() ); ucBottomGreen = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned char >();
ucBottomBlue = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetBoolean() ); ucBottomBlue = CLuaArgument( pLuaVM, -1 ).GetNumber< unsigned char >();
return true; return true;
} }
@ -6960,15 +6989,15 @@ bool CLuaFunctionDefinitions::GetHeatHaze( lua_State* pLuaVM, SHeatHazeSettings&
if( pLuaArguments.Call( pLuaVM, "getHeatHaze", 9 ) ) if( pLuaArguments.Call( pLuaVM, "getHeatHaze", 9 ) )
{ {
heatHazeSettings.ucIntensity = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -9 ) )->GetNumber() ); heatHazeSettings.ucIntensity = CLuaArgument( pLuaVM, -9 ).GetNumber< unsigned char >();
heatHazeSettings.ucRandomShift = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -8 ) )->GetNumber() ); heatHazeSettings.ucRandomShift = CLuaArgument( pLuaVM, -8 ).GetNumber< unsigned char >();
heatHazeSettings.usSpeedMin = static_cast< unsigned short >( ( new CLuaArgument( pLuaVM, -7 ) )->GetNumber() ); heatHazeSettings.usSpeedMin = CLuaArgument( pLuaVM, -7 ).GetNumber< unsigned short >();
heatHazeSettings.usSpeedMax = static_cast< unsigned short >( ( new CLuaArgument( pLuaVM, -6 ) )->GetNumber() ); heatHazeSettings.usSpeedMax = CLuaArgument( pLuaVM, -6 ).GetNumber< unsigned short >();
heatHazeSettings.sScanSizeX = static_cast< short >( ( new CLuaArgument( pLuaVM, -5 ) )->GetNumber() ); heatHazeSettings.sScanSizeX = CLuaArgument( pLuaVM, -5 ).GetNumber< short >();
heatHazeSettings.sScanSizeY = static_cast< short >( ( new CLuaArgument( pLuaVM, -4 ) )->GetNumber() ); heatHazeSettings.sScanSizeY = CLuaArgument( pLuaVM, -4 ).GetNumber< short >();
heatHazeSettings.usRenderSizeX = static_cast< unsigned short >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() ); heatHazeSettings.usRenderSizeX = CLuaArgument( pLuaVM, -3 ).GetNumber< unsigned short >();
heatHazeSettings.usRenderSizeY = static_cast< unsigned short >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() ); heatHazeSettings.usRenderSizeY = CLuaArgument( pLuaVM, -2 ).GetNumber< unsigned short >();
heatHazeSettings.bInsideBuilding = ( new CLuaArgument( pLuaVM, -1 ) )->GetBoolean(); heatHazeSettings.bInsideBuilding = CLuaArgument( pLuaVM, -1 ).GetBoolean();
return true; return true;
} }
@ -7640,18 +7669,17 @@ PVOID CLuaFunctionDefinitions::GetAccount( lua_State* pLuaVM, const char* szName
return nullptr; return nullptr;
} }
CLuaArguments* CLuaFunctionDefinitions::GetAccounts( lua_State* pLuaVM ) CLuaArgumentsVector CLuaFunctionDefinitions::GetAccounts( lua_State* pLuaVM )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
if( pLuaArguments.Call( pLuaVM, "getAccounts", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getAccounts", 1 ) )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); pLuaArgument.Read( pLuaVM, -1 );
return pLuaArgument.GetArray();
} }
return nullptr; return pLuaArgument.GetArray();
} }
PVOID CLuaFunctionDefinitions::GetAccountPlayer( lua_State* pLuaVM, PVOID pAccount ) PVOID CLuaFunctionDefinitions::GetAccountPlayer( lua_State* pLuaVM, PVOID pAccount )
@ -7691,8 +7719,9 @@ bool CLuaFunctionDefinitions::IsGuestAccount( lua_State* pLuaVM, PVOID pAccount,
return false; return false;
} }
CLuaArgument* CLuaFunctionDefinitions::GetAccountData( lua_State* pLuaVM, PVOID pAccount, const char* szKey ) CLuaArgument CLuaFunctionDefinitions::GetAccountData( lua_State* pLuaVM, PVOID pAccount, const char* szKey )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pAccount ); pLuaArguments.PushUserData( pAccount );
@ -7700,10 +7729,10 @@ CLuaArgument* CLuaFunctionDefinitions::GetAccountData( lua_State* pLuaVM, PVOID
if( pLuaArguments.Call( pLuaVM, "getAccountData", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getAccountData", 1 ) )
{ {
return new CLuaArgument( pLuaVM, -1 ); pLuaArgument.Read( pLuaVM, -1 );
} }
return nullptr; return pLuaArgument;
} }
bool CLuaFunctionDefinitions::GetAllAccountData( lua_State* pLuaVM, PVOID pAccount ) bool CLuaFunctionDefinitions::GetAllAccountData( lua_State* pLuaVM, PVOID pAccount )
@ -8370,20 +8399,19 @@ bool CLuaFunctionDefinitions::RemoveResourceFile( lua_State* pLuaVM, PVOID pReso
return false; return false;
} }
CLuaArguments* CLuaFunctionDefinitions::GetResourceExportedFunctions( lua_State* pLuaVM, PVOID pResource ) CLuaArgumentsVector CLuaFunctionDefinitions::GetResourceExportedFunctions( lua_State* pLuaVM, PVOID pResource )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pResource ); pLuaArguments.PushUserData( pResource );
if( pLuaArguments.Call( pLuaVM, "getResourceExportedFunctions", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getResourceExportedFunctions", 1 ) )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); pLuaArgument.Read( pLuaVM, -1 );
return pLuaArgument.GetArray();
} }
return nullptr; return pLuaArgument.GetArray();
} }
PVOID CLuaFunctionDefinitions::GetResourceFromName( lua_State* pLuaVM, const char* szResourceName ) PVOID CLuaFunctionDefinitions::GetResourceFromName( lua_State* pLuaVM, const char* szResourceName )
@ -8496,18 +8524,17 @@ bool CLuaFunctionDefinitions::GetResourceName( lua_State* pLuaVM, PVOID pResourc
return false; return false;
} }
CLuaArguments* CLuaFunctionDefinitions::GetResources( lua_State* pLuaVM ) CLuaArgumentsVector CLuaFunctionDefinitions::GetResources( lua_State* pLuaVM )
{ {
CLuaArgument pLuaArgument;
CLuaArguments pLuaArguments; CLuaArguments pLuaArguments;
if( pLuaArguments.Call( pLuaVM, "getResources", 1 ) ) if( pLuaArguments.Call( pLuaVM, "getResources", 1 ) )
{ {
CLuaArgument pLuaArgument( pLuaVM, -1 ); pLuaArgument.Read( pLuaVM, -1 );
return pLuaArgument.GetArray();
} }
return nullptr; return pLuaArgument.GetArray();
} }
bool CLuaFunctionDefinitions::GetResourceState( lua_State* pLuaVM, PVOID pResource, string& strState ) bool CLuaFunctionDefinitions::GetResourceState( lua_State* pLuaVM, PVOID pResource, string& strState )
@ -8762,16 +8789,16 @@ bool CLuaFunctionDefinitions::UpdateResourceACLRequest( lua_State* pLuaVM, PVOID
// Version funcs // Version funcs
LuaTable CLuaFunctionDefinitions::GetVersion( lua_State* pLuaVM ) CLuaArgumentsMap CLuaFunctionDefinitions::GetVersion( lua_State* pLuaVM )
{ {
LuaTable pLuaTable; CLuaArgument pLuaArgument;
if( CLuaArguments().Call( pLuaVM, "getVersion", 1 ) ) if( CLuaArguments().Call( pLuaVM, "getVersion", 1 ) )
{ {
pLuaTable = CLuaArgument( pLuaVM, -1 ).GetTable(); pLuaArgument.Read( pLuaVM, -1 );
} }
return pLuaTable; return pLuaArgument.GetTable();
} }
// Camera get functions // Camera get functions
@ -8979,7 +9006,7 @@ bool CLuaFunctionDefinitions::GiveWeapon( lua_State* pLuaVM, PVOID pElement, uns
if( pLuaArguments.Call( pLuaVM, "giveWeapon", 1 ) ) if( pLuaArguments.Call( pLuaVM, "giveWeapon", 1 ) )
{ {
return ( new CLuaArgument( pLuaVM, -1 ) )->GetBoolean(); return CLuaArgument( pLuaVM, -1 ).GetBoolean();
} }
return false; return false;
@ -8995,7 +9022,7 @@ bool CLuaFunctionDefinitions::TakeWeapon( lua_State* pLuaVM, PVOID pElement, uns
if( pLuaArguments.Call( pLuaVM, "takeWeapon", 1 ) ) if( pLuaArguments.Call( pLuaVM, "takeWeapon", 1 ) )
{ {
return ( new CLuaArgument( pLuaVM, -1 ) )->GetBoolean(); return CLuaArgument( pLuaVM, -1 ).GetBoolean();
} }
return false; return false;
@ -9009,7 +9036,7 @@ bool CLuaFunctionDefinitions::TakeAllWeapons( lua_State* pLuaVM, PVOID pElement
if( pLuaArguments.Call( pLuaVM, "takeAllWeapons", 1 ) ) if( pLuaArguments.Call( pLuaVM, "takeAllWeapons", 1 ) )
{ {
return ( new CLuaArgument( pLuaVM, -1 ) )->GetBoolean(); return CLuaArgument( pLuaVM, -1 ).GetBoolean();
} }
return false; return false;
@ -9026,7 +9053,7 @@ bool CLuaFunctionDefinitions::SetWeaponAmmo( lua_State* pLuaVM, PVOID pElement,
if( pLuaArguments.Call( pLuaVM, "setWeaponAmmo", 1 ) ) if( pLuaArguments.Call( pLuaVM, "setWeaponAmmo", 1 ) )
{ {
return ( new CLuaArgument( pLuaVM, -1 ) )->GetBoolean(); return CLuaArgument( pLuaVM, -1 ).GetBoolean();
} }
return false; return false;

View File

@ -29,8 +29,8 @@ public:
static string GetRuleValue ( lua_State* pLuaVM, const char* szKey ); static string GetRuleValue ( lua_State* pLuaVM, const char* szKey );
static bool SetRuleValue ( lua_State* pLuaVM, const char* szKey, const char* szValue ); static bool SetRuleValue ( lua_State* pLuaVM, const char* szKey, const char* szValue );
static bool RemoveRuleValue ( lua_State* pLuaVM, const char* szKey ); static bool RemoveRuleValue ( lua_State* pLuaVM, const char* szKey );
static string GetPlayerAnnounceValue ( lua_State* pLuaVM, void* pElement, const char* szKey ); static string GetPlayerAnnounceValue ( lua_State* pLuaVM, PVOID pElement, const char* szKey );
static bool SetPlayerAnnounceValue ( lua_State* pLuaVM, void* pElement, const char* szKey, const char* szValue ); static bool SetPlayerAnnounceValue ( lua_State* pLuaVM, PVOID pElement, const char* szKey, const char* szValue );
static string Get ( lua_State* pLuaVM, const char* szKey ); static string Get ( lua_State* pLuaVM, const char* szKey );
static bool Set ( lua_State* pLuaVM, const char* szKey, const char* szValue ); static bool Set ( lua_State* pLuaVM, const char* szKey, const char* szValue );
@ -38,7 +38,7 @@ public:
static string GetMapName ( lua_State* pLuaVM ); static string GetMapName ( lua_State* pLuaVM );
static bool AddCommandHandler ( lua_State* pLuaVM, const char* szCommand, lua_CFunction iLuaFunction, bool bRestricted = false, bool bCaseSensitive = true ); static bool AddCommandHandler ( lua_State* pLuaVM, const char* szCommand, lua_CFunction iLuaFunction, bool bRestricted = false, bool bCaseSensitive = true );
static bool ExecuteCommandHandler ( lua_State* pLuaVM, const char* szCommand, void* pUserData, const char* szArgs ); static bool ExecuteCommandHandler ( lua_State* pLuaVM, const char* szCommand, PVOID pUserData, const char* szArgs );
static bool RemoveCommandHandler ( lua_State* pLuaVM, const char* szCommand, lua_CFunction iLuaFunction ); static bool RemoveCommandHandler ( lua_State* pLuaVM, const char* szCommand, lua_CFunction iLuaFunction );
// static int CallRemote ( lua_State* luaVM ); // static int CallRemote ( lua_State* luaVM );
@ -46,176 +46,176 @@ public:
// Event functions // Event functions
static bool AddEvent ( lua_State* pLuaVM, const char* szName, bool bAllowRemoteTrigger ); static bool AddEvent ( lua_State* pLuaVM, const char* szName, bool bAllowRemoteTrigger );
static bool AddEventHandler ( lua_State* pLuaVM, const char* szName, void* pUserData, lua_CFunction iLuaFunction, bool bPropagated, const char* szEventPriority ); static bool AddEventHandler ( lua_State* pLuaVM, const char* szName, PVOID pUserData, lua_CFunction iLuaFunction, bool bPropagated, const char* szEventPriority );
static bool RemoveEventHandler ( lua_State* pLuaVM, const char* szName, void* pUserData, lua_CFunction iLuaFunction ); static bool RemoveEventHandler ( lua_State* pLuaVM, const char* szName, PVOID pUserData, lua_CFunction iLuaFunction );
// static bool GetEventHandlers ( lua_State* pLuaVM, const char* szName ); // static bool GetEventHandlers ( lua_State* pLuaVM, const char* szName );
static bool TriggerEvent ( lua_State* pLuaVM, const char* szName, void* pUserData, CLuaArguments& Arguments ); static bool TriggerEvent ( lua_State* pLuaVM, const char* szName, PVOID pUserData, CLuaArguments& Arguments );
static bool CancelEvent ( lua_State* pLuaVM, bool bCancel, const char* szReason ); static bool CancelEvent ( lua_State* pLuaVM, bool bCancel, const char* szReason );
static bool WasEventCancelled ( lua_State* pLuaVM ); static bool WasEventCancelled ( lua_State* pLuaVM );
static string GetCancelReason ( lua_State* pLuaVM ); static string GetCancelReason ( lua_State* pLuaVM );
static bool TriggerClientEvent ( lua_State* pLuaVM, void* pSendTo, const char* szName, void* pSource, CLuaArguments& Arguments ); static bool TriggerClientEvent ( lua_State* pLuaVM, PVOID pSendTo, const char* szName, PVOID pSource, CLuaArguments& Arguments );
// static int TriggerLatentClientEvent ( lua_State* pLuaVM ); // static int TriggerLatentClientEvent ( lua_State* pLuaVM );
// static int GetLatentEventHandles ( lua_State* pLuaVM ); // static int GetLatentEventHandles ( lua_State* pLuaVM );
// static int GetLatentEventStatus ( lua_State* pLuaVM ); // static int GetLatentEventStatus ( lua_State* pLuaVM );
// static int CancelLatentEvent ( lua_State* pLuaVM ); // static int CancelLatentEvent ( lua_State* pLuaVM );
// Element create/destroy // Element create/destroy
static void* CreateElement ( lua_State* pLuaVM, const char* szTypeName, const char* szID ); static PVOID CreateElement ( lua_State* pLuaVM, const char* szTypeName, const char* szID );
static bool DestroyElement ( lua_State* pLuaVM, void* pUserData ); static bool DestroyElement ( lua_State* pLuaVM, PVOID pUserData );
static void* CloneElement ( lua_State* pLuaVM, void* pUserData, const Vector3& vecPosition, bool bCloneElement ); static PVOID CloneElement ( lua_State* pLuaVM, PVOID pUserData, const Vector3& vecPosition, bool bCloneElement );
// Element get funcs // Element get funcs
static CLuaArguments* GetElementsByType ( lua_State* pLuaVM, const char* szTypeName, void* pUserData = NULL ); static CLuaArgumentsVector GetElementsByType ( lua_State* pLuaVM, const char* szTypeName, PVOID pUserData = nullptr );
static bool IsElement ( lua_State* pLuaVM, void* pUserData ); static bool IsElement ( lua_State* pLuaVM, PVOID pUserData );
static string GetElementType ( lua_State* pLuaVM, void* pUserData ); static string GetElementType ( lua_State* pLuaVM, PVOID pUserData );
static void* GetElementByID ( lua_State* pLuaVM, const char* szID, unsigned int uiIndex ); static PVOID GetElementByID ( lua_State* pLuaVM, const char* szID, unsigned int uiIndex );
static void* GetElementByIndex ( lua_State* pLuaVM, int iIndex ); static PVOID GetElementByIndex ( lua_State* pLuaVM, int iIndex );
static void* GetElementChild ( lua_State* pLuaVM, void* pUserData, int iIndex ); static PVOID GetElementChild ( lua_State* pLuaVM, PVOID pUserData, int iIndex );
static int GetElementChildrenCount ( lua_State* pLuaVM, void* pUserData ); static int GetElementChildrenCount ( lua_State* pLuaVM, PVOID pUserData );
static string GetElementID ( lua_State* pLuaVM, void* pUserData ); static string GetElementID ( lua_State* pLuaVM, PVOID pUserData );
static CLuaArgument* GetElementData ( lua_State* pLuaVM, void* pUserData, string sKey, bool bInherit = true ); static CLuaArgument GetElementData ( lua_State* pLuaVM, PVOID pUserData, string sKey, bool bInherit = true );
static CLuaArguments* GetAllElementData ( lua_State* pLuaVM, void* pUserData ); static CLuaArguments GetAllElementData ( lua_State* pLuaVM, PVOID pUserData );
static void* GetElementParent ( lua_State* pLuaVM, void* pUserData ); static PVOID GetElementParent ( lua_State* pLuaVM, PVOID pUserData );
static bool GetElementPosition ( lua_State* pLuaVM, void* pUserData, Vector3& vecPosition ); static bool GetElementPosition ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecPosition );
static bool GetElementRotation ( lua_State* pLuaVM, void* pUserData, Vector3& vecRotation ); static bool GetElementRotation ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecRotation );
static bool GetElementVelocity ( lua_State* pLuaVM, void* pUserData, Vector3& vecVelocity ); static bool GetElementVelocity ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecVelocity );
static bool GetElementInterior ( lua_State* pLuaVM, void* pUserData, unsigned char& ucInterior ); static bool GetElementInterior ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucInterior );
static bool IsElementWithinColShape ( lua_State* pLuaVM, void* pUserData, bool& bWithin ); static bool IsElementWithinColShape ( lua_State* pLuaVM, PVOID pUserData, bool& bWithin );
static bool IsElementWithinMarker ( lua_State* pLuaVM, void* pUserData, bool& bWithin ); static bool IsElementWithinMarker ( lua_State* pLuaVM, PVOID pUserData, bool& bWithin );
static bool GetElementDimension ( lua_State* pLuaVM, void* pUserData, unsigned short& usDimension ); static bool GetElementDimension ( lua_State* pLuaVM, PVOID pUserData, unsigned short& usDimension );
static bool GetElementZoneName ( lua_State* pLuaVM, void* pUserData, string& strOutName, bool bCitiesOnly = false ); static bool GetElementZoneName ( lua_State* pLuaVM, PVOID pUserData, string& strOutName, bool bCitiesOnly = false );
static bool IsElementAttached ( lua_State* pLuaVM, void* pUserData ); static bool IsElementAttached ( lua_State* pLuaVM, PVOID pUserData );
static void* GetElementAttachedTo ( lua_State* pLuaVM, void* pUserData ); static PVOID GetElementAttachedTo ( lua_State* pLuaVM, PVOID pUserData );
static void* GetElementColShape ( lua_State* pLuaVM, void* pUserData ); static PVOID GetElementColShape ( lua_State* pLuaVM, PVOID pUserData );
static bool GetElementAlpha ( lua_State* pLuaVM, void* pUserData, unsigned char& ucAlpha ); static bool GetElementAlpha ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucAlpha );
static bool IsElementDoubleSided ( lua_State* pLuaVM, void* pUserData, bool& bDoubleSided ); static bool IsElementDoubleSided ( lua_State* pLuaVM, PVOID pUserData, bool& bDoubleSided );
static bool GetElementHealth ( lua_State* pLuaVM, void* pUserData, float& fHealth ); static bool GetElementHealth ( lua_State* pLuaVM, PVOID pUserData, float& fHealth );
static bool GetElementModel ( lua_State* pLuaVM, void* pUserData, unsigned short& usModel ); static bool GetElementModel ( lua_State* pLuaVM, PVOID pUserData, unsigned short& usModel );
static bool IsElementInWater ( lua_State* pLuaVM, void* pUserData, bool& bInWater ); static bool IsElementInWater ( lua_State* pLuaVM, PVOID pUserData, bool& bInWater );
static bool GetElementAttachedOffsets ( lua_State* pLuaVM, void* pUserData, Vector3& vecPosition, Vector3& vecRotation ); static bool GetElementAttachedOffsets ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecPosition, Vector3& vecRotation );
static void* GetElementSyncer ( lua_State* pLuaVM, void* pUserData ); static PVOID GetElementSyncer ( lua_State* pLuaVM, PVOID pUserData );
static bool GetElementCollisionsEnabled ( lua_State* pLuaVM, void* pUserData ); static bool GetElementCollisionsEnabled ( lua_State* pLuaVM, PVOID pUserData );
static bool IsElementFrozen ( lua_State* pLuaVM, void* pUserData, bool& bFrozen ); static bool IsElementFrozen ( lua_State* pLuaVM, PVOID pUserData, bool& bFrozen );
static bool GetLowLodElement ( lua_State* pLuaVM, void* pUserData, void*& pOutLowLodElement ); static bool GetLowLodElement ( lua_State* pLuaVM, PVOID pUserData, PVOID& pOutLowLodElement );
static bool IsElementLowLod ( lua_State* pLuaVM, void* pUserData, bool& bOutLowLod ); static bool IsElementLowLod ( lua_State* pLuaVM, PVOID pUserData, bool& bOutLowLod );
// Element set funcs // Element set funcs
static bool ClearElementVisibleTo ( lua_State* pLuaVM, void* pUserData ); static bool ClearElementVisibleTo ( lua_State* pLuaVM, PVOID pUserData );
static bool SetElementID ( lua_State* pLuaVM, void* pUserData, string sID ); static bool SetElementID ( lua_State* pLuaVM, PVOID pUserData, string sID );
static bool SetElementData ( lua_State* pLuaVM, void* pUserData, string sKey, const CLuaArgument& Variable ); static bool SetElementData ( lua_State* pLuaVM, PVOID pUserData, string sKey, const CLuaArgument& Variable );
static bool RemoveElementData ( lua_State* pLuaVM, void* pUserData, string sKey ); static bool RemoveElementData ( lua_State* pLuaVM, PVOID pUserData, string sKey );
static bool SetElementParent ( lua_State* pLuaVM, void* pUserData, void* pTarget ); static bool SetElementParent ( lua_State* pLuaVM, PVOID pUserData, PVOID pTarget );
static bool SetElementPosition ( lua_State* pLuaVM, void* pUserData, const Vector3& vecPosition, bool bWarp = true ); static bool SetElementPosition ( lua_State* pLuaVM, PVOID pUserData, const Vector3& vecPosition, bool bWarp = true );
static bool SetElementRotation ( lua_State* pLuaVM, void* pUserData, const Vector3& vecRotation, const char* szRotationOrder = "default", bool bNewWay = false ); static bool SetElementRotation ( lua_State* pLuaVM, PVOID pUserData, const Vector3& vecRotation, const char* szRotationOrder = "default", bool bNewWay = false );
static bool SetElementVelocity ( lua_State* pLuaVM, void* pUserData, const Vector3& vecVelocity ); static bool SetElementVelocity ( lua_State* pLuaVM, PVOID pUserData, const Vector3& vecVelocity );
static bool SetElementVisibleTo ( lua_State* pLuaVM, void* pUserData, void* pTarget, bool bVisible ); static bool SetElementVisibleTo ( lua_State* pLuaVM, PVOID pUserData, PVOID pTarget, bool bVisible );
static bool SetElementInterior ( lua_State* pLuaVM, void* pUserData, int iInterior ); static bool SetElementInterior ( lua_State* pLuaVM, PVOID pUserData, int iInterior );
static bool SetElementDimension ( lua_State* pLuaVM, void* pUserData, int iDimension ); static bool SetElementDimension ( lua_State* pLuaVM, PVOID pUserData, int iDimension );
static bool AttachElements ( lua_State* pLuaVM, void* pUserData, void* pTarget, Vector3& vecPosition, Vector3& vecRotation ); static bool AttachElements ( lua_State* pLuaVM, PVOID pUserData, PVOID pTarget, Vector3& vecPosition, Vector3& vecRotation );
static bool DetachElements ( lua_State* pLuaVM, void* pUserData, void* pTarget = NULL ); static bool DetachElements ( lua_State* pLuaVM, PVOID pUserData, PVOID pTarget = NULL );
static bool SetElementAlpha ( lua_State* pLuaVM, void* pUserData, int iAlpha ); static bool SetElementAlpha ( lua_State* pLuaVM, PVOID pUserData, int iAlpha );
static bool SetElementDoubleSided ( lua_State* pLuaVM, void* pUserData, bool bDoubleSided ); static bool SetElementDoubleSided ( lua_State* pLuaVM, PVOID pUserData, bool bDoubleSided );
static bool SetElementHealth ( lua_State* pLuaVM, void* pUserData, float fHealth ); static bool SetElementHealth ( lua_State* pLuaVM, PVOID pUserData, float fHealth );
static bool SetElementModel ( lua_State* pLuaVM, void* pUserData, int iModel ); static bool SetElementModel ( lua_State* pLuaVM, PVOID pUserData, int iModel );
static bool SetElementAttachedOffsets ( lua_State* pLuaVM, void* pUserData, Vector3& vecPosition, Vector3& vecRotation ); static bool SetElementAttachedOffsets ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecPosition, Vector3& vecRotation );
static bool SetElementSyncer ( lua_State* pLuaVM, void* pUserData, void* pPlayer ); static bool SetElementSyncer ( lua_State* pLuaVM, PVOID pUserData, PVOID pPlayer );
static bool SetElementCollisionsEnabled ( lua_State* pLuaVM, void* pUserData, bool bEnabled ); static bool SetElementCollisionsEnabled ( lua_State* pLuaVM, PVOID pUserData, bool bEnabled );
static bool SetElementFrozen ( lua_State* pLuaVM, void* pUserData, bool bFrozen ); static bool SetElementFrozen ( lua_State* pLuaVM, PVOID pUserData, bool bFrozen );
static bool SetLowLodElement ( lua_State* pLuaVM, void* pUserData, bool bEnabled ); static bool SetLowLodElement ( lua_State* pLuaVM, PVOID pUserData, bool bEnabled );
// Player get functions // Player get functions
static unsigned int GetPlayerCount ( lua_State* pLuaVM ); static unsigned int GetPlayerCount ( lua_State* pLuaVM );
static void* GetPlayerFromName ( lua_State* pLuaVM, const char* szNick ); static PVOID GetPlayerFromName ( lua_State* pLuaVM, const char* szNick );
static bool GetPlayerPing ( lua_State* pLuaVM, void* pUserData, unsigned int& uiPing ); static bool GetPlayerPing ( lua_State* pLuaVM, PVOID pUserData, unsigned int& uiPing );
static bool GetPlayerMoney ( lua_State* pLuaVM, void* pUserData, long& lMoney ); static bool GetPlayerMoney ( lua_State* pLuaVM, PVOID pUserData, long& lMoney );
static void* GetRandomPlayer ( lua_State* pLuaVM ); static PVOID GetRandomPlayer ( lua_State* pLuaVM );
static bool IsPlayerMuted ( lua_State* pLuaVM, void* pUserData, bool& bMuted ); static bool IsPlayerMuted ( lua_State* pLuaVM, PVOID pUserData, bool& bMuted );
static void* GetPlayerTeam ( lua_State* pLuaVM, void* pUserData ); static PVOID GetPlayerTeam ( lua_State* pLuaVM, PVOID pUserData );
static bool GetPlayerWantedLevel ( lua_State* pLuaVM, void* pUserData, unsigned int& uiWantedLevel ); static bool GetPlayerWantedLevel ( lua_State* pLuaVM, PVOID pUserData, unsigned int& uiWantedLevel );
static CLuaArguments* GetAlivePlayers ( lua_State* pLuaVM ); static CLuaArgumentsVector GetAlivePlayers ( lua_State* pLuaVM );
static CLuaArguments* GetDeadPlayers ( lua_State* pLuaVM ); static CLuaArgumentsVector GetDeadPlayers ( lua_State* pLuaVM );
static bool GetPlayerIdleTime ( lua_State* pLuaVM, void* pUserData, unsigned int& uiIdleTime ); static bool GetPlayerIdleTime ( lua_State* pLuaVM, PVOID pUserData, unsigned int& uiIdleTime );
static bool IsPlayerMapForced ( lua_State* pLuaVM, void* pUserData, bool& bForced ); static bool IsPlayerMapForced ( lua_State* pLuaVM, PVOID pUserData, bool& bForced );
static bool GetPlayerNametagText ( lua_State* pLuaVM, void* pUserData, string& strOutText ); static bool GetPlayerNametagText ( lua_State* pLuaVM, PVOID pUserData, string& strOutText );
static bool GetPlayerNametagColor ( lua_State* pLuaVM, void* pUserData, unsigned char& ucR, unsigned char& ucG, unsigned char& ucB ); static bool GetPlayerNametagColor ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucR, unsigned char& ucG, unsigned char& ucB );
static bool IsPlayerNametagShowing ( lua_State* pLuaVM, void* pUserData, bool& bShowing ); static bool IsPlayerNametagShowing ( lua_State* pLuaVM, PVOID pUserData, bool& bShowing );
static string GetPlayerSerial ( lua_State* pLuaVM, void* pUserData ); static string GetPlayerSerial ( lua_State* pLuaVM, PVOID pUserData );
static string GetPlayerUserName ( lua_State* pLuaVM, void* pUserData ); static string GetPlayerUserName ( lua_State* pLuaVM, PVOID pUserData );
static bool GetPlayerBlurLevel ( lua_State* pLuaVM, void* pUserData, unsigned char& ucLevel ); static bool GetPlayerBlurLevel ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucLevel );
static bool GetPlayerName ( lua_State* pLuaVM, void* pUserData, string& strOutName ); static bool GetPlayerName ( lua_State* pLuaVM, PVOID pUserData, string& strOutName );
static bool GetPlayerIP ( lua_State* pLuaVM, void* pUserData, string& strOutIP ); static bool GetPlayerIP ( lua_State* pLuaVM, PVOID pUserData, string& strOutIP );
static void* GetPlayerAccount ( lua_State* pLuaVM, void* pUserData ); static PVOID GetPlayerAccount ( lua_State* pLuaVM, PVOID pUserData );
static string GetPlayerVersion ( lua_State* pLuaVM, void* pUserData ); static string GetPlayerVersion ( lua_State* pLuaVM, PVOID pUserData );
static LuaTable GetPlayerACInfo ( lua_State* pLuaVM, void* pUserData ); static CLuaArgumentsMap* GetPlayerACInfo ( lua_State* pLuaVM, PVOID pUserData );
// Player set functions // Player set functions
static bool SetPlayerMoney ( lua_State* pLuaVM, void* pUserData, int iAmount, bool bInstant = false ); static bool SetPlayerMoney ( lua_State* pLuaVM, PVOID pUserData, int iAmount, bool bInstant = false );
static bool GivePlayerMoney ( lua_State* pLuaVM, void* pUserData, int iAmount ); static bool GivePlayerMoney ( lua_State* pLuaVM, PVOID pUserData, int iAmount );
static bool TakePlayerMoney ( lua_State* pLuaVM, void* pUserData, int iAmount ); static bool TakePlayerMoney ( lua_State* pLuaVM, PVOID pUserData, int iAmount );
static bool SpawnPlayer ( lua_State* pLuaVM, void* pUserData, Vector3& vecPosition, int iRotation = 0, int iSkinID = 0, int iInterior = 0, int iDimension = 0, void* theTeam = NULL ); static bool SpawnPlayer ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecPosition, int iRotation = 0, int iSkinID = 0, int iInterior = 0, int iDimension = 0, PVOID theTeam = NULL );
static bool ShowPlayerHudComponent ( lua_State* pLuaVM, void* pUserData, string sComponent, bool bShow ); static bool ShowPlayerHudComponent ( lua_State* pLuaVM, PVOID pUserData, string sComponent, bool bShow );
static bool SetPlayerWantedLevel ( lua_State* pLuaVM, void* pUserData, int iLevel ); static bool SetPlayerWantedLevel ( lua_State* pLuaVM, PVOID pUserData, int iLevel );
static bool ForcePlayerMap ( lua_State* pLuaVM, void* pUserData, bool bForceOn ); static bool ForcePlayerMap ( lua_State* pLuaVM, PVOID pUserData, bool bForceOn );
static bool SetPlayerNametagText ( lua_State* pLuaVM, void* pUserData, string sText ); static bool SetPlayerNametagText ( lua_State* pLuaVM, PVOID pUserData, string sText );
static bool SetPlayerNametagColor ( lua_State* pLuaVM, void* pUserData, int iRed = 0, int iGreen = 0, int iBlue = 0 ); static bool SetPlayerNametagColor ( lua_State* pLuaVM, PVOID pUserData, int iRed = 0, int iGreen = 0, int iBlue = 0 );
static bool SetPlayerNametagShowing ( lua_State* pLuaVM, void* pUserData, bool bShowing ); static bool SetPlayerNametagShowing ( lua_State* pLuaVM, PVOID pUserData, bool bShowing );
static bool SetPlayerMuted ( lua_State* pLuaVM, void* pUserData, bool bMuted ); static bool SetPlayerMuted ( lua_State* pLuaVM, PVOID pUserData, bool bMuted );
static bool SetPlayerBlurLevel ( lua_State* pLuaVM, void* pUserData, int iLevel ); static bool SetPlayerBlurLevel ( lua_State* pLuaVM, PVOID pUserData, int iLevel );
static bool RedirectPlayer ( lua_State* pLuaVM, void* pUserData, const char* szServerIP, int iServerPort, const char* szServerPassword ); static bool RedirectPlayer ( lua_State* pLuaVM, PVOID pUserData, const char* szServerIP, int iServerPort, const char* szServerPassword );
static bool SetPlayerName ( lua_State* pLuaVM, void* pUserData, string sName ); static bool SetPlayerName ( lua_State* pLuaVM, PVOID pUserData, string sName );
static bool DetonateSatchels ( lua_State* pLuaVM, void* pUserData ); static bool DetonateSatchels ( lua_State* pLuaVM, PVOID pUserData );
static bool TakePlayerScreenShot ( lua_State* pLuaVM, void* pUserData, int iWidth, int iHeight, string sTag = "", int iQuality = 30, int iMaxBandwith = 5000 ); static bool TakePlayerScreenShot ( lua_State* pLuaVM, PVOID pUserData, int iWidth, int iHeight, string sTag = "", int iQuality = 30, int iMaxBandwith = 5000 );
// Ped get functions // Ped get functions
static void* CreatePed ( lua_State* pLuaVM, int iModelid, const Vector3& vecPosition, float fRot = 0.0, bool bSynced = true ); static PVOID CreatePed ( lua_State* pLuaVM, int iModelid, const Vector3& vecPosition, float fRot = 0.0, bool bSynced = true );
static bool GetPedArmor ( lua_State* pLuaVM, void* pUserData, float& fArmor ); static bool GetPedArmor ( lua_State* pLuaVM, PVOID pUserData, float& fArmor );
static bool IsPedChoking ( lua_State* pLuaVM, void* pUserData, bool& bIsChoking ); static bool IsPedChoking ( lua_State* pLuaVM, PVOID pUserData, bool& bIsChoking );
static bool IsPedDead ( lua_State* pLuaVM, void* pUserData, bool& bDead ); static bool IsPedDead ( lua_State* pLuaVM, PVOID pUserData, bool& bDead );
static bool IsPedDucked ( lua_State* pLuaVM, void* pUserData, bool& bDucked ); static bool IsPedDucked ( lua_State* pLuaVM, PVOID pUserData, bool& bDucked );
static bool GetPedStat ( lua_State* pLuaVM, void* pUserData, unsigned short usStat, float& fValue ); static bool GetPedStat ( lua_State* pLuaVM, PVOID pUserData, unsigned short usStat, float& fValue );
static void* GetPedTarget ( lua_State* pLuaVM, void* pUserData ); static PVOID GetPedTarget ( lua_State* pLuaVM, PVOID pUserData );
static int GetPedWeapon ( lua_State* pLuaVM, void* pUserData, int iWeaponSlot = -1 ); static int GetPedWeapon ( lua_State* pLuaVM, PVOID pUserData, int iWeaponSlot = -1 );
static bool GetPedClothes ( lua_State* pLuaVM, void* pUserData, unsigned char ucType, string& strOutTexture, string& strOutModel ); static bool GetPedClothes ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucType, string& strOutTexture, string& strOutModel );
static bool DoesPedHaveJetPack ( lua_State* pLuaVM, void* pUserData, bool& bHasJetPack ); static bool DoesPedHaveJetPack ( lua_State* pLuaVM, PVOID pUserData, bool& bHasJetPack );
static bool IsPedOnGround ( lua_State* pLuaVM, void* pUserData, bool& bOnGround ); static bool IsPedOnGround ( lua_State* pLuaVM, PVOID pUserData, bool& bOnGround );
static bool GetPedFightingStyle ( lua_State* pLuaVM, void* pUserData, unsigned char& ucStyle ); static bool GetPedFightingStyle ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucStyle );
static bool GetPedMoveAnim ( lua_State* pLuaVM, void* pUserData, unsigned int& iMoveAnim ); static bool GetPedMoveAnim ( lua_State* pLuaVM, PVOID pUserData, unsigned int& iMoveAnim );
static bool GetPedGravity ( lua_State* pLuaVM, void* pUserData, float& fGravity ); static bool GetPedGravity ( lua_State* pLuaVM, PVOID pUserData, float& fGravity );
static void* GetPedContactElement ( lua_State* pLuaVM, void* pUserData ); static PVOID GetPedContactElement ( lua_State* pLuaVM, PVOID pUserData );
static bool GetPedWeaponSlot ( lua_State* pLuaVM, void* pUserData, unsigned char& ucWeaponSlot ); static bool GetPedWeaponSlot ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucWeaponSlot );
static bool IsPedDoingGangDriveby ( lua_State* pLuaVM, void* pUserData, bool & bDoingGangDriveby ); static bool IsPedDoingGangDriveby ( lua_State* pLuaVM, PVOID pUserData, bool & bDoingGangDriveby );
static bool IsPedOnFire ( lua_State* pLuaVM, void* pUserData, bool & bIsOnFire ); static bool IsPedOnFire ( lua_State* pLuaVM, PVOID pUserData, bool & bIsOnFire );
static bool IsPedHeadless ( lua_State* pLuaVM, void* pUserData, bool & bIsHeadless ); static bool IsPedHeadless ( lua_State* pLuaVM, PVOID pUserData, bool & bIsHeadless );
static bool IsPedFrozen ( lua_State* pLuaVM, void* pUserData, bool & bIsFrozen ); static bool IsPedFrozen ( lua_State* pLuaVM, PVOID pUserData, bool & bIsFrozen );
static void* GetPedOccupiedVehicle ( lua_State* pLuaVM, void* pUserData ); static PVOID GetPedOccupiedVehicle ( lua_State* pLuaVM, PVOID pUserData );
static bool GetPedOccupiedVehicleSeat ( lua_State* pLuaVM, void* pUserData, unsigned int& uiSeat ); static bool GetPedOccupiedVehicleSeat ( lua_State* pLuaVM, PVOID pUserData, unsigned int& uiSeat );
static bool IsPedInVehicle ( lua_State* pLuaVM, void* pUserData, bool & bIsInVehicle ); static bool IsPedInVehicle ( lua_State* pLuaVM, PVOID pUserData, bool & bIsInVehicle );
static bool GetWeaponProperty ( lua_State* pLuaVM, unsigned char ucWeaponID, const char* szWeaponSkill, const char* szProperty, short& uData ); static bool GetWeaponProperty ( lua_State* pLuaVM, unsigned char ucWeaponID, const char* szWeaponSkill, const char* szProperty, short& uData );
static bool GetOriginalWeaponProperty ( lua_State* pLuaVM, unsigned char ucWeaponID, const char *szWeaponSkill, const char* szProperty, short& uData ); static bool GetOriginalWeaponProperty ( lua_State* pLuaVM, unsigned char ucWeaponID, const char *szWeaponSkill, const char* szProperty, short& uData );
// Ped set functions // Ped set functions
static bool SetPedArmor ( lua_State* pLuaVM, void* pUserData, float fArmor ); static bool SetPedArmor ( lua_State* pLuaVM, PVOID pUserData, float fArmor );
static bool KillPed ( lua_State* pLuaVM, void* pUserData, void* pKiller = NULL, unsigned char ucKillerWeapon = 0xFF, unsigned char ucBodyPart = 0xFF, bool bStealth = false ); static bool KillPed ( lua_State* pLuaVM, PVOID pUserData, PVOID pKiller = NULL, unsigned char ucKillerWeapon = 0xFF, unsigned char ucBodyPart = 0xFF, bool bStealth = false );
static bool SetPedStat ( lua_State* pLuaVM, void* pUserData, unsigned short usStat, float fValue ); static bool SetPedStat ( lua_State* pLuaVM, PVOID pUserData, unsigned short usStat, float fValue );
static bool AddPedClothes ( lua_State* pLuaVM, void* pUserData, const char* szTexture, const char* szModel, unsigned char ucType ); static bool AddPedClothes ( lua_State* pLuaVM, PVOID pUserData, const char* szTexture, const char* szModel, unsigned char ucType );
static bool RemovePedClothes ( lua_State* pLuaVM, void* pUserData, unsigned char ucType, const char* szTexture = NULL, const char* szModel = NULL ); static bool RemovePedClothes ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucType, const char* szTexture = NULL, const char* szModel = NULL );
static bool GivePedJetPack ( lua_State* pLuaVM, void* pUserData ); static bool GivePedJetPack ( lua_State* pLuaVM, PVOID pUserData );
static bool RemovePedJetPack ( lua_State* pLuaVM, void* pUserData ); static bool RemovePedJetPack ( lua_State* pLuaVM, PVOID pUserData );
static bool SetPedFightingStyle ( lua_State* pLuaVM, void* pUserData, unsigned char ucStyle ); static bool SetPedFightingStyle ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucStyle );
static bool SetPedMoveAnim ( lua_State* pLuaVM, void* pUserData, unsigned int iMoveAnim ); static bool SetPedMoveAnim ( lua_State* pLuaVM, PVOID pUserData, unsigned int iMoveAnim );
static bool SetPedGravity ( lua_State* pLuaVM, void* pUserData, float fGravity ); static bool SetPedGravity ( lua_State* pLuaVM, PVOID pUserData, float fGravity );
static bool SetPedChoking ( lua_State* pLuaVM, void* pUserData, bool bChoking ); static bool SetPedChoking ( lua_State* pLuaVM, PVOID pUserData, bool bChoking );
static bool SetPedWeaponSlot ( lua_State* pLuaVM, void* pUserData, unsigned char ucWeaponSlot ); static bool SetPedWeaponSlot ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucWeaponSlot );
static bool WarpPedIntoVehicle ( lua_State* pLuaVM, void* pUserData, void* pVehicle, unsigned int uiSeat = 0 ); static bool WarpPedIntoVehicle ( lua_State* pLuaVM, PVOID pUserData, PVOID pVehicle, unsigned int uiSeat = 0 );
static bool RemovePedFromVehicle ( lua_State* pLuaVM, void* pUserData ); static bool RemovePedFromVehicle ( lua_State* pLuaVM, PVOID pUserData );
static bool SetPedDoingGangDriveby ( lua_State* pLuaVM, void* pUserData, bool bGangDriveby ); static bool SetPedDoingGangDriveby ( lua_State* pLuaVM, PVOID pUserData, bool bGangDriveby );
static bool SetPedAnimation ( lua_State* pLuaVM, void* pUserData, const char * szBlockName, const char * szAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame ); static bool SetPedAnimation ( lua_State* pLuaVM, PVOID pUserData, const char * szBlockName, const char * szAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame );
static bool SetPedAnimationProgress ( lua_State* pLuaVM, void* pUserData, const char * szAnimName, float fProgress ); static bool SetPedAnimationProgress ( lua_State* pLuaVM, PVOID pUserData, const char * szAnimName, float fProgress );
static bool SetPedOnFire ( lua_State* pLuaVM, void* pUserData, bool bIsOnFire ); static bool SetPedOnFire ( lua_State* pLuaVM, PVOID pUserData, bool bIsOnFire );
static bool SetPedHeadless ( lua_State* pLuaVM, void* pUserData, bool bIsHeadless ); static bool SetPedHeadless ( lua_State* pLuaVM, PVOID pUserData, bool bIsHeadless );
static bool SetPedFrozen ( lua_State* pLuaVM, void* pUserData, bool bIsFrozen ); static bool SetPedFrozen ( lua_State* pLuaVM, PVOID pUserData, bool bIsFrozen );
static bool ReloadPedWeapon ( lua_State* pLuaVM, void* pUserData ); static bool ReloadPedWeapon ( lua_State* pLuaVM, PVOID pUserData );
static bool SetWeaponProperty ( lua_State* pLuaVM, unsigned char ucWeaponID, const char *szWeaponSkill, const char* szProperty, short uData ); static bool SetWeaponProperty ( lua_State* pLuaVM, unsigned char ucWeaponID, const char *szWeaponSkill, const char* szProperty, short uData );
// Weapon give/take functions // Weapon give/take functions
@ -226,195 +226,195 @@ public:
// static int GetSlotFromWeapon ( lua_State* pLuaVM ); // static int GetSlotFromWeapon ( lua_State* pLuaVM );
// Vehicle create/destroy functions // Vehicle create/destroy functions
static void* CreateVehicle ( lua_State* pLuaVM, int model, float fX, float fY, float fZ, float fRX, float fRY, float fRZ, string numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 ); static PVOID CreateVehicle ( lua_State* pLuaVM, int model, float fX, float fY, float fZ, float fRX, float fRY, float fRZ, string numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 );
// Vehicle get functions // Vehicle get functions
static bool GetVehicleType ( lua_State* pLuaVM, void* pUserData, string& strType ); static bool GetVehicleType ( lua_State* pLuaVM, PVOID pUserData, string& strType );
static bool GetVehicleVariant ( lua_State* pLuaVM, void* pUserData, unsigned char& ucVariant, unsigned char& ucVariant2 ); static bool GetVehicleVariant ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucVariant, unsigned char& ucVariant2 );
static bool GetVehicleColor ( lua_State* pLuaVM, void* pUserData, CVehicleColor& color ); static bool GetVehicleColor ( lua_State* pLuaVM, PVOID pUserData, CVehicleColor& color );
static bool GetVehicleModelFromName ( lua_State* pLuaVM, const char* szName, unsigned short& usID ); static bool GetVehicleModelFromName ( lua_State* pLuaVM, const char* szName, unsigned short& usID );
static bool GetVehicleLandingGearDown ( lua_State* pLuaVM, void* pUserData, bool& bGearDown ); static bool GetVehicleLandingGearDown ( lua_State* pLuaVM, PVOID pUserData, bool& bGearDown );
static bool GetVehicleMaxPassengers ( lua_State* pLuaVM, void* pUserData, unsigned char& ucMaxPassengers ); static bool GetVehicleMaxPassengers ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucMaxPassengers );
static bool GetVehicleName ( lua_State* pLuaVM, void* pUserData, string& strOutName ); static bool GetVehicleName ( lua_State* pLuaVM, PVOID pUserData, string& strOutName );
static bool GetVehicleNameFromModel ( lua_State* pLuaVM, unsigned short usModel, string& strOutName ); static bool GetVehicleNameFromModel ( lua_State* pLuaVM, unsigned short usModel, string& strOutName );
static void* GetVehicleOccupant ( lua_State* pLuaVM, void* pUserData, unsigned int uiSeat ); static PVOID GetVehicleOccupant ( lua_State* pLuaVM, PVOID pUserData, unsigned int uiSeat );
static CLuaArguments* GetVehicleOccupants ( lua_State* pLuaVM, void* pUserData ); static CLuaArgumentsVector GetVehicleOccupants ( lua_State* pLuaVM, PVOID pUserData );
static void* GetVehicleController ( lua_State* pLuaVM, void* pUserData ); static PVOID GetVehicleController ( lua_State* pLuaVM, PVOID pUserData );
static bool GetVehicleSirensOn ( lua_State* pLuaVM, void* pUserData, bool& bSirensOn ); static bool GetVehicleSirensOn ( lua_State* pLuaVM, PVOID pUserData, bool& bSirensOn );
static bool GetVehicleTurnVelocity ( lua_State* pLuaVM, void* pUserData, Vector3& vecTurnVelocity ); static bool GetVehicleTurnVelocity ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecTurnVelocity );
static bool GetVehicleTurretPosition ( lua_State* pLuaVM, void* pUserData, Vector2& vecPosition ); static bool GetVehicleTurretPosition ( lua_State* pLuaVM, PVOID pUserData, Vector2& vecPosition );
static bool IsVehicleLocked ( lua_State* pLuaVM, void* pUserData, bool& bLocked ); static bool IsVehicleLocked ( lua_State* pLuaVM, PVOID pUserData, bool& bLocked );
static CLuaArguments* GetVehiclesOfType ( lua_State* pLuaVM, unsigned int uiModel ); static CLuaArgumentsVector GetVehiclesOfType ( lua_State* pLuaVM, unsigned int uiModel );
static bool GetVehicleUpgradeOnSlot ( lua_State* pLuaVM, void* pUserData, unsigned char ucSlot, unsigned short& usUpgrade ); static bool GetVehicleUpgradeOnSlot ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucSlot, unsigned short& usUpgrade );
static CLuaArguments* GetVehicleUpgrades ( lua_State* pLuaVM, void* pUserData ); static CLuaArgumentsVector GetVehicleUpgrades ( lua_State* pLuaVM, PVOID pUserData );
static bool GetVehicleUpgradeSlotName ( lua_State* pLuaVM, unsigned char ucSlot, string& strOutName ); static bool GetVehicleUpgradeSlotName ( lua_State* pLuaVM, unsigned char ucSlot, string& strOutName );
static bool GetVehicleUpgradeSlotName ( lua_State* pLuaVM, unsigned short usUpgrade, string& strOutName ); static bool GetVehicleUpgradeSlotName ( lua_State* pLuaVM, unsigned short usUpgrade, string& strOutName );
static CLuaArguments* GetVehicleCompatibleUpgrades ( lua_State* pLuaVM, void* pUserData ); static CLuaArgumentsVector GetVehicleCompatibleUpgrades ( lua_State* pLuaVM, PVOID pUserData );
static bool GetVehicleDoorState ( lua_State* pLuaVM, void* pUserData, unsigned char ucDoor, unsigned char& ucState ); static bool GetVehicleDoorState ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucDoor, unsigned char& ucState );
static bool GetVehicleWheelStates ( lua_State* pLuaVM, void* pUserData, unsigned char& ucFrontLeft, unsigned char& ucRearLeft, unsigned char& ucFrontRight, unsigned char& ucRearRight ); static bool GetVehicleWheelStates ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucFrontLeft, unsigned char& ucRearLeft, unsigned char& ucFrontRight, unsigned char& ucRearRight );
static bool GetVehicleLightState ( lua_State* pLuaVM, void* pUserData, unsigned char ucLight, unsigned char& ucState ); static bool GetVehicleLightState ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucLight, unsigned char& ucState );
static bool GetVehiclePanelState ( lua_State* pLuaVM, void* pUserData, unsigned char ucPanel, unsigned char& ucState ); static bool GetVehiclePanelState ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucPanel, unsigned char& ucState );
static bool GetVehicleOverrideLights ( lua_State* pLuaVM, void* pUserData, unsigned char& ucLights ); static bool GetVehicleOverrideLights ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucLights );
static void* GetVehicleTowedByVehicle ( lua_State* pLuaVM, void* pUserData ); static PVOID GetVehicleTowedByVehicle ( lua_State* pLuaVM, PVOID pUserData );
static void* GetVehicleTowingVehicle ( lua_State* pLuaVM, void* pUserData ); static PVOID GetVehicleTowingVehicle ( lua_State* pLuaVM, PVOID pUserData );
static bool GetVehiclePaintjob ( lua_State* pLuaVM, void* pUserData, unsigned char& ucPaintjob ); static bool GetVehiclePaintjob ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucPaintjob );
static bool GetVehiclePlateText ( lua_State* pLuaVM, void* pUserData, char* szPlateText ); static bool GetVehiclePlateText ( lua_State* pLuaVM, PVOID pUserData, char* szPlateText );
static bool IsVehicleDamageProof ( lua_State* pLuaVM, void* pUserData, bool& bDamageProof ); static bool IsVehicleDamageProof ( lua_State* pLuaVM, PVOID pUserData, bool& bDamageProof );
static bool IsVehicleFuelTankExplodable ( lua_State* pLuaVM, void* pUserData, bool& bExplodable ); static bool IsVehicleFuelTankExplodable ( lua_State* pLuaVM, PVOID pUserData, bool& bExplodable );
static bool IsVehicleFrozen ( lua_State* pLuaVM, void* pUserData, bool& bFrozen ); static bool IsVehicleFrozen ( lua_State* pLuaVM, PVOID pUserData, bool& bFrozen );
static bool IsVehicleOnGround ( lua_State* pLuaVM, void* pUserData, bool& bOnGround ); static bool IsVehicleOnGround ( lua_State* pLuaVM, PVOID pUserData, bool& bOnGround );
static bool GetVehicleEngineState ( lua_State* pLuaVM, void* pUserData, bool& bState ); static bool GetVehicleEngineState ( lua_State* pLuaVM, PVOID pUserData, bool& bState );
static bool IsTrainDerailed ( lua_State* pLuaVM, void* pUserData, bool& bDerailed ); static bool IsTrainDerailed ( lua_State* pLuaVM, PVOID pUserData, bool& bDerailed );
static bool IsTrainDerailable ( lua_State* pLuaVM, void* pUserData, bool& bDerailable ); static bool IsTrainDerailable ( lua_State* pLuaVM, PVOID pUserData, bool& bDerailable );
static bool GetTrainDirection ( lua_State* pLuaVM, void* pUserData, bool& bDirection ); static bool GetTrainDirection ( lua_State* pLuaVM, PVOID pUserData, bool& bDirection );
static bool GetTrainSpeed ( lua_State* pLuaVM, void* pUserData, float& fSpeed ); static bool GetTrainSpeed ( lua_State* pLuaVM, PVOID pUserData, float& fSpeed );
static bool IsVehicleBlown ( lua_State* pLuaVM, void* pUserData ); static bool IsVehicleBlown ( lua_State* pLuaVM, PVOID pUserData );
static bool GetVehicleHeadLightColor ( lua_State* pLuaVM, void* pUserData, SColor& outColor ); static bool GetVehicleHeadLightColor ( lua_State* pLuaVM, PVOID pUserData, SColor& outColor );
static bool GetVehicleDoorOpenRatio ( lua_State* pLuaVM, void* pUserData, unsigned char ucDoor, float& fRatio ); static bool GetVehicleDoorOpenRatio ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucDoor, float& fRatio );
static bool IsVehicleTaxiLightOn ( lua_State* pLuaVM, void* pUserData, bool& bLightOn ); static bool IsVehicleTaxiLightOn ( lua_State* pLuaVM, PVOID pUserData, bool& bLightOn );
// Vehicle set functions // Vehicle set functions
static bool FixVehicle ( lua_State* pLuaVM, void* pUserData ); static bool FixVehicle ( lua_State* pLuaVM, PVOID pUserData );
static bool BlowVehicle ( lua_State* pLuaVM, void* pUserData, bool bExplode ); static bool BlowVehicle ( lua_State* pLuaVM, PVOID pUserData, bool bExplode );
static bool SetVehicleTurnVelocity ( lua_State* pLuaVM, void* pUserData, float fX, float fY, float fZ ); static bool SetVehicleTurnVelocity ( lua_State* pLuaVM, PVOID pUserData, float fX, float fY, float fZ );
static bool SetVehicleColor ( lua_State* pLuaVM, void* pUserData, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, unsigned char ucRed2, unsigned char ucGreen2, unsigned char ucBlue2, unsigned char ucRed3, unsigned char ucGreen3, unsigned char ucBlue3, unsigned char ucRed4, unsigned char ucGreen4, unsigned char ucBlue4 ); static bool SetVehicleColor ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, unsigned char ucRed2, unsigned char ucGreen2, unsigned char ucBlue2, unsigned char ucRed3, unsigned char ucGreen3, unsigned char ucBlue3, unsigned char ucRed4, unsigned char ucGreen4, unsigned char ucBlue4 );
static bool SetVehicleLandingGearDown ( lua_State* pLuaVM, void* pUserData, bool bLandingGearDown ); static bool SetVehicleLandingGearDown ( lua_State* pLuaVM, PVOID pUserData, bool bLandingGearDown );
static bool SetVehicleLocked ( lua_State* pLuaVM, void* pUserData, bool bLocked ); static bool SetVehicleLocked ( lua_State* pLuaVM, PVOID pUserData, bool bLocked );
static bool SetVehicleDoorsUndamageable ( lua_State* pLuaVM, void* pUserData, bool bDoorsUndamageable ); static bool SetVehicleDoorsUndamageable ( lua_State* pLuaVM, PVOID pUserData, bool bDoorsUndamageable );
static bool SetVehicleSirensOn ( lua_State* pLuaVM, void* pUserData, bool bSirensOn ); static bool SetVehicleSirensOn ( lua_State* pLuaVM, PVOID pUserData, bool bSirensOn );
static bool SetVehicleTaxiLightOn ( lua_State* pLuaVM, void* pUserData, bool bTaxiLightState ); static bool SetVehicleTaxiLightOn ( lua_State* pLuaVM, PVOID pUserData, bool bTaxiLightState );
static bool AddVehicleUpgrade ( lua_State* pLuaVM, void* pUserData, unsigned short usUpgrade ); static bool AddVehicleUpgrade ( lua_State* pLuaVM, PVOID pUserData, unsigned short usUpgrade );
static bool RemoveVehicleUpgrade ( lua_State* pLuaVM, void* pUserData, unsigned short usUpgrade ); static bool RemoveVehicleUpgrade ( lua_State* pLuaVM, PVOID pUserData, unsigned short usUpgrade );
static bool SetVehicleDoorState ( lua_State* pLuaVM, void* pUserData, unsigned char ucDoor, unsigned char ucState ); static bool SetVehicleDoorState ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucDoor, unsigned char ucState );
static bool SetVehicleWheelStates ( lua_State* pLuaVM, void* pUserData, int iFrontLeft, int iRearLeft = -1, int iFrontRight = -1, int iRearRight = -1 ); static bool SetVehicleWheelStates ( lua_State* pLuaVM, PVOID pUserData, int iFrontLeft, int iRearLeft = -1, int iFrontRight = -1, int iRearRight = -1 );
static bool SetVehicleLightState ( lua_State* pLuaVM, void* pUserData, unsigned char ucLight, unsigned char ucState ); static bool SetVehicleLightState ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucLight, unsigned char ucState );
static bool SetVehiclePanelState ( lua_State* pLuaVM, void* pUserData, unsigned char ucPanel, unsigned char ucState ); static bool SetVehiclePanelState ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucPanel, unsigned char ucState );
static bool SetVehicleIdleRespawnDelay ( lua_State* pLuaVM, void* pUserData, unsigned long ulTime ); static bool SetVehicleIdleRespawnDelay ( lua_State* pLuaVM, PVOID pUserData, unsigned long ulTime );
static bool SetVehicleRespawnDelay ( lua_State* pLuaVM, void* pUserData, unsigned long ulTime ); static bool SetVehicleRespawnDelay ( lua_State* pLuaVM, PVOID pUserData, unsigned long ulTime );
static bool SetVehicleRespawnPosition ( lua_State* pLuaVM, void* pUserData, float fX, float fY, float fZ, float fRX, float fRY, float fRZ ); static bool SetVehicleRespawnPosition ( lua_State* pLuaVM, PVOID pUserData, float fX, float fY, float fZ, float fRX, float fRY, float fRZ );
static bool ToggleVehicleRespawn ( lua_State* pLuaVM, void* pUserData, bool bRespawn ); static bool ToggleVehicleRespawn ( lua_State* pLuaVM, PVOID pUserData, bool bRespawn );
static bool ResetVehicleExplosionTime ( lua_State* pLuaVM, void* pUserData ); static bool ResetVehicleExplosionTime ( lua_State* pLuaVM, PVOID pUserData );
static bool ResetVehicleIdleTime ( lua_State* pLuaVM, void* pUserData ); static bool ResetVehicleIdleTime ( lua_State* pLuaVM, PVOID pUserData );
static bool SpawnVehicle ( lua_State* pLuaVM, void* pUserData, float fX, float fY, float fZ, float fRX, float fRY, float fRZ ); static bool SpawnVehicle ( lua_State* pLuaVM, PVOID pUserData, float fX, float fY, float fZ, float fRX, float fRY, float fRZ );
static bool RespawnVehicle ( lua_State* pLuaVM, void* pUserData ); static bool RespawnVehicle ( lua_State* pLuaVM, PVOID pUserData );
static bool SetVehicleOverrideLights ( lua_State* pLuaVM, void* pUserData, unsigned char ucLights ); static bool SetVehicleOverrideLights ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucLights );
static bool AttachTrailerToVehicle ( lua_State* pLuaVM, void* pUserData, void* pTrailer ); static bool AttachTrailerToVehicle ( lua_State* pLuaVM, PVOID pUserData, PVOID pTrailer );
static bool DetachTrailerFromVehicle ( lua_State* pLuaVM, void* pUserData, void* pTrailer = NULL ); static bool DetachTrailerFromVehicle ( lua_State* pLuaVM, PVOID pUserData, PVOID pTrailer = NULL );
static bool SetVehicleEngineState ( lua_State* pLuaVM, void* pUserData, bool bState ); static bool SetVehicleEngineState ( lua_State* pLuaVM, PVOID pUserData, bool bState );
static bool SetVehicleDirtLevel ( lua_State* pLuaVM, void* pUserData, float fDirtLevel ); static bool SetVehicleDirtLevel ( lua_State* pLuaVM, PVOID pUserData, float fDirtLevel );
static bool SetVehicleDamageProof ( lua_State* pLuaVM, void* pUserData, bool bDamageProof ); static bool SetVehicleDamageProof ( lua_State* pLuaVM, PVOID pUserData, bool bDamageProof );
static bool SetVehiclePaintjob ( lua_State* pLuaVM, void* pUserData, unsigned char ucPaintjob ); static bool SetVehiclePaintjob ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucPaintjob );
static bool SetVehicleFuelTankExplodable ( lua_State* pLuaVM, void* pUserData, bool bExplodable ); static bool SetVehicleFuelTankExplodable ( lua_State* pLuaVM, PVOID pUserData, bool bExplodable );
static bool SetVehicleFrozen ( lua_State* pLuaVM, void* pUserData, bool bFrozen ); static bool SetVehicleFrozen ( lua_State* pLuaVM, PVOID pUserData, bool bFrozen );
static bool SetTrainDerailed ( lua_State* pLuaVM, void* pUserData, bool bDerailed ); static bool SetTrainDerailed ( lua_State* pLuaVM, PVOID pUserData, bool bDerailed );
static bool SetTrainDerailable ( lua_State* pLuaVM, void* pUserData, bool bDerailable ); static bool SetTrainDerailable ( lua_State* pLuaVM, PVOID pUserData, bool bDerailable );
static bool SetTrainDirection ( lua_State* pLuaVM, void* pUserData, bool bDireciton ); static bool SetTrainDirection ( lua_State* pLuaVM, PVOID pUserData, bool bDireciton );
static bool SetTrainSpeed ( lua_State* pLuaVM, void* pUserData, float fSpeed ); static bool SetTrainSpeed ( lua_State* pLuaVM, PVOID pUserData, float fSpeed );
static bool SetVehicleHeadLightColor ( lua_State* pLuaVM, void* pUserData, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue ); static bool SetVehicleHeadLightColor ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue );
static bool SetVehicleTurretPosition ( lua_State* pLuaVM, void* pUserData, float fHorizontal, float fVertical ); static bool SetVehicleTurretPosition ( lua_State* pLuaVM, PVOID pUserData, float fHorizontal, float fVertical );
static bool SetVehicleDoorOpenRatio ( lua_State* pLuaVM, void* pUserData, unsigned char ucDoor, float fRatio, unsigned long ulTime = 0 ); static bool SetVehicleDoorOpenRatio ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucDoor, float fRatio, unsigned long ulTime = 0 );
static bool SetVehicleVariant ( lua_State* pLuaVM, void* pUserData, unsigned char ucVariant, unsigned char ucVariant2 ); static bool SetVehicleVariant ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucVariant, unsigned char ucVariant2 );
static bool GiveVehicleSirens ( lua_State* pLuaVM, void* pUserData, unsigned char ucSirenType, unsigned char ucSirenCount, bool bFlag360 = false, bool bCheckLosFlag = true, bool bUseRandomiserFlag = true, bool bSilentFlag = false ); static bool GiveVehicleSirens ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucSirenType, unsigned char ucSirenCount, bool bFlag360 = false, bool bCheckLosFlag = true, bool bUseRandomiserFlag = true, bool bSilentFlag = false );
static bool RemoveVehicleSirens ( lua_State* pLuaVM, void* pUserData ); static bool RemoveVehicleSirens ( lua_State* pLuaVM, PVOID pUserData );
static bool SetVehicleSirens ( lua_State* pLuaVM, void* pUserData, unsigned char ucSirenID, float fX, float fY, float fZ, float fRed, float fGreen, float fBlue, float fAlpha = 255, float fMinAlpha = 0.0 ); static bool SetVehicleSirens ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucSirenID, float fX, float fY, float fZ, float fRed, float fGreen, float fBlue, float fAlpha = 255, float fMinAlpha = 0.0 );
// static bool GetVehicleSirens ( lua_State* pLuaVM, void* pUserData ); // static bool GetVehicleSirens ( lua_State* pLuaVM, PVOID pUserData );
// static bool GetVehicleSirenParams ( lua_State* pLuaVM, void* pUserData ); // static bool GetVehicleSirenParams ( lua_State* pLuaVM, PVOID pUserData );
static bool SetVehiclePlateText ( lua_State* pLuaVM, void* pUserData, const char* szName ); static bool SetVehiclePlateText ( lua_State* pLuaVM, PVOID pUserData, const char* szName );
// Marker create/destroy functions // Marker create/destroy functions
static void* CreateMarker ( lua_State* pLuaVM, const Vector3& vecPosition, const char* szType, float fSize, const SColor color, void* pVisibleTo ); static PVOID CreateMarker ( lua_State* pLuaVM, const Vector3& vecPosition, const char* szType, float fSize, const SColor color, PVOID pVisibleTo );
// Marker get functions // Marker get functions
static bool GetMarkerCount ( lua_State* pLuaVM, unsigned int& uiCount ); static bool GetMarkerCount ( lua_State* pLuaVM, unsigned int& uiCount );
static bool GetMarkerType ( lua_State* pLuaVM, void* pUserData, char* szType ); static bool GetMarkerType ( lua_State* pLuaVM, PVOID pUserData, char* szType );
static bool GetMarkerSize ( lua_State* pLuaVM, void* pUserData, float& fSize ); static bool GetMarkerSize ( lua_State* pLuaVM, PVOID pUserData, float& fSize );
static bool GetMarkerColor ( lua_State* pLuaVM, void* pUserData, SColor& outColor ); static bool GetMarkerColor ( lua_State* pLuaVM, PVOID pUserData, SColor& outColor );
static bool GetMarkerTarget ( lua_State* pLuaVM, void* pUserData, Vector3& vecTarget ); static bool GetMarkerTarget ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecTarget );
static bool GetMarkerIcon ( lua_State* pLuaVM, void* pUserData, char* szIcon ); static bool GetMarkerIcon ( lua_State* pLuaVM, PVOID pUserData, char* szIcon );
// Marker set functions // Marker set functions
static bool SetMarkerType ( lua_State* pLuaVM, void* pUserData, const char* szType ); static bool SetMarkerType ( lua_State* pLuaVM, PVOID pUserData, const char* szType );
static bool SetMarkerSize ( lua_State* pLuaVM, void* pUserData, float fSize ); static bool SetMarkerSize ( lua_State* pLuaVM, PVOID pUserData, float fSize );
static bool SetMarkerColor ( lua_State* pLuaVM, void* pUserData, const SColor color ); static bool SetMarkerColor ( lua_State* pLuaVM, PVOID pUserData, const SColor color );
static bool SetMarkerTarget ( lua_State* pLuaVM, void* pUserData, const Vector3& pTarget ); static bool SetMarkerTarget ( lua_State* pLuaVM, PVOID pUserData, const Vector3& pTarget );
static bool SetMarkerIcon ( lua_State* pLuaVM, void* pUserData, const char* szIcon ); static bool SetMarkerIcon ( lua_State* pLuaVM, PVOID pUserData, const char* szIcon );
// Blip create/destroy functions // Blip create/destroy functions
static void* CreateBlip ( lua_State* pLuaVM, const Vector3& vecPosition, unsigned char ucIcon, unsigned char ucSize, const SColor color, short sOrdering, unsigned short usVisibleDistance, void* pVisibleTo = NULL ); static PVOID CreateBlip ( lua_State* pLuaVM, const Vector3& vecPosition, unsigned char ucIcon, unsigned char ucSize, const SColor color, short sOrdering, unsigned short usVisibleDistance, PVOID pVisibleTo = NULL );
static void* CreateBlipAttachedTo ( lua_State* pLuaVM, void* pTarget, unsigned char ucIcon, unsigned char ucSize, const SColor color, short sOrdering, unsigned short usVisibleDistance, void* pVisibleTo = NULL ); static PVOID CreateBlipAttachedTo ( lua_State* pLuaVM, PVOID pTarget, unsigned char ucIcon, unsigned char ucSize, const SColor color, short sOrdering, unsigned short usVisibleDistance, PVOID pVisibleTo = NULL );
// Blip get functions // Blip get functions
static bool GetBlipIcon ( lua_State* pLuaVM, void* pUserData, unsigned char& ucIcon ); static bool GetBlipIcon ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucIcon );
static bool GetBlipSize ( lua_State* pLuaVM, void* pUserData, unsigned char& ucSize ); static bool GetBlipSize ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucSize );
static bool GetBlipColor ( lua_State* pLuaVM, void* pUserData, SColor& outColor ); static bool GetBlipColor ( lua_State* pLuaVM, PVOID pUserData, SColor& outColor );
static bool GetBlipOrdering ( lua_State* pLuaVM, void* pUserData, short& sOrdering ); static bool GetBlipOrdering ( lua_State* pLuaVM, PVOID pUserData, short& sOrdering );
static bool GetBlipVisibleDistance ( lua_State* pLuaVM, void* pUserData, unsigned short& usVisibleDistance ); static bool GetBlipVisibleDistance ( lua_State* pLuaVM, PVOID pUserData, unsigned short& usVisibleDistance );
// Blip set functions // Blip set functions
static bool SetBlipIcon ( lua_State* pLuaVM, void* pUserData, unsigned char ucIcon ); static bool SetBlipIcon ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucIcon );
static bool SetBlipSize ( lua_State* pLuaVM, void* pUserData, unsigned char ucSize ); static bool SetBlipSize ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucSize );
static bool SetBlipColor ( lua_State* pLuaVM, void* pUserData, const SColor color ); static bool SetBlipColor ( lua_State* pLuaVM, PVOID pUserData, const SColor color );
static bool SetBlipOrdering ( lua_State* pLuaVM, void* pUserData, short sOrdering ); static bool SetBlipOrdering ( lua_State* pLuaVM, PVOID pUserData, short sOrdering );
static bool SetBlipVisibleDistance ( lua_State* pLuaVM, void* pUserData, unsigned short usVisibleDistance ); static bool SetBlipVisibleDistance ( lua_State* pLuaVM, PVOID pUserData, unsigned short usVisibleDistance );
// Object create/destroy functions // Object create/destroy functions
static void* CreateObject ( lua_State* pLuaVM, unsigned short usModelID, const Vector3& vecPosition, const Vector3& vecRotation, bool bIsLowLod ); static PVOID CreateObject ( lua_State* pLuaVM, unsigned short usModelID, const Vector3& vecPosition, const Vector3& vecRotation, bool bIsLowLod );
// Object get functions // Object get functions
static bool GetObjectScale ( lua_State* pLuaVM, void* pUserData, Vector3& vecScale ); static bool GetObjectScale ( lua_State* pLuaVM, PVOID pUserData, Vector3& vecScale );
// Object set functions // Object set functions
static bool SetObjectScale ( lua_State* pLuaVM, void* pUserData, const Vector3& vecScale ); static bool SetObjectScale ( lua_State* pLuaVM, PVOID pUserData, const Vector3& vecScale );
static bool MoveObject ( lua_State* pLuaVM, void* pUserData, unsigned long ulTime, const Vector3& vecPosition, const Vector3& vecRotation, const char* szEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot ); static bool MoveObject ( lua_State* pLuaVM, PVOID pUserData, unsigned long ulTime, const Vector3& vecPosition, const Vector3& vecRotation, const char* szEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot );
static bool StopObject ( lua_State* pLuaVM, void* pUserData ); static bool StopObject ( lua_State* pLuaVM, PVOID pUserData );
// Radar area create/destroy funcs // Radar area create/destroy funcs
static void* CreateRadarArea ( lua_State* pLuaVM, const Vector2& vecPosition, const Vector2& vecSize, const SColor color, void* pVisibleTo = NULL ); static PVOID CreateRadarArea ( lua_State* pLuaVM, const Vector2& vecPosition, const Vector2& vecSize, const SColor color, PVOID pVisibleTo = NULL );
// Radar area get funcs // Radar area get funcs
static bool GetRadarAreaSize ( lua_State* pLuaVM, void* pUserData, Vector2& vecSize ); static bool GetRadarAreaSize ( lua_State* pLuaVM, PVOID pUserData, Vector2& vecSize );
static bool GetRadarAreaColor ( lua_State* pLuaVM, void* pUserData, SColor& outColor ); static bool GetRadarAreaColor ( lua_State* pLuaVM, PVOID pUserData, SColor& outColor );
static bool IsRadarAreaFlashing ( lua_State* pLuaVM, void* pUserData ); static bool IsRadarAreaFlashing ( lua_State* pLuaVM, PVOID pUserData );
static bool IsInsideRadarArea ( lua_State* pLuaVM, void* pUserData, const Vector2& vecPosition, bool& bInside ); static bool IsInsideRadarArea ( lua_State* pLuaVM, PVOID pUserData, const Vector2& vecPosition, bool& bInside );
// Radar area set funcs // Radar area set funcs
static bool SetRadarAreaSize ( lua_State* pLuaVM, void* pUserData, const Vector2& vecSize ); static bool SetRadarAreaSize ( lua_State* pLuaVM, PVOID pUserData, const Vector2& vecSize );
static bool SetRadarAreaColor ( lua_State* pLuaVM, void* pUserData, const SColor color ); static bool SetRadarAreaColor ( lua_State* pLuaVM, PVOID pUserData, const SColor color );
static bool SetRadarAreaFlashing ( lua_State* pLuaVM, void* pUserData, bool bFlashing ); static bool SetRadarAreaFlashing ( lua_State* pLuaVM, PVOID pUserData, bool bFlashing );
// Pickup create/destroy funcs // Pickup create/destroy funcs
static void* CreatePickup ( lua_State* pLuaVM, const Vector3& vecPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval = 30000, double dSix = 50 ); static PVOID CreatePickup ( lua_State* pLuaVM, const Vector3& vecPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval = 30000, double dSix = 50 );
// Pickup get funcs // Pickup get funcs
static bool GetPickupType ( lua_State* pLuaVM, void* pUserData, unsigned char& ucType ); static bool GetPickupType ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucType );
static bool GetPickupWeapon ( lua_State* pLuaVM, void* pUserData, unsigned char& ucWeapon ); static bool GetPickupWeapon ( lua_State* pLuaVM, PVOID pUserData, unsigned char& ucWeapon );
static bool GetPickupAmount ( lua_State* pLuaVM, void* pUserData, float& fAmount ); static bool GetPickupAmount ( lua_State* pLuaVM, PVOID pUserData, float& fAmount );
static bool GetPickupAmmo ( lua_State* pLuaVM, void* pUserData, unsigned short& ucAmmo ); static bool GetPickupAmmo ( lua_State* pLuaVM, PVOID pUserData, unsigned short& ucAmmo );
static bool GetPickupRespawnInterval ( lua_State* pLuaVM, void* pUserData, unsigned long& ulInterval ); static bool GetPickupRespawnInterval ( lua_State* pLuaVM, PVOID pUserData, unsigned long& ulInterval );
static bool IsPickupSpawned ( lua_State* pLuaVM, void* pUserData, bool& bSpawned ); static bool IsPickupSpawned ( lua_State* pLuaVM, PVOID pUserData, bool& bSpawned );
// Pickup set funcs // Pickup set funcs
static bool SetPickupType ( lua_State* pLuaVM, void* pUserData, unsigned char ucType, double dThree, double dFour ); static bool SetPickupType ( lua_State* pLuaVM, PVOID pUserData, unsigned char ucType, double dThree, double dFour );
static bool SetPickupRespawnInterval ( lua_State* pLuaVM, void* pUserData, unsigned long ulInterval ); static bool SetPickupRespawnInterval ( lua_State* pLuaVM, PVOID pUserData, unsigned long ulInterval );
static bool UsePickup ( lua_State* pLuaVM, void* pUserData, void* pPlayer ); static bool UsePickup ( lua_State* pLuaVM, PVOID pUserData, PVOID pPlayer );
// Shape create funcs // Shape create funcs
static void* CreateColCircle ( lua_State* pLuaVM, const Vector2& vecPosition, float fRadius ); static PVOID CreateColCircle ( lua_State* pLuaVM, const Vector2& vecPosition, float fRadius );
static void* CreateColCuboid ( lua_State* pLuaVM, const Vector3& vecPosition, const Vector3& vecSize ); static PVOID CreateColCuboid ( lua_State* pLuaVM, const Vector3& vecPosition, const Vector3& vecSize );
static void* CreateColSphere ( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius ); static PVOID CreateColSphere ( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius );
static void* CreateColRectangle ( lua_State* pLuaVM, const Vector2& vecPosition, const Vector2& vecSize ); static PVOID CreateColRectangle ( lua_State* pLuaVM, const Vector2& vecPosition, const Vector2& vecSize );
static void* CreateColPolygon ( lua_State* pLuaVM, const vector< Vector2 >& vecPointList ); static PVOID CreateColPolygon ( lua_State* pLuaVM, const vector< Vector2 >& vecPointList );
static void* CreateColTube ( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius, float fHeight ); static PVOID CreateColTube ( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius, float fHeight );
// Explosion funcs // Explosion funcs
static bool CreateExplosion ( lua_State* pLuaVM, const Vector3& vecPosition, unsigned char ucType, void* pCreator = NULL ); static bool CreateExplosion ( lua_State* pLuaVM, const Vector3& vecPosition, unsigned char ucType, PVOID pCreator = NULL );
// Fire funcs // Fire funcs
// static int CreateFire ( lua_State* pLuaVM ); // static int CreateFire ( lua_State* pLuaVM );
// Audio funcs // Audio funcs
static bool PlaySoundFrontEnd ( lua_State* pLuaVM, void* pElement, unsigned char ucSound ); static bool PlaySoundFrontEnd ( lua_State* pLuaVM, PVOID pElement, unsigned char ucSound );
static bool PlayMissionAudio ( lua_State* pLuaVM, void* pElement, Vector3& vecPosition, unsigned short usSlot ); static bool PlayMissionAudio ( lua_State* pLuaVM, PVOID pElement, Vector3& vecPosition, unsigned short usSlot );
// Ped body? // Ped body?
static bool GetBodyPartName ( lua_State* pLuaVM, unsigned char ucID, char* szName ); static bool GetBodyPartName ( lua_State* pLuaVM, unsigned char ucID, char* szName );
@ -423,40 +423,40 @@ public:
static bool GetClothesTypeName ( lua_State* pLuaVM, unsigned char ucType, char* szNameReturn ); static bool GetClothesTypeName ( lua_State* pLuaVM, unsigned char ucType, char* szNameReturn );
// Input funcs // Input funcs
// static bool BindKey ( lua_State* pLuaVM, void* pPlayer, const char* szKey, const char* szHitState, const CLuaFunctionRef& iLuaFunction, CLuaArguments& Arguments ); // static bool BindKey ( lua_State* pLuaVM, PVOID pPlayer, const char* szKey, const char* szHitState, const CLuaFunctionRef& iLuaFunction, CLuaArguments& Arguments );
static bool BindKey ( lua_State* pLuaVM, void* pPlayer, const char* szKey, const char* szHitState, const char* szCommandName, const char* szArguments ); static bool BindKey ( lua_State* pLuaVM, PVOID pPlayer, const char* szKey, const char* szHitState, const char* szCommandName, const char* szArguments );
// static bool UnbindKey ( lua_State* pLuaVM, void* pPlayer, const char* szKey, const char* szHitState = NULL, const CLuaFunctionRef& iLuaFunction = CLuaFunctionRef() ); // static bool UnbindKey ( lua_State* pLuaVM, PVOID pPlayer, const char* szKey, const char* szHitState = NULL, const CLuaFunctionRef& iLuaFunction = CLuaFunctionRef() );
static bool UnbindKey ( lua_State* pLuaVM, void* pPlayer, const char* szKey, const char* szHitState, const char* szCommandName ); static bool UnbindKey ( lua_State* pLuaVM, PVOID pPlayer, const char* szKey, const char* szHitState, const char* szCommandName );
// static bool IsKeyBound ( lua_State* pLuaVM, void* pPlayer, const char* szKey, const char* szHitState, const CLuaFunctionRef& iLuaFunction, bool& bBound ); // static bool IsKeyBound ( lua_State* pLuaVM, PVOID pPlayer, const char* szKey, const char* szHitState, const CLuaFunctionRef& iLuaFunction, bool& bBound );
static bool GetControlState ( lua_State* pLuaVM, void* pPlayer, const char* szControl, bool& bState ); static bool GetControlState ( lua_State* pLuaVM, PVOID pPlayer, const char* szControl, bool& bState );
static bool IsControlEnabled ( lua_State* pLuaVM, void* pPlayer, const char* szControl, bool& bEnabled ); static bool IsControlEnabled ( lua_State* pLuaVM, PVOID pPlayer, const char* szControl, bool& bEnabled );
static bool SetControlState ( lua_State* pLuaVM, void* pPlayer, const char* szControl, bool bState ); static bool SetControlState ( lua_State* pLuaVM, PVOID pPlayer, const char* szControl, bool bState );
static bool ToggleControl ( lua_State* pLuaVM, void* pPlayer, const char* szControl, bool bEnabled ); static bool ToggleControl ( lua_State* pLuaVM, PVOID pPlayer, const char* szControl, bool bEnabled );
static bool ToggleAllControls ( lua_State* pLuaVM, void* pPlayer, bool bGTAControls, bool bMTAControls, bool bEnabled ); static bool ToggleAllControls ( lua_State* pLuaVM, PVOID pPlayer, bool bGTAControls, bool bMTAControls, bool bEnabled );
// Team get funcs // Team get funcs
static void* CreateTeam ( lua_State* pLuaVM, const char* szTeamName, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue ); static PVOID CreateTeam ( lua_State* pLuaVM, const char* szTeamName, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue );
static void* GetTeamFromName ( lua_State* pLuaVM, const char* szTeamName ); static PVOID GetTeamFromName ( lua_State* pLuaVM, const char* szTeamName );
static bool GetTeamName ( lua_State* pLuaVM, void* pTeam, string& strOutName ); static bool GetTeamName ( lua_State* pLuaVM, PVOID pTeam, string& strOutName );
static bool GetTeamColor ( lua_State* pLuaVM, void* pTeam, unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue ); static bool GetTeamColor ( lua_State* pLuaVM, PVOID pTeam, unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue );
static bool CountPlayersInTeam ( lua_State* pLuaVM, void* pTeam, unsigned int& uiCount ); static bool CountPlayersInTeam ( lua_State* pLuaVM, PVOID pTeam, unsigned int& uiCount );
static bool GetTeamFriendlyFire ( lua_State* pLuaVM, void* pTeam, bool& bFriendlyFire ); static bool GetTeamFriendlyFire ( lua_State* pLuaVM, PVOID pTeam, bool& bFriendlyFire );
// Team set funcs // Team set funcs
static bool SetTeamName ( lua_State* pLuaVM, void* pTeam, const char* szTeamName ); static bool SetTeamName ( lua_State* pLuaVM, PVOID pTeam, const char* szTeamName );
static bool SetTeamColor ( lua_State* pLuaVM, void* pTeam, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue ); static bool SetTeamColor ( lua_State* pLuaVM, PVOID pTeam, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue );
static bool SetPlayerTeam ( lua_State* pLuaVM, void* pPlayer, void* pTeam ); static bool SetPlayerTeam ( lua_State* pLuaVM, PVOID pPlayer, PVOID pTeam );
static bool SetTeamFriendlyFire ( lua_State* pLuaVM, void* pTeam, bool bFriendlyFire ); static bool SetTeamFriendlyFire ( lua_State* pLuaVM, PVOID pTeam, bool bFriendlyFire );
// Water funcs // Water funcs
static void* CreateWater ( lua_State* pLuaVM, Vector3* pV1, Vector3* pV2, Vector3* pV3, Vector3* pV4, bool bShallow ); static PVOID CreateWater ( lua_State* pLuaVM, Vector3* pV1, Vector3* pV2, Vector3* pV3, Vector3* pV4, bool bShallow );
static bool SetElementWaterLevel ( lua_State* pLuaVM, void* pWater, float fLevel ); static bool SetElementWaterLevel ( lua_State* pLuaVM, PVOID pWater, float fLevel );
static bool SetAllElementWaterLevel ( lua_State* pLuaVM, float fLevel ); static bool SetAllElementWaterLevel ( lua_State* pLuaVM, float fLevel );
static bool SetWorldWaterLevel ( lua_State* pLuaVM, float fLevel, bool bIncludeWorldNonSeaLevel ); static bool SetWorldWaterLevel ( lua_State* pLuaVM, float fLevel, bool bIncludeWorldNonSeaLevel );
static bool ResetWorldWaterLevel ( lua_State* pLuaVM ); static bool ResetWorldWaterLevel ( lua_State* pLuaVM );
static bool GetWaterVertexPosition ( lua_State* pLuaVM, void* pWater, int iVertexIndex, Vector3& vecPosition ); static bool GetWaterVertexPosition ( lua_State* pLuaVM, PVOID pWater, int iVertexIndex, Vector3& vecPosition );
static bool SetWaterVertexPosition ( lua_State* pLuaVM, void* pWater, int iVertexIndex, Vector3& vecPosition ); static bool SetWaterVertexPosition ( lua_State* pLuaVM, PVOID pWater, int iVertexIndex, Vector3& vecPosition );
static bool GetWaterColor ( lua_State* pLuaVM, unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue, unsigned char& ucAlpha ); static bool GetWaterColor ( lua_State* pLuaVM, unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue, unsigned char& ucAlpha );
static bool SetWaterColor ( lua_State* pLuaVM, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, unsigned char ucAlpha ); static bool SetWaterColor ( lua_State* pLuaVM, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, unsigned char ucAlpha );
static bool ResetWaterColor ( lua_State* pLuaVM ); static bool ResetWaterColor ( lua_State* pLuaVM );
@ -464,8 +464,8 @@ public:
// Standard server functions // Standard server functions
static unsigned int GetMaxPlayers ( lua_State* pLuaVM ); static unsigned int GetMaxPlayers ( lua_State* pLuaVM );
static bool SetMaxPlayers ( lua_State* pLuaVM, unsigned int uiMax ); static bool SetMaxPlayers ( lua_State* pLuaVM, unsigned int uiMax );
static bool OutputChatBox ( lua_State* pLuaVM, const char* szText, void* pElement, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, bool bColorCoded ); static bool OutputChatBox ( lua_State* pLuaVM, const char* szText, PVOID pElement, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, bool bColorCoded );
static bool OutputConsole ( lua_State* pLuaVM, const char* szText, void* pElement ); static bool OutputConsole ( lua_State* pLuaVM, const char* szText, PVOID pElement );
static bool SetServerPassword ( lua_State* pLuaVM, const string& strPassword, bool bSave ); static bool SetServerPassword ( lua_State* pLuaVM, const string& strPassword, bool bSave );
// General world get funcs // General world get funcs
@ -537,129 +537,129 @@ public:
static bool RemoveWorldModel ( lua_State* pLuaVM, unsigned short usModel, float fRadius, const Vector3& vecPosition, char cInterior ); static bool RemoveWorldModel ( lua_State* pLuaVM, unsigned short usModel, float fRadius, const Vector3& vecPosition, char cInterior );
static bool RestoreWorldModel ( lua_State* pLuaVM, unsigned short usModel, float fRadius, const Vector3& vecPosition, char cInterior ); static bool RestoreWorldModel ( lua_State* pLuaVM, unsigned short usModel, float fRadius, const Vector3& vecPosition, char cInterior );
static bool RestoreAllWorldModels ( lua_State* pLuaVM ); static bool RestoreAllWorldModels ( lua_State* pLuaVM );
static bool SendSyncIntervals ( lua_State* pLuaVM, void* pPlayer = NULL ); static bool SendSyncIntervals ( lua_State* pLuaVM, PVOID pPlayer = NULL );
static bool SetPedTargetingMarkerEnabled ( lua_State* pLuaVM, bool bEnabled ); static bool SetPedTargetingMarkerEnabled ( lua_State* pLuaVM, bool bEnabled );
static bool IsPedTargetingMarkerEnabled ( lua_State* pLuaVM ); static bool IsPedTargetingMarkerEnabled ( lua_State* pLuaVM );
static bool SetMoonSize ( lua_State* pLuaVM, int iMoonSize ); static bool SetMoonSize ( lua_State* pLuaVM, int iMoonSize );
static bool ResetMoonSize ( lua_State* pLuaVM ); static bool ResetMoonSize ( lua_State* pLuaVM );
// Loaded Map Functions // Loaded Map Functions
static void* GetRootElement ( lua_State* pLuaVM ); static PVOID GetRootElement ( lua_State* pLuaVM );
// static void* LoadMapData ( lua_State* pLuaVM, void* pParent, CXMLNode* pNode ); // static PVOID LoadMapData ( lua_State* pLuaVM, PVOID pParent, CXMLNode* pNode );
// static void* SaveMapData ( lua_State* pLuaVM, void* pElement, CXMLNode* pNode, bool bChildren ); // static PVOID SaveMapData ( lua_State* pLuaVM, PVOID pElement, CXMLNode* pNode, bool bChildren );
// Account get funcs // Account get funcs
static void* GetAccount ( lua_State* pLuaVM, const char* szName, const char* szPassword ); static PVOID GetAccount ( lua_State* pLuaVM, const char* szName, const char* szPassword );
static CLuaArguments* GetAccounts ( lua_State* pLuaVM ); static CLuaArgumentsVector GetAccounts ( lua_State* pLuaVM );
static void* GetAccountPlayer ( lua_State* pLuaVM, void* pAccount ); static PVOID GetAccountPlayer ( lua_State* pLuaVM, PVOID pAccount );
static bool IsGuestAccount ( lua_State* pLuaVM, void* pAccount, bool& bGuest ); static bool IsGuestAccount ( lua_State* pLuaVM, PVOID pAccount, bool& bGuest );
static CLuaArgument* GetAccountData ( lua_State* pLuaVM, void* pAccount, const char* szKey ); static CLuaArgument GetAccountData ( lua_State* pLuaVM, PVOID pAccount, const char* szKey );
static bool GetAllAccountData ( lua_State* pLuaVM, void* pAccount ); static bool GetAllAccountData ( lua_State* pLuaVM, PVOID pAccount );
static bool GetAccountSerial ( lua_State* pLuaVM, void* pAccount, string& strSerial ); static bool GetAccountSerial ( lua_State* pLuaVM, PVOID pAccount, string& strSerial );
static bool GetAccountsBySerial ( lua_State* pLuaVM, const string& strSerial, std::vector<void*>& outAccounts ); static bool GetAccountsBySerial ( lua_State* pLuaVM, const string& strSerial, std::vector<PVOID>& outAccounts );
// Account set funcs // Account set funcs
static void* AddAccount ( lua_State* pLuaVM, const char* szName, const char* szPassword ); static PVOID AddAccount ( lua_State* pLuaVM, const char* szName, const char* szPassword );
static bool RemoveAccount ( lua_State* pLuaVM, void* pAccount ); static bool RemoveAccount ( lua_State* pLuaVM, PVOID pAccount );
static bool SetAccountPassword ( lua_State* pLuaVM, void* pAccount, const char* szPassword ); static bool SetAccountPassword ( lua_State* pLuaVM, PVOID pAccount, const char* szPassword );
static bool SetAccountData ( lua_State* pLuaVM, void* pAccount, const char* szKey, CLuaArgument* pArgument ); static bool SetAccountData ( lua_State* pLuaVM, PVOID pAccount, const char* szKey, CLuaArgument* pArgument );
static bool CopyAccountData ( lua_State* pLuaVM, void* pAccount, void* pFromAccount ); static bool CopyAccountData ( lua_State* pLuaVM, PVOID pAccount, PVOID pFromAccount );
// Log in/out funcs // Log in/out funcs
static bool LogIn ( lua_State* pLuaVM, void* pPlayer, void* pAccount, const char* szPassword ); static bool LogIn ( lua_State* pLuaVM, PVOID pPlayer, PVOID pAccount, const char* szPassword );
static bool LogOut ( lua_State* pLuaVM, void* pPlayer ); static bool LogOut ( lua_State* pLuaVM, PVOID pPlayer );
// Admin funcs // Admin funcs
static bool KickPlayer ( lua_State* pLuaVM, void* pPlayer, string strResponsible = "Console", string strReason = "" ); static bool KickPlayer ( lua_State* pLuaVM, PVOID pPlayer, string strResponsible = "Console", string strReason = "" );
static void* BanPlayer ( lua_State* pLuaVM, void* pPlayer, bool bIP, bool bUsername, bool bSerial, void* pResponsible = NULL, string strResponsible = "Console", string strReason = "", time_t tUnban = 0 ); static PVOID BanPlayer ( lua_State* pLuaVM, PVOID pPlayer, bool bIP, bool bUsername, bool bSerial, PVOID pResponsible = NULL, string strResponsible = "Console", string strReason = "", time_t tUnban = 0 );
static void* AddBan ( lua_State* pLuaVM, string strIP, string strUsername, string strSerial, void* pResponsible = NULL, string strResponsible = "Console", string strReason = "", time_t tUnban = 0 ); static PVOID AddBan ( lua_State* pLuaVM, string strIP, string strUsername, string strSerial, PVOID pResponsible = NULL, string strResponsible = "Console", string strReason = "", time_t tUnban = 0 );
static bool RemoveBan ( lua_State* pLuaVM, void* pBan, void* pResponsible = NULL ); static bool RemoveBan ( lua_State* pLuaVM, PVOID pBan, PVOID pResponsible = NULL );
static bool GetBans ( lua_State* pLuaVM ); static bool GetBans ( lua_State* pLuaVM );
static bool ReloadBanList ( lua_State* pLuaVM ); static bool ReloadBanList ( lua_State* pLuaVM );
static bool GetBanIP ( lua_State* pLuaVM, void* pBan, string& strOutIP ); static bool GetBanIP ( lua_State* pLuaVM, PVOID pBan, string& strOutIP );
static bool GetBanSerial ( lua_State* pLuaVM, void* pBan, string& strOutSerial ); static bool GetBanSerial ( lua_State* pLuaVM, PVOID pBan, string& strOutSerial );
static bool GetBanUsername ( lua_State* pLuaVM, void* pBan, string& strOutUsername ); static bool GetBanUsername ( lua_State* pLuaVM, PVOID pBan, string& strOutUsername );
static bool GetBanNick ( lua_State* pLuaVM, void* pBan, string& strOutNick ); static bool GetBanNick ( lua_State* pLuaVM, PVOID pBan, string& strOutNick );
static bool GetBanReason ( lua_State* pLuaVM, void* pBan, string& strOutReason ); static bool GetBanReason ( lua_State* pLuaVM, PVOID pBan, string& strOutReason );
static bool GetBanAdmin ( lua_State* pLuaVM, void* pBan, string& strOutAdmin ); static bool GetBanAdmin ( lua_State* pLuaVM, PVOID pBan, string& strOutAdmin );
static bool GetBanTime ( lua_State* pLuaVM, void* pBan, time_t& time ); static bool GetBanTime ( lua_State* pLuaVM, PVOID pBan, time_t& time );
static bool GetUnbanTime ( lua_State* pLuaVM, void* pBan, time_t& time ); static bool GetUnbanTime ( lua_State* pLuaVM, PVOID pBan, time_t& time );
static bool SetUnbanTime ( lua_State* pLuaVM, void* pBan, time_t time); static bool SetUnbanTime ( lua_State* pLuaVM, PVOID pBan, time_t time);
static bool SetBanReason ( lua_State* pLuaVM, void* pBan, const string& strReason ); static bool SetBanReason ( lua_State* pLuaVM, PVOID pBan, const string& strReason );
static bool SetBanAdmin ( lua_State* pLuaVM, void* pBan, const string& strAdminName ); static bool SetBanAdmin ( lua_State* pLuaVM, PVOID pBan, const string& strAdminName );
// Cursor get funcs // Cursor get funcs
static bool IsCursorShowing ( lua_State* pLuaVM, void* pPlayer, bool& bShowing ); static bool IsCursorShowing ( lua_State* pLuaVM, PVOID pPlayer, bool& bShowing );
// Cursor set funcs // Cursor set funcs
static bool ShowCursor ( lua_State* pLuaVM, void* pElement, bool bShow, bool bToggleControls ); static bool ShowCursor ( lua_State* pLuaVM, PVOID pElement, bool bShow, bool bToggleControls );
// Chat funcs // Chat funcs
static bool ShowChat ( lua_State* pLuaVM, void* pElement, bool bShow ); static bool ShowChat ( lua_State* pLuaVM, PVOID pElement, bool bShow );
// Misc funcs // Misc funcs
static bool ResetMapInfo ( lua_State* pLuaVM, void* pElement ); static bool ResetMapInfo ( lua_State* pLuaVM, PVOID pElement );
// Resource funcs // Resource funcs
static void* CreateResource ( lua_State* pLuaVM, const char* szResourceName, const char* szOrganizationalDir ); static PVOID CreateResource ( lua_State* pLuaVM, const char* szResourceName, const char* szOrganizationalDir );
static void* CopyResource ( lua_State* pLuaVM, void* pResource, const char* szNewResourceName, const char* szOrganizationalDir ); static PVOID CopyResource ( lua_State* pLuaVM, PVOID pResource, const char* szNewResourceName, const char* szOrganizationalDir );
static void* GetResourceRootElement ( lua_State* pLuaVM, void* pResource = NULL ); static PVOID GetResourceRootElement ( lua_State* pLuaVM, PVOID pResource = NULL );
static void* GetResourceMapRootElement ( lua_State* pLuaVM, void* pResource, const char* szMap ); static PVOID GetResourceMapRootElement ( lua_State* pLuaVM, PVOID pResource, const char* szMap );
static void* GetResourceDynamicElementRoot ( lua_State* pLuaVM, void* pResource ); static PVOID GetResourceDynamicElementRoot ( lua_State* pLuaVM, PVOID pResource );
// static CXMLNode* AddResourceMap ( lua_State* pLuaVM, const string& strFilePath, const std::string& strMapName, int iDimension ); // static CXMLNode* AddResourceMap ( lua_State* pLuaVM, const string& strFilePath, const std::string& strMapName, int iDimension );
// static CXMLNode* AddResourceConfig ( lua_State* pLuaVM, const string& strFilePath, const std::string& strConfigName, int iType ); // static CXMLNode* AddResourceConfig ( lua_State* pLuaVM, const string& strFilePath, const std::string& strConfigName, int iType );
static bool RemoveResourceFile ( lua_State* pLuaVM, void* pResource, const char* szFilename ); static bool RemoveResourceFile ( lua_State* pLuaVM, PVOID pResource, const char* szFilename );
// static CXMLNode AddResourceConfig ( lua_State* pLuaVM, const char* szFilePath, const char* szFileType = "server" ); // static CXMLNode AddResourceConfig ( lua_State* pLuaVM, const char* szFilePath, const char* szFileType = "server" );
// static CXMLNode AddResourceMap ( lua_State* pLuaVM, const char* szFilePath, unsigned int uiDimension = 0 ); // static CXMLNode AddResourceMap ( lua_State* pLuaVM, const char* szFilePath, unsigned int uiDimension = 0 );
// static CXMLNode GetResourceConfig ( lua_State* pLuaVM, const char* szFilePath ); // static CXMLNode GetResourceConfig ( lua_State* pLuaVM, const char* szFilePath );
static CLuaArguments* GetResourceExportedFunctions ( lua_State* pLuaVM, void* pResource ); static CLuaArgumentsVector GetResourceExportedFunctions ( lua_State* pLuaVM, PVOID pResource );
static void* GetResourceFromName ( lua_State* pLuaVM, const char* szResourceName ); static PVOID GetResourceFromName ( lua_State* pLuaVM, const char* szResourceName );
static bool GetResourceInfo ( lua_State* pLuaVM, void* pResource, const char* szAttribute, string& strInfo ); static bool GetResourceInfo ( lua_State* pLuaVM, PVOID pResource, const char* szAttribute, string& strInfo );
static bool GetResourceLastStartTime ( lua_State* pLuaVM, void* pResource, unsigned int& uiTime ); static bool GetResourceLastStartTime ( lua_State* pLuaVM, PVOID pResource, unsigned int& uiTime );
static bool GetResourceLoadFailureReason ( lua_State* pLuaVM, void* pResource, string& strReason ); static bool GetResourceLoadFailureReason ( lua_State* pLuaVM, PVOID pResource, string& strReason );
static bool GetResourceLoadTime ( lua_State* pLuaVM, void* pResource, unsigned int& uiTime ); static bool GetResourceLoadTime ( lua_State* pLuaVM, PVOID pResource, unsigned int& uiTime );
static bool GetResourceName ( lua_State* pLuaVM, void* pResource, string& strName ); static bool GetResourceName ( lua_State* pLuaVM, PVOID pResource, string& strName );
static CLuaArguments* GetResources ( lua_State* pLuaVM ); static CLuaArgumentsVector GetResources ( lua_State* pLuaVM );
static bool GetResourceState ( lua_State* pLuaVM, void* pResource, string& strState ); static bool GetResourceState ( lua_State* pLuaVM, PVOID pResource, string& strState );
static void* GetThisResource ( lua_State* pLuaVM ); static PVOID GetThisResource ( lua_State* pLuaVM );
static bool RefreshResources ( lua_State* pLuaVM, bool refreshAll = false ); static bool RefreshResources ( lua_State* pLuaVM, bool refreshAll = false );
static bool RemoveResourceDefaultSetting ( lua_State* pLuaVM, void* pResource, const char* szSettingName ); static bool RemoveResourceDefaultSetting ( lua_State* pLuaVM, PVOID pResource, const char* szSettingName );
static bool StartResource ( lua_State* pLuaVM, void* pResource, bool persistent = false, bool startIncludedResources = true, bool loadServerConfigs = true, bool loadMaps = true, bool loadServerScripts = true, bool loadHTML = true, bool loadClientConfigs = true, bool loadClientScripts = true, bool loadFiles = true ); static bool StartResource ( lua_State* pLuaVM, PVOID pResource, bool persistent = false, bool startIncludedResources = true, bool loadServerConfigs = true, bool loadMaps = true, bool loadServerScripts = true, bool loadHTML = true, bool loadClientConfigs = true, bool loadClientScripts = true, bool loadFiles = true );
static bool RestartResource ( lua_State* pLuaVM, void* pResource ); static bool RestartResource ( lua_State* pLuaVM, PVOID pResource );
static bool StopResource ( lua_State* pLuaVM, void* pResource ); static bool StopResource ( lua_State* pLuaVM, PVOID pResource );
static bool SetResourceDefaultSetting ( lua_State* pLuaVM, void* pResource, const char* szSettingName, const char* szSettingValue ); static bool SetResourceDefaultSetting ( lua_State* pLuaVM, PVOID pResource, const char* szSettingName, const char* szSettingValue );
static bool SetResourceDefaultSetting ( lua_State* pLuaVM, void* pResource, const char* szSettingName, int iSettingValue ); static bool SetResourceDefaultSetting ( lua_State* pLuaVM, PVOID pResource, const char* szSettingName, int iSettingValue );
static bool SetResourceDefaultSetting ( lua_State* pLuaVM, void* pResource, const char* szSettingName, float fSettingValue ); static bool SetResourceDefaultSetting ( lua_State* pLuaVM, PVOID pResource, const char* szSettingName, float fSettingValue );
static bool SetResourceInfo ( lua_State* pLuaVM, void* pResource, const char* szAttribute, const char* szValue ); static bool SetResourceInfo ( lua_State* pLuaVM, PVOID pResource, const char* szAttribute, const char* szValue );
static bool RenameResource ( lua_State* pLuaVM, const char* szResourceName, const char* szNewResourceName, const char* szOrganizationalPath ); static bool RenameResource ( lua_State* pLuaVM, const char* szResourceName, const char* szNewResourceName, const char* szOrganizationalPath );
static bool DeleteResource ( lua_State* pLuaVM, const char* szResourceName ); static bool DeleteResource ( lua_State* pLuaVM, const char* szResourceName );
// static CLuaArguments* GetResourceACLRequests ( lua_State* pLuaVM, void* pResource ); // static CLuaArguments* GetResourceACLRequests ( lua_State* pLuaVM, PVOID pResource );
static bool UpdateResourceACLRequest ( lua_State* pLuaVM, void* pResource, const char* szRightName, bool bAccess, const char* szByWho = NULL ); static bool UpdateResourceACLRequest ( lua_State* pLuaVM, PVOID pResource, const char* szRightName, bool bAccess, const char* szByWho = NULL );
// Version funcs // Version funcs
static LuaTable GetVersion ( lua_State* pLuaVM ); static CLuaArgumentsMap GetVersion ( lua_State* pLuaVM );
// Camera get functions // Camera get functions
static bool GetCameraMatrix ( lua_State* pLuaVM, void* pPlayer, Vector3& vecPosition, Vector3& vecLookAt, float& fRoll, float& fFOV ); static bool GetCameraMatrix ( lua_State* pLuaVM, PVOID pPlayer, Vector3& vecPosition, Vector3& vecLookAt, float& fRoll, float& fFOV );
static void* GetCameraTarget ( lua_State* pLuaVM, void* pPlayer ); static PVOID GetCameraTarget ( lua_State* pLuaVM, PVOID pPlayer );
static bool GetCameraInterior ( lua_State* pLuaVM, void* pPlayer, unsigned char & ucInterior ); static bool GetCameraInterior ( lua_State* pLuaVM, PVOID pPlayer, unsigned char & ucInterior );
// Camera set functions // Camera set functions
static bool SetCameraMatrix ( lua_State* pLuaVM, void* pPlayer, const Vector3& vecPosition, Vector3& pvecLookAt, float fRoll, float fFOV ); static bool SetCameraMatrix ( lua_State* pLuaVM, PVOID pPlayer, const Vector3& vecPosition, Vector3& pvecLookAt, float fRoll, float fFOV );
static bool SetCameraTarget ( lua_State* pLuaVM, void* pPlayer, void* pTarget ); static bool SetCameraTarget ( lua_State* pLuaVM, PVOID pPlayer, PVOID pTarget );
static bool SetCameraInterior ( lua_State* pLuaVM, void* pPlayer, unsigned char ucInterior ); static bool SetCameraInterior ( lua_State* pLuaVM, PVOID pPlayer, unsigned char ucInterior );
static bool FadeCamera ( lua_State* pLuaVM, void* pPlayer, bool bFadeIn, float fFadeTime, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue ); static bool FadeCamera ( lua_State* pLuaVM, PVOID pPlayer, bool bFadeIn, float fFadeTime, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue );
// Weapon give/take functions // Weapon give/take functions
static bool GiveWeapon ( lua_State* pLuaVM, void* pPed, unsigned char ucWeaponID, unsigned short usAmmo, bool bSetAsCurrent = false ); static bool GiveWeapon ( lua_State* pLuaVM, PVOID pPed, unsigned char ucWeaponID, unsigned short usAmmo, bool bSetAsCurrent = false );
static bool TakeWeapon ( lua_State* pLuaVM, void* pPed, unsigned char ucWeaponID, unsigned short usAmmo = 9999 ); static bool TakeWeapon ( lua_State* pLuaVM, PVOID pPed, unsigned char ucWeaponID, unsigned short usAmmo = 9999 );
static bool TakeAllWeapons ( lua_State* pLuaVM, void* pPed ); static bool TakeAllWeapons ( lua_State* pLuaVM, PVOID pPed );
static bool SetWeaponAmmo ( lua_State* pLuaVM, void* pPed, unsigned char ucWeaponID, unsigned short usAmmo, unsigned short usAmmoInClip ); static bool SetWeaponAmmo ( lua_State* pLuaVM, PVOID pPed, unsigned char ucWeaponID, unsigned short usAmmo, unsigned short usAmmoInClip );
}; };
#endif #endif