From 31a0c201379e5a78ae19f8de65b40029c6d855b0 Mon Sep 17 00:00:00 2001 From: Kernell Date: Sat, 28 Nov 2015 04:41:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D1=91=D0=BD=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D1=8B=20=D1=81=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82?= =?UTF-8?q?=D0=B5=D0=BA=D0=B0=D0=BC=D0=B8.=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mta-mono/src/CMonoFunctions.cpp | 841 +++++----- mta-mono/src/CMonoFunctions_Audio.cpp | 70 +- mta-mono/src/CMonoFunctions_Blip.cpp | 209 ++- mta-mono/src/CMonoFunctions_Element.cpp | 1481 ++++++++--------- mta-mono/src/CMonoFunctions_Explosion.cpp | 48 +- mta-mono/src/CMonoFunctions_Marker.cpp | 266 ++- mta-mono/src/CMonoFunctions_Object.cpp | 144 +- mta-mono/src/CMonoFunctions_Ped.cpp | 298 ++-- mta-mono/src/CMonoFunctions_Pickup.cpp | 190 ++- mta-mono/src/CMonoFunctions_Player.cpp | 1785 ++++++++++----------- mta-mono/src/CMonoFunctions_RadarArea.cpp | 204 +-- mta-mono/src/CMonoFunctions_Shape.cpp | 150 +- mta-mono/src/CMonoFunctions_Team.cpp | 275 ++-- mta-mono/src/CMonoFunctions_Vehicle.cpp | 441 +++-- mta-mono/src/CMonoFunctions_Water.cpp | 190 ++- mta-mono/src/CMonoFunctions_World.cpp | 1236 +++++++------- mta-mono/src/CResource.cpp | 527 +++--- mta-mono/src/CResource.h | 206 +-- 18 files changed, 4118 insertions(+), 4443 deletions(-) diff --git a/mta-mono/src/CMonoFunctions.cpp b/mta-mono/src/CMonoFunctions.cpp index e87a118..21e7624 100644 --- a/mta-mono/src/CMonoFunctions.cpp +++ b/mta-mono/src/CMonoFunctions.cpp @@ -1,189 +1,189 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -void CMonoFunctions::AddInternals( void ) -{ +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +void CMonoFunctions::AddInternals( void ) +{ mono_add_internal_call( "MultiTheftAuto.Debug::Log", CMonoFunctions::Debug::Log ); mono_add_internal_call( "MultiTheftAuto.Debug::Info", CMonoFunctions::Debug::Info ); mono_add_internal_call( "MultiTheftAuto.Debug::Error", CMonoFunctions::Debug::Error ); - MONO_DECLARE( Config, Get ); - MONO_DECLARE( Config, Set ); - - MONO_DECLARE( Server, GetMaxPlayers ); - MONO_DECLARE( Server, SetMaxPlayers ); - MONO_DECLARE( Server, OutputChatBox ); - MONO_DECLARE( Server, OutputConsole ); - MONO_DECLARE( Server, SetPassword ); - MONO_DECLARE( Server, GetVersion ); - - MONO_DECLARE( Server, GetGameType ); - MONO_DECLARE( Server, GetMapName ); - - MONO_DECLARE( Server, SetGameType ); - MONO_DECLARE( Server, SetMapName ); - MONO_DECLARE( Server, GetRuleValue ); - MONO_DECLARE( Server, SetRuleValue ); - MONO_DECLARE( Server, RemoveRuleValue ); - - // Element create/destroy - MONO_DECLARE( Element, Create ); - MONO_DECLARE( Element, Destroy ); - MONO_DECLARE( Element, Clone ); - - // Element get funcs - MONO_DECLARE( Element, GetByType ); - MONO_DECLARE( Element, IsElement ); - MONO_DECLARE( Element, GetType ); - MONO_DECLARE( Element, GetByID ); - MONO_DECLARE( Element, GetByIndex ); - MONO_DECLARE( Element, GetChild ); - MONO_DECLARE( Element, GetChildrenCount ); - MONO_DECLARE( Element, GetID ); - MONO_DECLARE( Element, GetParent ); - MONO_DECLARE( Element, GetPosition ); - MONO_DECLARE( Element, GetRotation ); - MONO_DECLARE( Element, GetVelocity ); - MONO_DECLARE( Element, GetInterior ); - MONO_DECLARE( Element, IsWithinColShape ); - MONO_DECLARE( Element, IsWithinMarker ); - MONO_DECLARE( Element, GetDimension ); - MONO_DECLARE( Element, GetZoneName ); - MONO_DECLARE( Element, IsAttached ); - MONO_DECLARE( Element, GetAttachedTo ); - MONO_DECLARE( Element, GetColShape ); - MONO_DECLARE( Element, GetAlpha ); - MONO_DECLARE( Element, IsDoubleSided ); - MONO_DECLARE( Element, GetHealth ); - MONO_DECLARE( Element, GetModel ); - MONO_DECLARE( Element, IsInWater ); - MONO_DECLARE( Element, GetAttachedOffsetPosition ); - MONO_DECLARE( Element, GetAttachedOffsetRotation ); - MONO_DECLARE( Element, GetSyncer ); - MONO_DECLARE( Element, GetCollisionsEnabled ); - MONO_DECLARE( Element, IsFrozen ); - MONO_DECLARE( Element, GetLowLod ); - MONO_DECLARE( Element, IsLowLod ); - - // Element set funcs - MONO_DECLARE( Element, ClearVisibleTo ); - MONO_DECLARE( Element, SetID ); - MONO_DECLARE( Element, SetData ); - MONO_DECLARE( Element, RemoveData ); - MONO_DECLARE( Element, SetParent ); - MONO_DECLARE( Element, SetPosition ); - MONO_DECLARE( Element, SetRotation ); - MONO_DECLARE( Element, SetVelocity ); - MONO_DECLARE( Element, SetVisibleTo ); - MONO_DECLARE( Element, SetInterior ); - MONO_DECLARE( Element, SetDimension ); - MONO_DECLARE( Element, Attach ); - MONO_DECLARE( Element, Detach ); - MONO_DECLARE( Element, SetAlpha ); - MONO_DECLARE( Element, SetDoubleSided ); - MONO_DECLARE( Element, SetHealth ); - MONO_DECLARE( Element, SetModel ); - MONO_DECLARE( Element, SetAttachedOffsets ); - MONO_DECLARE( Element, SetSyncer ); - MONO_DECLARE( Element, SetCollisionsEnabled ); - MONO_DECLARE( Element, SetFrozen ); - MONO_DECLARE( Element, SetLowLod ); - - // Player get functions - MONO_DECLARE( Player, GetCount ); - MONO_DECLARE( Player, GetFromName ); - MONO_DECLARE( Player, GetPing ); - MONO_DECLARE( Player, GetMoney ); - MONO_DECLARE( Player, GetRandom ); - MONO_DECLARE( Player, IsMuted ); - MONO_DECLARE( Player, GetTeam ); - MONO_DECLARE( Player, GetWantedLevel ); - MONO_DECLARE( Player, GetAlivePlayers ); - MONO_DECLARE( Player, GetDeadPlayers ); - MONO_DECLARE( Player, GetIdleTime ); - MONO_DECLARE( Player, IsMapForced ); - MONO_DECLARE( Player, GetNametagText ); - MONO_DECLARE( Player, GetNametagColor ); - MONO_DECLARE( Player, IsNametagShowing ); - MONO_DECLARE( Player, GetSerial ); - MONO_DECLARE( Player, GetUserName ); - MONO_DECLARE( Player, GetBlurLevel ); - MONO_DECLARE( Player, GetName ); - MONO_DECLARE( Player, GetIP ); - MONO_DECLARE( Player, GetAccount ); - MONO_DECLARE( Player, GetVersion ); - MONO_DECLARE( Player, GetACInfo ); - MONO_DECLARE( Player, GetPlayerAnnounceValue ); - - // Player set functions - MONO_DECLARE( Player, SetMoney ); - MONO_DECLARE( Player, GiveMoney ); - MONO_DECLARE( Player, TakeMoney ); - MONO_DECLARE( Player, Spawn ); - MONO_DECLARE( Player, ShowHudComponent ); - MONO_DECLARE( Player, SetWantedLevel ); - MONO_DECLARE( Player, ForceMap ); - MONO_DECLARE( Player, SetNametagText ); - MONO_DECLARE( Player, SetNametagColor ); - MONO_DECLARE( Player, SetNametagShowing ); - MONO_DECLARE( Player, SetMuted ); - MONO_DECLARE( Player, SetBlurLevel ); - MONO_DECLARE( Player, Redirect ); - MONO_DECLARE( Player, SetName ); - MONO_DECLARE( Player, DetonateSatchels ); - MONO_DECLARE( Player, TakeScreenShot ); - MONO_DECLARE( Player, SetTeam ); - MONO_DECLARE( Player, SetPlayerAnnounceValue ); - - // Input funcs - MONO_DECLARE( Player, BindKey ); - MONO_DECLARE( Player, UnbindKey ); - MONO_DECLARE( Player, GetControlState ); - MONO_DECLARE( Player, IsControlEnabled ); - - MONO_DECLARE( Player, SetControlState ); - MONO_DECLARE( Player, ToggleControl ); - MONO_DECLARE( Player, ToggleAllControls ); - - // Log in/out funcs - MONO_DECLARE( Player, LogIn ); - MONO_DECLARE( Player, LogOut ); - - // Admin funcs - MONO_DECLARE( Player, Kick ); - MONO_DECLARE( Player, Ban ); - - // Cursor get funcs - MONO_DECLARE( Player, IsCursorShowing ); - - // Cursor set funcs - MONO_DECLARE( Player, ShowCursor ); - - // Chat funcs - MONO_DECLARE( Player, ShowChat ); - - // Camera get functions - MONO_DECLARE( Player, GetCameraMatrix ); - MONO_DECLARE( Player, GetCameraTarget ); - MONO_DECLARE( Player, GetCameraInterior ); - - // Camera set functions - MONO_DECLARE( Player, SetCameraMatrix ); - MONO_DECLARE( Player, SetCameraTarget ); - MONO_DECLARE( Player, SetCameraInterior ); - MONO_DECLARE( Player, FadeCamera ); - + MONO_DECLARE( Config, Get ); + MONO_DECLARE( Config, Set ); + + MONO_DECLARE( Server, GetMaxPlayers ); + MONO_DECLARE( Server, SetMaxPlayers ); + MONO_DECLARE( Server, OutputChatBox ); + MONO_DECLARE( Server, OutputConsole ); + MONO_DECLARE( Server, SetPassword ); + MONO_DECLARE( Server, GetVersion ); + + MONO_DECLARE( Server, GetGameType ); + MONO_DECLARE( Server, GetMapName ); + + MONO_DECLARE( Server, SetGameType ); + MONO_DECLARE( Server, SetMapName ); + MONO_DECLARE( Server, GetRuleValue ); + MONO_DECLARE( Server, SetRuleValue ); + MONO_DECLARE( Server, RemoveRuleValue ); + + // Element create/destroy + MONO_DECLARE( Element, Create ); + MONO_DECLARE( Element, Destroy ); + MONO_DECLARE( Element, Clone ); + + // Element get funcs + MONO_DECLARE( Element, GetByType ); + MONO_DECLARE( Element, IsElement ); + MONO_DECLARE( Element, GetType ); + MONO_DECLARE( Element, GetByID ); + MONO_DECLARE( Element, GetByIndex ); + MONO_DECLARE( Element, GetChild ); + MONO_DECLARE( Element, GetChildrenCount ); + MONO_DECLARE( Element, GetID ); + MONO_DECLARE( Element, GetParent ); + MONO_DECLARE( Element, GetPosition ); + MONO_DECLARE( Element, GetRotation ); + MONO_DECLARE( Element, GetVelocity ); + MONO_DECLARE( Element, GetInterior ); + MONO_DECLARE( Element, IsWithinColShape ); + MONO_DECLARE( Element, IsWithinMarker ); + MONO_DECLARE( Element, GetDimension ); + MONO_DECLARE( Element, GetZoneName ); + MONO_DECLARE( Element, IsAttached ); + MONO_DECLARE( Element, GetAttachedTo ); + MONO_DECLARE( Element, GetColShape ); + MONO_DECLARE( Element, GetAlpha ); + MONO_DECLARE( Element, IsDoubleSided ); + MONO_DECLARE( Element, GetHealth ); + MONO_DECLARE( Element, GetModel ); + MONO_DECLARE( Element, IsInWater ); + MONO_DECLARE( Element, GetAttachedOffsetPosition ); + MONO_DECLARE( Element, GetAttachedOffsetRotation ); + MONO_DECLARE( Element, GetSyncer ); + MONO_DECLARE( Element, GetCollisionsEnabled ); + MONO_DECLARE( Element, IsFrozen ); + MONO_DECLARE( Element, GetLowLod ); + MONO_DECLARE( Element, IsLowLod ); + + // Element set funcs + MONO_DECLARE( Element, ClearVisibleTo ); + MONO_DECLARE( Element, SetID ); + MONO_DECLARE( Element, SetData ); + MONO_DECLARE( Element, RemoveData ); + MONO_DECLARE( Element, SetParent ); + MONO_DECLARE( Element, SetPosition ); + MONO_DECLARE( Element, SetRotation ); + MONO_DECLARE( Element, SetVelocity ); + MONO_DECLARE( Element, SetVisibleTo ); + MONO_DECLARE( Element, SetInterior ); + MONO_DECLARE( Element, SetDimension ); + MONO_DECLARE( Element, Attach ); + MONO_DECLARE( Element, Detach ); + MONO_DECLARE( Element, SetAlpha ); + MONO_DECLARE( Element, SetDoubleSided ); + MONO_DECLARE( Element, SetHealth ); + MONO_DECLARE( Element, SetModel ); + MONO_DECLARE( Element, SetAttachedOffsets ); + MONO_DECLARE( Element, SetSyncer ); + MONO_DECLARE( Element, SetCollisionsEnabled ); + MONO_DECLARE( Element, SetFrozen ); + MONO_DECLARE( Element, SetLowLod ); + + // Player get functions + MONO_DECLARE( Player, GetCount ); + MONO_DECLARE( Player, GetFromName ); + MONO_DECLARE( Player, GetPing ); + MONO_DECLARE( Player, GetMoney ); + MONO_DECLARE( Player, GetRandom ); + MONO_DECLARE( Player, IsMuted ); + MONO_DECLARE( Player, GetTeam ); + MONO_DECLARE( Player, GetWantedLevel ); + MONO_DECLARE( Player, GetAlivePlayers ); + MONO_DECLARE( Player, GetDeadPlayers ); + MONO_DECLARE( Player, GetIdleTime ); + MONO_DECLARE( Player, IsMapForced ); + MONO_DECLARE( Player, GetNametagText ); + MONO_DECLARE( Player, GetNametagColor ); + MONO_DECLARE( Player, IsNametagShowing ); + MONO_DECLARE( Player, GetSerial ); + MONO_DECLARE( Player, GetUserName ); + MONO_DECLARE( Player, GetBlurLevel ); + MONO_DECLARE( Player, GetName ); + MONO_DECLARE( Player, GetIP ); + MONO_DECLARE( Player, GetAccount ); + MONO_DECLARE( Player, GetVersion ); + MONO_DECLARE( Player, GetACInfo ); + MONO_DECLARE( Player, GetPlayerAnnounceValue ); + + // Player set functions + MONO_DECLARE( Player, SetMoney ); + MONO_DECLARE( Player, GiveMoney ); + MONO_DECLARE( Player, TakeMoney ); + MONO_DECLARE( Player, Spawn ); + MONO_DECLARE( Player, ShowHudComponent ); + MONO_DECLARE( Player, SetWantedLevel ); + MONO_DECLARE( Player, ForceMap ); + MONO_DECLARE( Player, SetNametagText ); + MONO_DECLARE( Player, SetNametagColor ); + MONO_DECLARE( Player, SetNametagShowing ); + MONO_DECLARE( Player, SetMuted ); + MONO_DECLARE( Player, SetBlurLevel ); + MONO_DECLARE( Player, Redirect ); + MONO_DECLARE( Player, SetName ); + MONO_DECLARE( Player, DetonateSatchels ); + MONO_DECLARE( Player, TakeScreenShot ); + MONO_DECLARE( Player, SetTeam ); + MONO_DECLARE( Player, SetPlayerAnnounceValue ); + + // Input funcs + MONO_DECLARE( Player, BindKey ); + MONO_DECLARE( Player, UnbindKey ); + MONO_DECLARE( Player, GetControlState ); + MONO_DECLARE( Player, IsControlEnabled ); + + MONO_DECLARE( Player, SetControlState ); + MONO_DECLARE( Player, ToggleControl ); + MONO_DECLARE( Player, ToggleAllControls ); + + // Log in/out funcs + MONO_DECLARE( Player, LogIn ); + MONO_DECLARE( Player, LogOut ); + + // Admin funcs + MONO_DECLARE( Player, Kick ); + MONO_DECLARE( Player, Ban ); + + // Cursor get funcs + MONO_DECLARE( Player, IsCursorShowing ); + + // Cursor set funcs + MONO_DECLARE( Player, ShowCursor ); + + // Chat funcs + MONO_DECLARE( Player, ShowChat ); + + // Camera get functions + MONO_DECLARE( Player, GetCameraMatrix ); + MONO_DECLARE( Player, GetCameraTarget ); + MONO_DECLARE( Player, GetCameraInterior ); + + // Camera set functions + MONO_DECLARE( Player, SetCameraMatrix ); + MONO_DECLARE( Player, SetCameraTarget ); + MONO_DECLARE( Player, SetCameraInterior ); + MONO_DECLARE( Player, FadeCamera ); + // Ped get functions MONO_DECLARE( Ped, Create ); MONO_DECLARE( Ped, GetArmor ); @@ -246,8 +246,8 @@ void CMonoFunctions::AddInternals( void ) MONO_DECLARE( Ped, GiveWeapon ); MONO_DECLARE( Ped, TakeWeapon ); MONO_DECLARE( Ped, TakeAllWeapons ); - MONO_DECLARE( Ped, SetWeaponAmmo ); - + MONO_DECLARE( Ped, SetWeaponAmmo ); + // Vehicle create/destroy functions MONO_DECLARE( Vehicle, Create ); @@ -341,8 +341,8 @@ void CMonoFunctions::AddInternals( void ) MONO_DECLARE( Vehicle, SetSirens ); MONO_DECLARE( Vehicle, GetSirens ); MONO_DECLARE( Vehicle, GetSirenParams ); - MONO_DECLARE( Vehicle, SetPlateText ); - + MONO_DECLARE( Vehicle, SetPlateText ); + // Marker create/destroy functions MONO_DECLARE( Marker, Create ); @@ -603,241 +603,234 @@ void CMonoFunctions::AddInternals( void ) MONO_DECLARE( Resource, Rename ); MONO_DECLARE( Resource, Delete ); // MONO_DECLARE( Resource, GetACLRequests ); - MONO_DECLARE( Resource, UpdateACLRequest ); -} - -void CMonoFunctions::Debug::Log( MonoString *string ) -{ - if( RESOURCE ) - { - g_pModuleManager->Printf( "%s\n", mono_string_to_utf8( string ) ); - } -} - -void CMonoFunctions::Debug::Info( MonoString *string ) -{ - if( RESOURCE ) - { - g_pModuleManager->DebugPrintf( RESOURCE->GetLua(), "%s", mono_string_to_utf8( string ) ); - } -} - -void CMonoFunctions::Debug::Error( MonoString *string ) -{ - if( RESOURCE ) - { - - - g_pModuleManager->ErrorPrintf( "%s\n", mono_string_to_utf8( string ) ); - } -} - -MonoString *CMonoFunctions::Config::Get( MonoString *msKey ) -{ - if( RESOURCE ) - { - string sValue = CLuaFunctionDefinitions::Get( RESOURCE->GetLua(), mono_string_to_utf8( msKey ) ); - - return mono_string_new( mono_domain_get(), sValue.c_str() ); - } - - return mono_string_new( mono_domain_get(), "" ); -} - -bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue ) -{ - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - const char* szValue = mono_string_to_utf8( msValue ); - - return CLuaFunctionDefinitions::Set( RESOURCE->GetLua(), szKey, szValue ); - } - - return false; -} - -unsigned int CMonoFunctions::Server::GetMaxPlayers( void ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GetMaxPlayers( RESOURCE->GetLua() ); - } - - return 0; -} - -bool CMonoFunctions::Server::SetMaxPlayers( unsigned int uiMax ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetMaxPlayers( RESOURCE->GetLua(), uiMax ); - } - - return 0; -} - -bool CMonoFunctions::Server::OutputChatBox( MonoString* msText, DWORD pElement, MonoObject* mpColor, bool bColorCoded ) -{ - if( RESOURCE ) - { - const char* szText = mono_string_to_utf8( msText ); - - CMonoObject pColor( mpColor ); - - unsigned char ucRed = pColor.GetPropertyValue< unsigned char >( "R" ); - unsigned char ucGreen = pColor.GetPropertyValue< unsigned char >( "G" ); - unsigned char ucBlue = pColor.GetPropertyValue< unsigned char >( "B" ); - - return CLuaFunctionDefinitions::OutputChatBox( RESOURCE->GetLua(), szText, (void*)pElement, ucRed, ucGreen, ucBlue, bColorCoded ); - } - - return false; -} - -bool CMonoFunctions::Server::OutputConsole( MonoString* msText, DWORD pElement ) -{ - if( RESOURCE ) - { - const char* szText = mono_string_to_utf8( msText ); - - return CLuaFunctionDefinitions::OutputConsole( RESOURCE->GetLua(), szText, (void*)pElement ); - } - - return false; -} - -bool CMonoFunctions::Server::SetPassword( MonoString* msPassword, bool bSave ) -{ - if( RESOURCE ) - { - const char* szPassword = mono_string_to_utf8( msPassword ); - - return CLuaFunctionDefinitions::SetServerPassword( RESOURCE->GetLua(), szPassword, bSave ); - } - - return false; -} - -MonoObject* CMonoFunctions::Server::GetVersion( void ) -{ - if( RESOURCE ) - { - LuaTable pLuaTable = CLuaFunctionDefinitions::GetVersion( RESOURCE->GetLua() ); - - if( !pLuaTable.empty() ) - { - unsigned long ulNumber = pLuaTable[ "number" ]->GetNumber< unsigned long >(); - const char* szString = pLuaTable[ "mta" ]->GetString(); - const char* szName = pLuaTable[ "name" ]->GetString(); - const char* szBuildType = pLuaTable[ "type" ]->GetString(); - unsigned long ulNetcode = pLuaTable[ "netcode" ]->GetNumber< unsigned long >(); - const char* szOS = pLuaTable[ "os" ]->GetString(); - const char* szBuildTag = pLuaTable[ "tag" ]->GetString(); - const char* szSortable = pLuaTable[ "sortable" ]->GetString(); - - void *args[] = - { - &ulNumber, - &szString, - &szName, - &szBuildType, - &ulNetcode, - &szOS, - &szBuildTag, - &szSortable - }; - - CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "ServerVersion", args, 8 ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -MonoString* CMonoFunctions::Server::GetGameType( void ) -{ - if( RESOURCE ) - { - return RESOURCE->NewString( CLuaFunctionDefinitions::GetGameType( RESOURCE->GetLua() ) ); - } - - return NULL; -} - -MonoString* CMonoFunctions::Server::GetMapName( void ) -{ - if( RESOURCE ) - { - return RESOURCE->NewString( CLuaFunctionDefinitions::GetMapName( RESOURCE->GetLua() ) ); - } - - return NULL; -} - -bool CMonoFunctions::Server::SetGameType( MonoString* msGameType ) -{ - if( RESOURCE ) - { - const char* szGameType = mono_string_to_utf8( msGameType ); - - return CLuaFunctionDefinitions::SetGameType( RESOURCE->GetLua(), szGameType ); - } - - return false; -} - -bool CMonoFunctions::Server::SetMapName( MonoString* msMapName ) -{ - if( RESOURCE ) - { - const char* szMapName = mono_string_to_utf8( msMapName ); - - return CLuaFunctionDefinitions::SetMapName( RESOURCE->GetLua(), szMapName ); - } - - return false; -} - -MonoString* CMonoFunctions::Server::GetRuleValue( MonoString* msKey ) -{ - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - - return RESOURCE->NewString( CLuaFunctionDefinitions::GetRuleValue( RESOURCE->GetLua(), szKey ) ); - } - - return false; -} - -bool CMonoFunctions::Server::SetRuleValue( MonoString* msKey, MonoString* msValue ) -{ - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - const char* szValue = mono_string_to_utf8( msValue ); - - return CLuaFunctionDefinitions::SetRuleValue( RESOURCE->GetLua(), szKey, szValue ); - } - - return false; -} - -bool CMonoFunctions::Server::RemoveRuleValue( MonoString* msKey ) -{ - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - - return CLuaFunctionDefinitions::RemoveRuleValue( RESOURCE->GetLua(), szKey ); - } - - return false; -} - + MONO_DECLARE( Resource, UpdateACLRequest ); +} + +void CMonoFunctions::Debug::Log( MonoString *string ) +{ + if( RESOURCE ) + { + g_pModuleManager->Printf( "%s\n", mono_string_to_utf8( string ) ); + } +} + +void CMonoFunctions::Debug::Info( MonoString *string ) +{ + if( RESOURCE ) + { + g_pModuleManager->DebugPrintf( RESOURCE->GetLua(), "%s", mono_string_to_utf8( string ) ); + } +} + +void CMonoFunctions::Debug::Error( MonoString *string ) +{ + if( RESOURCE ) + { + + + g_pModuleManager->ErrorPrintf( "%s\n", mono_string_to_utf8( string ) ); + } +} + +MonoString *CMonoFunctions::Config::Get( MonoString *msKey ) +{ + if( RESOURCE ) + { + string sValue = CLuaFunctionDefinitions::Get( RESOURCE->GetLua(), mono_string_to_utf8( msKey ) ); + + return mono_string_new( mono_domain_get(), sValue.c_str() ); + } + + return mono_string_new( mono_domain_get(), "" ); +} + +bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue ) +{ + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + const char* szValue = mono_string_to_utf8( msValue ); + + return CLuaFunctionDefinitions::Set( RESOURCE->GetLua(), szKey, szValue ); + } + + return false; +} + +unsigned int CMonoFunctions::Server::GetMaxPlayers( void ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GetMaxPlayers( RESOURCE->GetLua() ); + } + + return 0; +} + +bool CMonoFunctions::Server::SetMaxPlayers( unsigned int uiMax ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetMaxPlayers( RESOURCE->GetLua(), uiMax ); + } + + return 0; +} + +bool CMonoFunctions::Server::OutputChatBox( MonoString* msText, DWORD pElement, MonoObject* mpColor, bool bColorCoded ) +{ + if( RESOURCE ) + { + const char* szText = mono_string_to_utf8( msText ); + + unsigned char ucRed = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "R" ); + unsigned char ucGreen = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "G" ); + unsigned char ucBlue = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "B" ); + + return CLuaFunctionDefinitions::OutputChatBox( RESOURCE->GetLua(), szText, (void*)pElement, ucRed, ucGreen, ucBlue, bColorCoded ); + } + + return false; +} + +bool CMonoFunctions::Server::OutputConsole( MonoString* msText, DWORD pElement ) +{ + if( RESOURCE ) + { + const char* szText = mono_string_to_utf8( msText ); + + return CLuaFunctionDefinitions::OutputConsole( RESOURCE->GetLua(), szText, (void*)pElement ); + } + + return false; +} + +bool CMonoFunctions::Server::SetPassword( MonoString* msPassword, bool bSave ) +{ + if( RESOURCE ) + { + const char* szPassword = mono_string_to_utf8( msPassword ); + + return CLuaFunctionDefinitions::SetServerPassword( RESOURCE->GetLua(), szPassword, bSave ); + } + + return false; +} + +MonoObject* CMonoFunctions::Server::GetVersion( void ) +{ + if( RESOURCE ) + { + LuaTable pLuaTable = CLuaFunctionDefinitions::GetVersion( RESOURCE->GetLua() ); + + if( !pLuaTable.empty() ) + { + unsigned long ulNumber = pLuaTable[ "number" ]->GetNumber< unsigned long >(); + const char* szString = pLuaTable[ "mta" ]->GetString(); + const char* szName = pLuaTable[ "name" ]->GetString(); + const char* szBuildType = pLuaTable[ "type" ]->GetString(); + unsigned long ulNetcode = pLuaTable[ "netcode" ]->GetNumber< unsigned long >(); + const char* szOS = pLuaTable[ "os" ]->GetString(); + const char* szBuildTag = pLuaTable[ "tag" ]->GetString(); + const char* szSortable = pLuaTable[ "sortable" ]->GetString(); + + void *args[] = + { + &ulNumber, + &szString, + &szName, + &szBuildType, + &ulNetcode, + &szOS, + &szBuildTag, + &szSortable + }; + + return RESOURCE->NewObject( "MultiTheftAuto", "ServerVersion", args, 8 ); + } + } + + return NULL; +} + +MonoString* CMonoFunctions::Server::GetGameType( void ) +{ + if( RESOURCE ) + { + return RESOURCE->NewString( CLuaFunctionDefinitions::GetGameType( RESOURCE->GetLua() ) ); + } + + return NULL; +} + +MonoString* CMonoFunctions::Server::GetMapName( void ) +{ + if( RESOURCE ) + { + return RESOURCE->NewString( CLuaFunctionDefinitions::GetMapName( RESOURCE->GetLua() ) ); + } + + return NULL; +} + +bool CMonoFunctions::Server::SetGameType( MonoString* msGameType ) +{ + if( RESOURCE ) + { + const char* szGameType = mono_string_to_utf8( msGameType ); + + return CLuaFunctionDefinitions::SetGameType( RESOURCE->GetLua(), szGameType ); + } + + return false; +} + +bool CMonoFunctions::Server::SetMapName( MonoString* msMapName ) +{ + if( RESOURCE ) + { + const char* szMapName = mono_string_to_utf8( msMapName ); + + return CLuaFunctionDefinitions::SetMapName( RESOURCE->GetLua(), szMapName ); + } + + return false; +} + +MonoString* CMonoFunctions::Server::GetRuleValue( MonoString* msKey ) +{ + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + + return RESOURCE->NewString( CLuaFunctionDefinitions::GetRuleValue( RESOURCE->GetLua(), szKey ) ); + } + + return false; +} + +bool CMonoFunctions::Server::SetRuleValue( MonoString* msKey, MonoString* msValue ) +{ + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + const char* szValue = mono_string_to_utf8( msValue ); + + return CLuaFunctionDefinitions::SetRuleValue( RESOURCE->GetLua(), szKey, szValue ); + } + + return false; +} + +bool CMonoFunctions::Server::RemoveRuleValue( MonoString* msKey ) +{ + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + + return CLuaFunctionDefinitions::RemoveRuleValue( RESOURCE->GetLua(), szKey ); + } + + return false; +} + diff --git a/mta-mono/src/CMonoFunctions_Audio.cpp b/mta-mono/src/CMonoFunctions_Audio.cpp index ea3cd44..f256156 100644 --- a/mta-mono/src/CMonoFunctions_Audio.cpp +++ b/mta-mono/src/CMonoFunctions_Audio.cpp @@ -1,36 +1,34 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Audio funcs -bool CMonoFunctions::Audio::PlayFrontEnd( DWORD pUserData, unsigned char ucSound ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::PlaySoundFrontEnd( RESOURCE->GetLua(), (void*)pUserData, ucSound ); - } - - return false; -} - -bool CMonoFunctions::Audio::PlayMission( DWORD pUserData, MonoObject* pPosition, unsigned short usSlot ) -{ - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - - return CLuaFunctionDefinitions::PlayMissionAudio( RESOURCE->GetLua(), (void*)pUserData, vecPosition, usSlot ); - } - - return false; -} +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Audio funcs +bool CMonoFunctions::Audio::PlayFrontEnd( DWORD pUserData, unsigned char ucSound ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::PlaySoundFrontEnd( RESOURCE->GetLua(), (void*)pUserData, ucSound ); + } + + return false; +} + +bool CMonoFunctions::Audio::PlayMission( DWORD pUserData, MonoObject* pPosition, unsigned short usSlot ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::PlayMissionAudio( RESOURCE->GetLua(), (void*)pUserData, Vector3( pPosition ), usSlot ); + } + + return false; +} diff --git a/mta-mono/src/CMonoFunctions_Blip.cpp b/mta-mono/src/CMonoFunctions_Blip.cpp index 13027c1..0bd18f9 100644 --- a/mta-mono/src/CMonoFunctions_Blip.cpp +++ b/mta-mono/src/CMonoFunctions_Blip.cpp @@ -1,175 +1,168 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Blip create/destroy functions +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Blip create/destroy functions DWORD CMonoFunctions::Blip::Create( MonoObject* pPosition, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo ) { - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - - SColor pColor = CMonoObject( color ).GetColor(); - - return (DWORD)CLuaFunctionDefinitions::CreateBlip( RESOURCE->GetLua(), vecPosition, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + + SColor pColor = CMonoObject::GetColor( color ); + + return (DWORD)CLuaFunctionDefinitions::CreateBlip( RESOURCE->GetLua(), vecPosition, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); + } + return NULL; } - + DWORD CMonoFunctions::Blip::CreateAttachedTo( DWORD pTarget, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo ) { - if( RESOURCE ) - { - SColor pColor = CMonoObject( color ).GetColor(); - - return (DWORD)CLuaFunctionDefinitions::CreateBlipAttachedTo( RESOURCE->GetLua(), (void*)pTarget, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); - } - + if( RESOURCE ) + { + SColor pColor = CMonoObject::GetColor( color ); + + return (DWORD)CLuaFunctionDefinitions::CreateBlipAttachedTo( RESOURCE->GetLua(), (void*)pTarget, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); + } + return NULL; } - - -// Blip get functions + + +// Blip get functions unsigned char CMonoFunctions::Blip::GetIcon( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned char ucIcon; - - if( CLuaFunctionDefinitions::GetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ) ) - { - return ucIcon; - } + if( RESOURCE ) + { + unsigned char ucIcon; + + if( CLuaFunctionDefinitions::GetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ) ) + { + return ucIcon; + } } return 0; } - + unsigned char CMonoFunctions::Blip::GetSize( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned char ucSize; - - if( CLuaFunctionDefinitions::GetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ) ) - { - return ucSize; - } + if( RESOURCE ) + { + unsigned char ucSize; + + if( CLuaFunctionDefinitions::GetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ) ) + { + return ucSize; + } } return 0; } - + MonoObject* CMonoFunctions::Blip::GetColor( DWORD pUserData ) { - if( RESOURCE ) - { - SColor outColor; - - if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( outColor ); - - if( pObject ) - { - return pObject->GetObject(); - } - } + if( RESOURCE ) + { + SColor outColor; + + if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) + { + return RESOURCE->NewObject( outColor ); + } } return NULL; } - + short CMonoFunctions::Blip::GetOrdering( DWORD pUserData ) { - if( RESOURCE ) - { - short sOrdering; - - if( CLuaFunctionDefinitions::GetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ) ) - { - return sOrdering; - } + if( RESOURCE ) + { + short sOrdering; + + if( CLuaFunctionDefinitions::GetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ) ) + { + return sOrdering; + } } return 0; } - + unsigned short CMonoFunctions::Blip::GetVisibleDistance( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned short usVisibleDistance; - - if( CLuaFunctionDefinitions::GetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ) ) - { - return usVisibleDistance; - } + if( RESOURCE ) + { + unsigned short usVisibleDistance; + + if( CLuaFunctionDefinitions::GetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ) ) + { + return usVisibleDistance; + } } return 0; } - - -// Blip set functions + + +// Blip set functions bool CMonoFunctions::Blip::SetIcon( DWORD pUserData, unsigned char ucIcon ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ); } return false; } - + bool CMonoFunctions::Blip::SetSize( DWORD pUserData, unsigned char ucSize ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ); } return false; } - + bool CMonoFunctions::Blip::SetColor( DWORD pUserData, MonoObject* color ) { - if( RESOURCE ) - { - SColor pColor = CMonoObject( color ).GetColor(); - - return CLuaFunctionDefinitions::SetBlipColor( RESOURCE->GetLua(), (void*)pUserData, pColor ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetBlipColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( color ) ); } return false; } - + bool CMonoFunctions::Blip::SetOrdering( DWORD pUserData, short sOrdering ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ); } return false; } - + bool CMonoFunctions::Blip::SetVisibleDistance( DWORD pUserData, unsigned short usVisibleDistance ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ); } return false; diff --git a/mta-mono/src/CMonoFunctions_Element.cpp b/mta-mono/src/CMonoFunctions_Element.cpp index 025bbdf..5435b10 100644 --- a/mta-mono/src/CMonoFunctions_Element.cpp +++ b/mta-mono/src/CMonoFunctions_Element.cpp @@ -1,775 +1,706 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Element create/destroy - -DWORD CMonoFunctions::Element::Create( MonoString* msTypeName, MonoString* msID ) -{ - if( RESOURCE ) - { - const char* szTypeName = mono_string_to_utf8( msTypeName ); - const char* szID = mono_string_to_utf8( msID ); - - return (DWORD)CLuaFunctionDefinitions::CreateElement( RESOURCE->GetLua(), szTypeName, szID ); - } - - return NULL; -} - -bool CMonoFunctions::Element::Destroy( DWORD pUserData ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::DestroyElement( RESOURCE->GetLua(), (void*)pUserData ); - } - - return false; -} - -DWORD CMonoFunctions::Element::Clone( DWORD pUserData, MonoObject* vecPosition, bool bCloneElement ) -{ - if( RESOURCE ) - { - CMonoObject pPosition( vecPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - return (DWORD)CLuaFunctionDefinitions::CloneElement( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ), bCloneElement ); - } - - return false; -} - -// Element get funcs - -MonoArray* CMonoFunctions::Element::GetByType( MonoString* msType, DWORD pStartElement ) -{ - if( RESOURCE ) - { - const char* szType = mono_string_to_utf8( msType ); - - CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetElementsByType( RESOURCE->GetLua(), szType, (void*)pStartElement ); - - return RESOURCE->NewArray( mono_get_uint32_class(), pLuaArguments ); - } - - return NULL; -} - -bool CMonoFunctions::Element::IsElement( DWORD pUserData ) -{ - if( RESOURCE ) - { - return (unsigned int)CLuaFunctionDefinitions::IsElement( RESOURCE->GetLua(), (void*)pUserData ); - } - - return false; -} - -MonoString* CMonoFunctions::Element::GetType( DWORD pUserData ) -{ - if( RESOURCE ) - { - const string strType = CLuaFunctionDefinitions::GetElementType( RESOURCE->GetLua(), (void*)pUserData ); - - return mono_string_new( mono_domain_get(), strType.c_str() ); - } - - return mono_string_new( mono_domain_get(), "" ); -} - -DWORD CMonoFunctions::Element::GetByID( MonoString* msID, unsigned int uiIndex ) -{ - if( RESOURCE ) - { - const char* szID = mono_string_to_utf8( msID ); - - return (DWORD)CLuaFunctionDefinitions::GetElementByID( RESOURCE->GetLua(), szID, uiIndex ); - } - - return NULL; -} - -DWORD CMonoFunctions::Element::GetByIndex( int iIndex ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetElementByIndex( RESOURCE->GetLua(), iIndex ); - } - - return NULL; -} - -DWORD CMonoFunctions::Element::GetChild( DWORD pUserData, int iIndex ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetElementChild( RESOURCE->GetLua(), (void*)pUserData, iIndex ); - } - - return NULL; -} - -int CMonoFunctions::Element::GetChildrenCount( DWORD pUserData ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GetElementChildrenCount( RESOURCE->GetLua(), (void*)pUserData ); - } - - return 0; -} - -MonoString* CMonoFunctions::Element::GetID( DWORD pUserData ) -{ - if( RESOURCE ) - { - const string strID = CLuaFunctionDefinitions::GetElementID( RESOURCE->GetLua(), (void*)pUserData ); - - return mono_string_new( mono_domain_get(), strID.c_str() ); - } - - return mono_string_new( mono_domain_get(), "" ); -} - -unsigned int CMonoFunctions::Element::GetParent( DWORD pUserData ) -{ - if( RESOURCE ) - { - return (unsigned int)CLuaFunctionDefinitions::GetElementParent( RESOURCE->GetLua(), (void*)pUserData ); - } - - return NULL; -} - -MonoObject* CMonoFunctions::Element::GetPosition( DWORD pUserData ) -{ - if( RESOURCE ) - { - Vector3 vecPosition; - - if( CLuaFunctionDefinitions::GetElementPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -MonoObject* CMonoFunctions::Element::GetRotation( DWORD pUserData ) -{ - if( RESOURCE ) - { - Vector3 vecPosition; - - if( CLuaFunctionDefinitions::GetElementRotation( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -MonoObject* CMonoFunctions::Element::GetVelocity( DWORD pUserData ) -{ - if( RESOURCE ) - { - Vector3 vecPosition; - - if( CLuaFunctionDefinitions::GetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -unsigned char CMonoFunctions::Element::GetInterior( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned char ucInterior; - - if( CLuaFunctionDefinitions::GetElementInterior( RESOURCE->GetLua(), (void*)pUserData, ucInterior ) ) - { - return ucInterior; - } - } - - return 0; -} - -bool CMonoFunctions::Element::IsWithinColShape( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bWithin; - - if( CLuaFunctionDefinitions::IsElementWithinColShape( RESOURCE->GetLua(), (void*)pUserData, bWithin ) ) - { - return bWithin; - } - } - - return false; -} - -bool CMonoFunctions::Element::IsWithinMarker( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bWithin; - - if( CLuaFunctionDefinitions::IsElementWithinMarker( RESOURCE->GetLua(), (void*)pUserData, bWithin ) ) - { - return bWithin; - } - } - - return false; -} - -unsigned short CMonoFunctions::Element::GetDimension( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned short usDimension; - - if( CLuaFunctionDefinitions::GetElementDimension( RESOURCE->GetLua(), (void*)pUserData, usDimension ) ) - { - return usDimension; - } - } - - return 0; -} - -MonoString* CMonoFunctions::Element::GetZoneName( DWORD pUserData, bool bCitiesOnly ) -{ - if( RESOURCE ) - { - string strOutName; - - if( CLuaFunctionDefinitions::GetElementZoneName( RESOURCE->GetLua(), (void*)pUserData, strOutName, bCitiesOnly ) ) - { - return RESOURCE->NewString( strOutName ); - } - } - - return NULL; -} - -bool CMonoFunctions::Element::IsAttached( DWORD pUserData ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::IsElementAttached( RESOURCE->GetLua(), (void*)pUserData ); - } - - return false; -} - -DWORD CMonoFunctions::Element::GetAttachedTo( DWORD pUserData ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetElementAttachedTo( RESOURCE->GetLua(), (void*)pUserData ); - } - - return NULL; -} - -DWORD CMonoFunctions::Element::GetColShape( DWORD pUserData ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetElementColShape( RESOURCE->GetLua(), (void*)pUserData ); - } - - return NULL; -} - -unsigned char CMonoFunctions::Element::GetAlpha( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned char ucAlpha; - - if( CLuaFunctionDefinitions::GetElementAlpha( RESOURCE->GetLua(), (void*)pUserData, ucAlpha ) ) - { - return ucAlpha; - } - } - - return 0; -} - -bool CMonoFunctions::Element::IsDoubleSided( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bDoubleSided; - - if( CLuaFunctionDefinitions::IsElementDoubleSided( RESOURCE->GetLua(), (void*)pUserData, bDoubleSided ) ) - { - return bDoubleSided; - } - } - - return false; -} - -float CMonoFunctions::Element::GetHealth( DWORD pUserData ) -{ - if( RESOURCE ) - { - float fHealth; - - if( CLuaFunctionDefinitions::GetElementHealth( RESOURCE->GetLua(), (void*)pUserData, fHealth ) ) - { - return fHealth; - } - } - - return false; -} - -unsigned short CMonoFunctions::Element::GetModel( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned short usModel; - - if( CLuaFunctionDefinitions::GetElementModel( RESOURCE->GetLua(), (void*)pUserData, usModel ) ) - { - return usModel; - } - } - - return false; -} - -bool CMonoFunctions::Element::IsInWater( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bInWater; - - if( CLuaFunctionDefinitions::IsElementInWater( RESOURCE->GetLua(), (void*)pUserData, bInWater ) ) - { - return bInWater; - } - } - - return false; -} - -MonoObject* CMonoFunctions::Element::GetAttachedOffsetPosition( DWORD pUserData ) -{ - if( RESOURCE ) - { - Vector3 vecPosition, vecRotation; - - if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -MonoObject* CMonoFunctions::Element::GetAttachedOffsetRotation( DWORD pUserData ) -{ - if( RESOURCE ) - { - Vector3 vecPosition, vecRotation; - - if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecRotation ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -DWORD CMonoFunctions::Element::GetSyncer( DWORD pUserData ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetElementSyncer( RESOURCE->GetLua(), (void*)pUserData ); - } - - return NULL; -} - -bool CMonoFunctions::Element::GetCollisionsEnabled( DWORD pUserData ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GetElementCollisionsEnabled( RESOURCE->GetLua(), (void*)pUserData ); - } - - return false; -} - -bool CMonoFunctions::Element::IsFrozen( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bFrozen; - - if( CLuaFunctionDefinitions::IsElementFrozen( RESOURCE->GetLua(), (void*)pUserData, bFrozen ) ) - { - return bFrozen; - } - } - - return false; -} - -DWORD CMonoFunctions::Element::GetLowLod( DWORD pUserData ) -{ - if( RESOURCE ) - { - void* pUserData; - - if( CLuaFunctionDefinitions::GetLowLodElement( RESOURCE->GetLua(), (void*)pUserData, pUserData ) ) - { - return (DWORD)pUserData; - } - } - - return NULL; -} - -bool CMonoFunctions::Element::IsLowLod( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bIsLowLod; - - if( CLuaFunctionDefinitions::IsElementLowLod( RESOURCE->GetLua(), (void*)pUserData, bIsLowLod ) ) - { - return bIsLowLod; - } - } - - return false; -} - -// Element set funcs - -bool CMonoFunctions::Element::ClearVisibleTo( DWORD pUserData ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ClearElementVisibleTo( RESOURCE->GetLua(), (void*)pUserData ); - } - - return false; -} - -bool CMonoFunctions::Element::SetID( DWORD pUserData, MonoString* msID ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementID( RESOURCE->GetLua(), (void*)pUserData, string( mono_string_to_utf8( msID ) ) ); - } - - return false; -} - -bool CMonoFunctions::Element::SetData( DWORD pUserData, MonoString* msKey, CLuaArgument& Variable ) -{ - if( RESOURCE ) - { - string strKey( mono_string_to_utf8( msKey ) ); - - return CLuaFunctionDefinitions::SetElementData( RESOURCE->GetLua(), (void*)pUserData, strKey, Variable ); - } - - return false; -} - -bool CMonoFunctions::Element::RemoveData( DWORD pUserData, MonoString* msKey ) -{ - if( RESOURCE ) - { - string strKey( mono_string_to_utf8( msKey ) ); - - return CLuaFunctionDefinitions::RemoveElementData( RESOURCE->GetLua(), (void*)pUserData, strKey ); - } - - return false; -} - -bool CMonoFunctions::Element::SetParent( DWORD pUserData, DWORD pTarget ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementParent( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget ); - } - - return false; -} - -bool CMonoFunctions::Element::SetPosition( DWORD pUserData, MonoObject* pPosition, bool bWarp ) -{ - if( RESOURCE ) - { - CMonoObject pPosition( pPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - return CLuaFunctionDefinitions::SetElementPosition( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ), bWarp ); - } - - return false; -} - -bool CMonoFunctions::Element::SetRotation( DWORD pUserData, MonoObject* pRotation, MonoString* msRotationOrder, bool bNewWay ) -{ - if( RESOURCE ) - { - CMonoObject pPosition( pRotation ); - - float fX = pPosition.GetPropertyValue( "X" ); - float fY = pPosition.GetPropertyValue( "Y" ); - float fZ = pPosition.GetPropertyValue( "Z" ); - - const char* szRotationOrder = mono_string_to_utf8( msRotationOrder ); - - return CLuaFunctionDefinitions::SetElementRotation( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ), szRotationOrder, bNewWay ); - } - - return false; -} - -bool CMonoFunctions::Element::SetVelocity( DWORD pUserData, MonoObject* pVelocity ) -{ - if( RESOURCE ) - { - CMonoObject pPosition( pVelocity ); - - float fX = pPosition.GetPropertyValue( "X" ); - float fY = pPosition.GetPropertyValue( "Y" ); - float fZ = pPosition.GetPropertyValue( "Z" ); - - return CLuaFunctionDefinitions::SetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ) ); - } - - return false; -} - -bool CMonoFunctions::Element::SetVisibleTo( DWORD pUserData, DWORD pTarget, bool bVisible ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementVisibleTo( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget, bVisible ); - } - - return false; -} - -bool CMonoFunctions::Element::SetInterior( DWORD pUserData, int iInterior ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementInterior( RESOURCE->GetLua(), (void*)pUserData, iInterior ); - } - - return false; -} - -bool CMonoFunctions::Element::SetDimension( DWORD pUserData, int iDimension ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementDimension( RESOURCE->GetLua(), (void*)pUserData, iDimension ); - } - - return false; -} - -bool CMonoFunctions::Element::Attach( DWORD pUserData, DWORD pTarget, MonoObject* pMonoPosition, MonoObject* pMonoRotation ) -{ - if( RESOURCE ) - { - Vector3 - vecPosition, vecRotation; - - CMonoObject - pPosition( pMonoPosition ), pRotation( pMonoRotation ); - - vecPosition.fX = pPosition.GetPropertyValue( "X" ); - vecPosition.fY = pPosition.GetPropertyValue( "Y" ); - vecPosition.fZ = pPosition.GetPropertyValue( "Z" ); - - vecRotation.fX = pRotation.GetPropertyValue( "X" ); - vecRotation.fY = pRotation.GetPropertyValue( "Y" ); - vecRotation.fZ = pRotation.GetPropertyValue( "Z" ); - - return CLuaFunctionDefinitions::AttachElements( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget, vecPosition, vecRotation ); - } - - return false; -} - -bool CMonoFunctions::Element::Detach( DWORD pUserData, DWORD pTarget ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::DetachElements( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget ); - } - - return false; -} - -bool CMonoFunctions::Element::SetAlpha( DWORD pUserData, int iAlpha ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementAlpha( RESOURCE->GetLua(), (void*)pUserData, iAlpha ); - } - - return false; -} - -bool CMonoFunctions::Element::SetDoubleSided( DWORD pUserData, bool bDoubleSided ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementDoubleSided( RESOURCE->GetLua(), (void*)pUserData, bDoubleSided ); - } - - return false; -} - -bool CMonoFunctions::Element::SetHealth( DWORD pUserData, float fHealth ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementHealth( RESOURCE->GetLua(), (void*)pUserData, fHealth ); - } - - return false; -} - -bool CMonoFunctions::Element::SetModel( DWORD pUserData, int iModel ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementModel( RESOURCE->GetLua(), (void*)pUserData, iModel ); - } - - return false; -} - -bool CMonoFunctions::Element::SetAttachedOffsets( DWORD pUserData, MonoObject* pMonoPosition, MonoObject* pMonoRotation ) -{ - if( RESOURCE ) - { - Vector3 - vecPosition, vecRotation; - - CMonoObject - pPosition( pMonoPosition ), pRotation( pMonoRotation ); - - vecPosition.fX = pPosition.GetPropertyValue( "X" ); - vecPosition.fY = pPosition.GetPropertyValue( "Y" ); - vecPosition.fZ = pPosition.GetPropertyValue( "Z" ); - - vecRotation.fX = pRotation.GetPropertyValue( "X" ); - vecRotation.fY = pRotation.GetPropertyValue( "Y" ); - vecRotation.fZ = pRotation.GetPropertyValue( "Z" ); - - return CLuaFunctionDefinitions::SetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ); - } - - return false; -} - -bool CMonoFunctions::Element::SetSyncer( DWORD pUserData, DWORD pPlayer ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementSyncer( RESOURCE->GetLua(), (void*)pUserData, (void*)pPlayer ); - } - - return false; -} - -bool CMonoFunctions::Element::SetCollisionsEnabled( DWORD pUserData, bool bEnabled ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementCollisionsEnabled( RESOURCE->GetLua(), (void*)pUserData, bEnabled ); - } - - return false; -} - -bool CMonoFunctions::Element::SetFrozen( DWORD pUserData, bool bFrozen ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementFrozen( RESOURCE->GetLua(), (void*)pUserData, bFrozen ); - } - - return false; -} - -bool CMonoFunctions::Element::SetLowLod( DWORD pUserData, bool bEnabled ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetLowLodElement( RESOURCE->GetLua(), (void*)pUserData, bEnabled ); - } - - return false; -} +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Element create/destroy + +DWORD CMonoFunctions::Element::Create( MonoString* msTypeName, MonoString* msID ) +{ + if( RESOURCE ) + { + const char* szTypeName = mono_string_to_utf8( msTypeName ); + const char* szID = mono_string_to_utf8( msID ); + + return (DWORD)CLuaFunctionDefinitions::CreateElement( RESOURCE->GetLua(), szTypeName, szID ); + } + + return NULL; +} + +bool CMonoFunctions::Element::Destroy( DWORD pUserData ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::DestroyElement( RESOURCE->GetLua(), (void*)pUserData ); + } + + return false; +} + +DWORD CMonoFunctions::Element::Clone( DWORD pUserData, MonoObject* vecPosition, bool bCloneElement ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::CloneElement( RESOURCE->GetLua(), (void*)pUserData, Vector3( vecPosition ), bCloneElement ); + } + + return false; +} + +// Element get funcs + +MonoArray* CMonoFunctions::Element::GetByType( MonoString* msType, DWORD pStartElement ) +{ + if( RESOURCE ) + { + const char* szType = mono_string_to_utf8( msType ); + + CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetElementsByType( RESOURCE->GetLua(), szType, (void*)pStartElement ); + + return RESOURCE->NewArray( mono_get_uint32_class(), pLuaArguments ); + } + + return NULL; +} + +bool CMonoFunctions::Element::IsElement( DWORD pUserData ) +{ + if( RESOURCE ) + { + return (unsigned int)CLuaFunctionDefinitions::IsElement( RESOURCE->GetLua(), (void*)pUserData ); + } + + return false; +} + +MonoString* CMonoFunctions::Element::GetType( DWORD pUserData ) +{ + if( RESOURCE ) + { + const string strType = CLuaFunctionDefinitions::GetElementType( RESOURCE->GetLua(), (void*)pUserData ); + + return mono_string_new( mono_domain_get(), strType.c_str() ); + } + + return mono_string_new( mono_domain_get(), "" ); +} + +DWORD CMonoFunctions::Element::GetByID( MonoString* msID, unsigned int uiIndex ) +{ + if( RESOURCE ) + { + const char* szID = mono_string_to_utf8( msID ); + + return (DWORD)CLuaFunctionDefinitions::GetElementByID( RESOURCE->GetLua(), szID, uiIndex ); + } + + return NULL; +} + +DWORD CMonoFunctions::Element::GetByIndex( int iIndex ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetElementByIndex( RESOURCE->GetLua(), iIndex ); + } + + return NULL; +} + +DWORD CMonoFunctions::Element::GetChild( DWORD pUserData, int iIndex ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetElementChild( RESOURCE->GetLua(), (void*)pUserData, iIndex ); + } + + return NULL; +} + +int CMonoFunctions::Element::GetChildrenCount( DWORD pUserData ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GetElementChildrenCount( RESOURCE->GetLua(), (void*)pUserData ); + } + + return 0; +} + +MonoString* CMonoFunctions::Element::GetID( DWORD pUserData ) +{ + if( RESOURCE ) + { + const string strID = CLuaFunctionDefinitions::GetElementID( RESOURCE->GetLua(), (void*)pUserData ); + + return mono_string_new( mono_domain_get(), strID.c_str() ); + } + + return mono_string_new( mono_domain_get(), "" ); +} + +unsigned int CMonoFunctions::Element::GetParent( DWORD pUserData ) +{ + if( RESOURCE ) + { + return (unsigned int)CLuaFunctionDefinitions::GetElementParent( RESOURCE->GetLua(), (void*)pUserData ); + } + + return NULL; +} + +MonoObject* CMonoFunctions::Element::GetPosition( DWORD pUserData ) +{ + if( RESOURCE ) + { + Vector3 vecPosition; + + if( CLuaFunctionDefinitions::GetElementPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) + { + return RESOURCE->NewObject( vecPosition ); + } + } + + return NULL; +} + +MonoObject* CMonoFunctions::Element::GetRotation( DWORD pUserData ) +{ + if( RESOURCE ) + { + Vector3 vecPosition; + + if( CLuaFunctionDefinitions::GetElementRotation( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) + { + return RESOURCE->NewObject( vecPosition ); + } + } + + return NULL; +} + +MonoObject* CMonoFunctions::Element::GetVelocity( DWORD pUserData ) +{ + if( RESOURCE ) + { + Vector3 vecPosition; + + if( CLuaFunctionDefinitions::GetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) + { + return RESOURCE->NewObject( vecPosition ); + } + } + + return NULL; +} + +unsigned char CMonoFunctions::Element::GetInterior( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned char ucInterior; + + if( CLuaFunctionDefinitions::GetElementInterior( RESOURCE->GetLua(), (void*)pUserData, ucInterior ) ) + { + return ucInterior; + } + } + + return 0; +} + +bool CMonoFunctions::Element::IsWithinColShape( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bWithin; + + if( CLuaFunctionDefinitions::IsElementWithinColShape( RESOURCE->GetLua(), (void*)pUserData, bWithin ) ) + { + return bWithin; + } + } + + return false; +} + +bool CMonoFunctions::Element::IsWithinMarker( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bWithin; + + if( CLuaFunctionDefinitions::IsElementWithinMarker( RESOURCE->GetLua(), (void*)pUserData, bWithin ) ) + { + return bWithin; + } + } + + return false; +} + +unsigned short CMonoFunctions::Element::GetDimension( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned short usDimension; + + if( CLuaFunctionDefinitions::GetElementDimension( RESOURCE->GetLua(), (void*)pUserData, usDimension ) ) + { + return usDimension; + } + } + + return 0; +} + +MonoString* CMonoFunctions::Element::GetZoneName( DWORD pUserData, bool bCitiesOnly ) +{ + if( RESOURCE ) + { + string strOutName; + + if( CLuaFunctionDefinitions::GetElementZoneName( RESOURCE->GetLua(), (void*)pUserData, strOutName, bCitiesOnly ) ) + { + return RESOURCE->NewString( strOutName ); + } + } + + return NULL; +} + +bool CMonoFunctions::Element::IsAttached( DWORD pUserData ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::IsElementAttached( RESOURCE->GetLua(), (void*)pUserData ); + } + + return false; +} + +DWORD CMonoFunctions::Element::GetAttachedTo( DWORD pUserData ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetElementAttachedTo( RESOURCE->GetLua(), (void*)pUserData ); + } + + return NULL; +} + +DWORD CMonoFunctions::Element::GetColShape( DWORD pUserData ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetElementColShape( RESOURCE->GetLua(), (void*)pUserData ); + } + + return NULL; +} + +unsigned char CMonoFunctions::Element::GetAlpha( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned char ucAlpha; + + if( CLuaFunctionDefinitions::GetElementAlpha( RESOURCE->GetLua(), (void*)pUserData, ucAlpha ) ) + { + return ucAlpha; + } + } + + return 0; +} + +bool CMonoFunctions::Element::IsDoubleSided( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bDoubleSided; + + if( CLuaFunctionDefinitions::IsElementDoubleSided( RESOURCE->GetLua(), (void*)pUserData, bDoubleSided ) ) + { + return bDoubleSided; + } + } + + return false; +} + +float CMonoFunctions::Element::GetHealth( DWORD pUserData ) +{ + if( RESOURCE ) + { + float fHealth; + + if( CLuaFunctionDefinitions::GetElementHealth( RESOURCE->GetLua(), (void*)pUserData, fHealth ) ) + { + return fHealth; + } + } + + return false; +} + +unsigned short CMonoFunctions::Element::GetModel( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned short usModel; + + if( CLuaFunctionDefinitions::GetElementModel( RESOURCE->GetLua(), (void*)pUserData, usModel ) ) + { + return usModel; + } + } + + return false; +} + +bool CMonoFunctions::Element::IsInWater( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bInWater; + + if( CLuaFunctionDefinitions::IsElementInWater( RESOURCE->GetLua(), (void*)pUserData, bInWater ) ) + { + return bInWater; + } + } + + return false; +} + +MonoObject* CMonoFunctions::Element::GetAttachedOffsetPosition( DWORD pUserData ) +{ + if( RESOURCE ) + { + Vector3 vecPosition, vecRotation; + + if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) ) + { + return RESOURCE->NewObject( vecPosition ); + } + } + + return NULL; +} + +MonoObject* CMonoFunctions::Element::GetAttachedOffsetRotation( DWORD pUserData ) +{ + if( RESOURCE ) + { + Vector3 vecPosition, vecRotation; + + if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) ) + { + return RESOURCE->NewObject( vecRotation ); + } + } + + return NULL; +} + +DWORD CMonoFunctions::Element::GetSyncer( DWORD pUserData ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetElementSyncer( RESOURCE->GetLua(), (void*)pUserData ); + } + + return NULL; +} + +bool CMonoFunctions::Element::GetCollisionsEnabled( DWORD pUserData ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GetElementCollisionsEnabled( RESOURCE->GetLua(), (void*)pUserData ); + } + + return false; +} + +bool CMonoFunctions::Element::IsFrozen( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bFrozen; + + if( CLuaFunctionDefinitions::IsElementFrozen( RESOURCE->GetLua(), (void*)pUserData, bFrozen ) ) + { + return bFrozen; + } + } + + return false; +} + +DWORD CMonoFunctions::Element::GetLowLod( DWORD pUserData ) +{ + if( RESOURCE ) + { + void* pUserData; + + if( CLuaFunctionDefinitions::GetLowLodElement( RESOURCE->GetLua(), (void*)pUserData, pUserData ) ) + { + return (DWORD)pUserData; + } + } + + return NULL; +} + +bool CMonoFunctions::Element::IsLowLod( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bIsLowLod; + + if( CLuaFunctionDefinitions::IsElementLowLod( RESOURCE->GetLua(), (void*)pUserData, bIsLowLod ) ) + { + return bIsLowLod; + } + } + + return false; +} + +// Element set funcs + +bool CMonoFunctions::Element::ClearVisibleTo( DWORD pUserData ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ClearElementVisibleTo( RESOURCE->GetLua(), (void*)pUserData ); + } + + return false; +} + +bool CMonoFunctions::Element::SetID( DWORD pUserData, MonoString* msID ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementID( RESOURCE->GetLua(), (void*)pUserData, string( mono_string_to_utf8( msID ) ) ); + } + + return false; +} + +bool CMonoFunctions::Element::SetData( DWORD pUserData, MonoString* msKey, CLuaArgument& Variable ) +{ + if( RESOURCE ) + { + string strKey( mono_string_to_utf8( msKey ) ); + + return CLuaFunctionDefinitions::SetElementData( RESOURCE->GetLua(), (void*)pUserData, strKey, Variable ); + } + + return false; +} + +bool CMonoFunctions::Element::RemoveData( DWORD pUserData, MonoString* msKey ) +{ + if( RESOURCE ) + { + string strKey( mono_string_to_utf8( msKey ) ); + + return CLuaFunctionDefinitions::RemoveElementData( RESOURCE->GetLua(), (void*)pUserData, strKey ); + } + + return false; +} + +bool CMonoFunctions::Element::SetParent( DWORD pUserData, DWORD pTarget ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementParent( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget ); + } + + return false; +} + +bool CMonoFunctions::Element::SetPosition( DWORD pUserData, MonoObject* pPosition, bool bWarp ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementPosition( RESOURCE->GetLua(), (void*)pUserData, Vector3( pPosition ), bWarp ); + } + + return false; +} + +bool CMonoFunctions::Element::SetRotation( DWORD pUserData, MonoObject* pRotation, MonoString* msRotationOrder, bool bNewWay ) +{ + if( RESOURCE ) + { + const char* szRotationOrder = mono_string_to_utf8( msRotationOrder ); + + return CLuaFunctionDefinitions::SetElementRotation( RESOURCE->GetLua(), (void*)pUserData, Vector3( pRotation ), szRotationOrder, bNewWay ); + } + + return false; +} + +bool CMonoFunctions::Element::SetVelocity( DWORD pUserData, MonoObject* pVelocity ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, Vector3( pVelocity ) ); + } + + return false; +} + +bool CMonoFunctions::Element::SetVisibleTo( DWORD pUserData, DWORD pTarget, bool bVisible ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementVisibleTo( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget, bVisible ); + } + + return false; +} + +bool CMonoFunctions::Element::SetInterior( DWORD pUserData, int iInterior ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementInterior( RESOURCE->GetLua(), (void*)pUserData, iInterior ); + } + + return false; +} + +bool CMonoFunctions::Element::SetDimension( DWORD pUserData, int iDimension ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementDimension( RESOURCE->GetLua(), (void*)pUserData, iDimension ); + } + + return false; +} + +bool CMonoFunctions::Element::Attach( DWORD pUserData, DWORD pTarget, MonoObject* pMonoPosition, MonoObject* pMonoRotation ) +{ + if( RESOURCE ) + { + Vector3 + vecPosition( pMonoPosition ), + vecRotation( pMonoRotation ); + + return CLuaFunctionDefinitions::AttachElements( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget, vecPosition, vecRotation ); + } + + return false; +} + +bool CMonoFunctions::Element::Detach( DWORD pUserData, DWORD pTarget ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::DetachElements( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget ); + } + + return false; +} + +bool CMonoFunctions::Element::SetAlpha( DWORD pUserData, int iAlpha ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementAlpha( RESOURCE->GetLua(), (void*)pUserData, iAlpha ); + } + + return false; +} + +bool CMonoFunctions::Element::SetDoubleSided( DWORD pUserData, bool bDoubleSided ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementDoubleSided( RESOURCE->GetLua(), (void*)pUserData, bDoubleSided ); + } + + return false; +} + +bool CMonoFunctions::Element::SetHealth( DWORD pUserData, float fHealth ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementHealth( RESOURCE->GetLua(), (void*)pUserData, fHealth ); + } + + return false; +} + +bool CMonoFunctions::Element::SetModel( DWORD pUserData, int iModel ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementModel( RESOURCE->GetLua(), (void*)pUserData, iModel ); + } + + return false; +} + +bool CMonoFunctions::Element::SetAttachedOffsets( DWORD pUserData, MonoObject* pMonoPosition, MonoObject* pMonoRotation ) +{ + if( RESOURCE ) + { + Vector3 + vecPosition( pMonoPosition ), + vecRotation( pMonoRotation ); + + return CLuaFunctionDefinitions::SetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ); + } + + return false; +} + +bool CMonoFunctions::Element::SetSyncer( DWORD pUserData, DWORD pPlayer ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementSyncer( RESOURCE->GetLua(), (void*)pUserData, (void*)pPlayer ); + } + + return false; +} + +bool CMonoFunctions::Element::SetCollisionsEnabled( DWORD pUserData, bool bEnabled ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementCollisionsEnabled( RESOURCE->GetLua(), (void*)pUserData, bEnabled ); + } + + return false; +} + +bool CMonoFunctions::Element::SetFrozen( DWORD pUserData, bool bFrozen ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementFrozen( RESOURCE->GetLua(), (void*)pUserData, bFrozen ); + } + + return false; +} + +bool CMonoFunctions::Element::SetLowLod( DWORD pUserData, bool bEnabled ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetLowLodElement( RESOURCE->GetLua(), (void*)pUserData, bEnabled ); + } + + return false; +} diff --git a/mta-mono/src/CMonoFunctions_Explosion.cpp b/mta-mono/src/CMonoFunctions_Explosion.cpp index add3477..5346175 100644 --- a/mta-mono/src/CMonoFunctions_Explosion.cpp +++ b/mta-mono/src/CMonoFunctions_Explosion.cpp @@ -1,26 +1,24 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Explosion funcs -bool CMonoFunctions::Explosion::Create( MonoObject* pPosition, unsigned char ucType, DWORD pCreator ) -{ - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - - return (DWORD)CLuaFunctionDefinitions::CreateExplosion( RESOURCE->GetLua(), vecPosition, ucType, (void*)pCreator ); - } - - return NULL; +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Explosion funcs +bool CMonoFunctions::Explosion::Create( MonoObject* pPosition, unsigned char ucType, DWORD pCreator ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::CreateExplosion( RESOURCE->GetLua(), Vector3( pPosition ), ucType, (void*)pCreator ); + } + + return NULL; } \ No newline at end of file diff --git a/mta-mono/src/CMonoFunctions_Marker.cpp b/mta-mono/src/CMonoFunctions_Marker.cpp index cb02003..a2e40a7 100644 --- a/mta-mono/src/CMonoFunctions_Marker.cpp +++ b/mta-mono/src/CMonoFunctions_Marker.cpp @@ -1,217 +1,173 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Marker create/destroy functions +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Marker create/destroy functions DWORD CMonoFunctions::Marker::Create( MonoObject* pPosition, MonoString* msType, float fSize, MonoObject* pColor, DWORD pVisibleTo ) { - if( RESOURCE ) - { - CMonoObject pPosition( pPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - Vector3 vecPosition( fX, fY, fZ ); - - const char* szType = mono_string_to_utf8( msType ); - - CMonoObject pMonoColor( pColor ); - - SColor pColor; - - pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" ); - pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" ); - pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" ); - pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" ); - - return (DWORD)CLuaFunctionDefinitions::CreateMarker( RESOURCE->GetLua(), vecPosition, szType, fSize, pColor, (void*)pVisibleTo ); - } - - return NULL; -} - - -// Marker get functions -unsigned int CMonoFunctions::Marker::GetCount() -{ - if( RESOURCE ) - { - unsigned int uiCount; - - if( CLuaFunctionDefinitions::GetMarkerCount( RESOURCE->GetLua(), uiCount ) ) - { - return uiCount; - } + if( RESOURCE ) + { + const char* szType = mono_string_to_utf8( msType ); + + return (DWORD)CLuaFunctionDefinitions::CreateMarker( RESOURCE->GetLua(), Vector3( pPosition ), szType, fSize, CMonoObject::GetColor( pColor ), (void*)pVisibleTo ); } - return 0; -} - + return NULL; +} + + +// Marker get functions +unsigned int CMonoFunctions::Marker::GetCount() +{ + if( RESOURCE ) + { + unsigned int uiCount; + + if( CLuaFunctionDefinitions::GetMarkerCount( RESOURCE->GetLua(), uiCount ) ) + { + return uiCount; + } + } + + return 0; +} + MonoString* CMonoFunctions::Marker::GetType( DWORD pUserData ) { - if( RESOURCE ) - { - char* szType = NULL; - - if( CLuaFunctionDefinitions::GetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ) ) - { - return RESOURCE->NewString( szType ); - } + if( RESOURCE ) + { + char* szType = NULL; + + if( CLuaFunctionDefinitions::GetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ) ) + { + return RESOURCE->NewString( szType ); + } } return NULL; } - + float CMonoFunctions::Marker::GetSize( DWORD pUserData ) { - if( RESOURCE ) - { - float fSize; - - if( CLuaFunctionDefinitions::GetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ) ) - { - return fSize; - } + if( RESOURCE ) + { + float fSize; + + if( CLuaFunctionDefinitions::GetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ) ) + { + return fSize; + } } return 0.0f; } - + MonoObject* CMonoFunctions::Marker::GetColor( DWORD pUserData ) { - if( RESOURCE ) - { - SColor outColor; - - if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( outColor ); - - if( pObject ) - { - return pObject->GetObject(); - } - } + if( RESOURCE ) + { + SColor outColor; + + if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) + { + return RESOURCE->NewObject( outColor ); + } } return NULL; } - + MonoObject* CMonoFunctions::Marker::GetTarget( DWORD pUserData ) { - if( RESOURCE ) - { - Vector3 vecPosition; - - if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); - - if( pObject ) - { - return pObject->GetObject(); - } - } + if( RESOURCE ) + { + Vector3 vecPosition; + + if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) + { + return RESOURCE->NewObject( vecPosition ); + } } return NULL; } - + MonoString* CMonoFunctions::Marker::GetIcon( DWORD pUserData ) { - if( RESOURCE ) - { - char* szIcon = NULL; - - if( CLuaFunctionDefinitions::GetMarkerIcon( RESOURCE->GetLua(), (void*)pUserData, szIcon ) ) - { - return RESOURCE->NewString( szIcon ); - } + if( RESOURCE ) + { + char* szIcon = NULL; + + if( CLuaFunctionDefinitions::GetMarkerIcon( RESOURCE->GetLua(), (void*)pUserData, szIcon ) ) + { + return RESOURCE->NewString( szIcon ); + } } return NULL; } - - -// Marker set functions + + +// Marker set functions bool CMonoFunctions::Marker::SetType( DWORD pUserData, MonoString* msType ) { - if( RESOURCE ) - { - const char* szType = mono_string_to_utf8( msType ); - - return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ); + if( RESOURCE ) + { + const char* szType = mono_string_to_utf8( msType ); + + return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ); } return false; } - + bool CMonoFunctions::Marker::SetSize( DWORD pUserData, float fSize ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ); } return false; } - -bool CMonoFunctions::Marker::SetColor( DWORD pUserData, MonoObject* color ) + +bool CMonoFunctions::Marker::SetColor( DWORD pUserData, MonoObject* pColor ) { - if( RESOURCE ) - { - SColor pColor; - - CMonoObject pMonoColor( color ); - - pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" ); - pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" ); - pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" ); - pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" ); - - return CLuaFunctionDefinitions::SetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, pColor ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( pColor ) ); } return false; } - + bool CMonoFunctions::Marker::SetTarget( DWORD pUserData, MonoObject* pTarget ) { - if( RESOURCE ) - { - Vector3* vecPosition = new Vector3; - - CMonoObject pTarget( pTarget ); - - vecPosition->fX = pTarget.GetPropertyValue< float >( "X" ); - vecPosition->fY = pTarget.GetPropertyValue< float >( "Y" ); - vecPosition->fZ = pTarget.GetPropertyValue< float >( "Z" ); - - return CLuaFunctionDefinitions::SetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, Vector3( pTarget ) ); } return false; } - + bool CMonoFunctions::Marker::SetIcon( DWORD pUserData, MonoString* msIcon ) { - if( RESOURCE ) - { - const char* szIcon = mono_string_to_utf8( msIcon ); - - return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szIcon ); + if( RESOURCE ) + { + const char* szIcon = mono_string_to_utf8( msIcon ); + + return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szIcon ); } return false; diff --git a/mta-mono/src/CMonoFunctions_Object.cpp b/mta-mono/src/CMonoFunctions_Object.cpp index cb774da..56ce24e 100644 --- a/mta-mono/src/CMonoFunctions_Object.cpp +++ b/mta-mono/src/CMonoFunctions_Object.cpp @@ -1,117 +1,81 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Object create/destroy functions +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Object create/destroy functions DWORD CMonoFunctions::Object::Create( unsigned short usModelID, MonoObject* pPosition, MonoObject* pRotation, bool bIsLowLod ) { - if( RESOURCE ) - { - CMonoObject pPosition( pPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - Vector3 vecPosition( fX, fY, fZ ); - - CMonoObject pRotation( pRotation ); - - float fRX = pRotation.GetPropertyValue< float >( "X" ); - float fRY = pRotation.GetPropertyValue< float >( "Y" ); - float fRZ = pRotation.GetPropertyValue< float >( "Z" ); - - Vector3 vecRotation( fRX, fRY, fRZ ); - - return (DWORD)CLuaFunctionDefinitions::CreateObject( RESOURCE->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + Vector3 vecRotation( pRotation ); + + return (DWORD)CLuaFunctionDefinitions::CreateObject( RESOURCE->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod ); + } + return NULL; } - - -// Object get functions + + +// Object get functions MonoObject* CMonoFunctions::Object::GetScale( DWORD pUserData ) { - if( RESOURCE ) - { - Vector3 vecScale; - - if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecScale ); - - if( pObject ) - { - return pObject->GetObject(); - } - } + if( RESOURCE ) + { + Vector3 vecScale; + + if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) ) + { + return RESOURCE->NewObject( vecScale ); + } } return NULL; } - - -// Object set functions + + +// Object set functions bool CMonoFunctions::Object::SetScale( DWORD pUserData, MonoObject* pScale ) { - if( RESOURCE ) - { - Vector3 vecScale; - - CMonoObject pScale( pScale ); - - vecScale.fX = pScale.GetPropertyValue< float >( "X" ); - vecScale.fY = pScale.GetPropertyValue< float >( "Y" ); - vecScale.fZ = pScale.GetPropertyValue< float >( "Z" ); - - return CLuaFunctionDefinitions::SetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetObjectScale( RESOURCE->GetLua(), (void*)pUserData, Vector3( pScale ) ); } return false; } - + bool CMonoFunctions::Object::Move( DWORD pUserData, unsigned long ulTime, MonoObject* pPosition, MonoObject* pRotation, MonoString* msEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot ) { - if( RESOURCE ) - { - Vector3 vecPosition, vecRotation; - - CMonoObject pPosition( pPosition ); - - vecPosition.fX = pPosition.GetPropertyValue< float >( "X" ); - vecPosition.fY = pPosition.GetPropertyValue< float >( "Y" ); - vecPosition.fZ = pPosition.GetPropertyValue< float >( "Z" ); - - CMonoObject pRotation( pRotation ); - - vecRotation.fX = pRotation.GetPropertyValue< float >( "X" ); - vecRotation.fY = pRotation.GetPropertyValue< float >( "Y" ); - vecRotation.fZ = pRotation.GetPropertyValue< float >( "Z" ); - - const char* szEasingType = mono_string_to_utf8( msEasingType ); - - return CLuaFunctionDefinitions::MoveObject( RESOURCE->GetLua(), (void*)pUserData, ulTime, vecPosition, vecRotation, szEasingType, fEasingPeriod, fEasingAmplitude, fEasingOvershoot ); + if( RESOURCE ) + { + Vector3 + vecPosition( pPosition ), + vecRotation( pRotation ); + + const char* szEasingType = mono_string_to_utf8( msEasingType ); + + return CLuaFunctionDefinitions::MoveObject( RESOURCE->GetLua(), (void*)pUserData, ulTime, vecPosition, vecRotation, szEasingType, fEasingPeriod, fEasingAmplitude, fEasingOvershoot ); } return false; } - + bool CMonoFunctions::Object::Stop( DWORD pUserData ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::StopObject( RESOURCE->GetLua(), (void*)pUserData ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::StopObject( RESOURCE->GetLua(), (void*)pUserData ); } return false; diff --git a/mta-mono/src/CMonoFunctions_Ped.cpp b/mta-mono/src/CMonoFunctions_Ped.cpp index 3848652..4950ca4 100644 --- a/mta-mono/src/CMonoFunctions_Ped.cpp +++ b/mta-mono/src/CMonoFunctions_Ped.cpp @@ -1,134 +1,128 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#ifndef _CMONO_FUNCS_PED -#define _CMONO_FUNCS_PED - -#include "CMonoFunctions.h" - -// Ped get functions +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#ifndef _CMONO_FUNCS_PED +#define _CMONO_FUNCS_PED + +#include "CMonoFunctions.h" + +// Ped get functions DWORD CMonoFunctions::Ped::Create( int iModelid, MonoObject* pMonoPosition, float fRot, bool bSynced ) { - if( RESOURCE ) - { - CMonoObject pPosition( pMonoPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - Vector3 vecPosition( fX, fY, fZ ); - - return (DWORD)CLuaFunctionDefinitions::CreatePed( RESOURCE->GetLua(), iModelid, vecPosition, fRot, bSynced ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pMonoPosition ); + + return (DWORD)CLuaFunctionDefinitions::CreatePed( RESOURCE->GetLua(), iModelid, vecPosition, fRot, bSynced ); + } + return NULL; } - + float CMonoFunctions::Ped::GetArmor( DWORD pUserData ) { - if( RESOURCE ) - { - float fArmor; - - if( CLuaFunctionDefinitions::GetPedArmor( RESOURCE->GetLua(), (void*)pUserData, fArmor ) ) - { - return fArmor; - } - } - + if( RESOURCE ) + { + float fArmor; + + if( CLuaFunctionDefinitions::GetPedArmor( RESOURCE->GetLua(), (void*)pUserData, fArmor ) ) + { + return fArmor; + } + } + return 0.0f; } - + bool CMonoFunctions::Ped::IsChoking( DWORD pUserData ) { - if( RESOURCE ) - { - bool bChoking; - - if( CLuaFunctionDefinitions::IsPedChoking( RESOURCE->GetLua(), (void*)pUserData, bChoking ) ) - { - return bChoking; - } - } - + if( RESOURCE ) + { + bool bChoking; + + if( CLuaFunctionDefinitions::IsPedChoking( RESOURCE->GetLua(), (void*)pUserData, bChoking ) ) + { + return bChoking; + } + } + return false; } - + bool CMonoFunctions::Ped::IsDead( DWORD pUserData ) { - if( RESOURCE ) - { - bool bDead; - - if( CLuaFunctionDefinitions::IsPedDead( RESOURCE->GetLua(), (void*)pUserData, bDead ) ) - { - return bDead; - } - } - + if( RESOURCE ) + { + bool bDead; + + if( CLuaFunctionDefinitions::IsPedDead( RESOURCE->GetLua(), (void*)pUserData, bDead ) ) + { + return bDead; + } + } + return false; } - + bool CMonoFunctions::Ped::IsDucked( DWORD pUserData ) { - if( RESOURCE ) - { - bool bDucked; - - if( CLuaFunctionDefinitions::IsPedDucked( RESOURCE->GetLua(), (void*)pUserData, bDucked ) ) - { - return bDucked; - } - } - + if( RESOURCE ) + { + bool bDucked; + + if( CLuaFunctionDefinitions::IsPedDucked( RESOURCE->GetLua(), (void*)pUserData, bDucked ) ) + { + return bDucked; + } + } + return false; } - + float CMonoFunctions::Ped::GetStat( DWORD pUserData, unsigned short usStat ) { - if( RESOURCE ) - { - float fStat; - - if( CLuaFunctionDefinitions::GetPedStat( RESOURCE->GetLua(), (void*)pUserData, usStat, fStat ) ) - { - return fStat; - } - } - + if( RESOURCE ) + { + float fStat; + + if( CLuaFunctionDefinitions::GetPedStat( RESOURCE->GetLua(), (void*)pUserData, usStat, fStat ) ) + { + return fStat; + } + } + return 0.0f; } - + DWORD CMonoFunctions::Ped::GetTarget( DWORD pUserData ) { - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetPedTarget( RESOURCE->GetLua(), (void*)pUserData ); - } - + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetPedTarget( RESOURCE->GetLua(), (void*)pUserData ); + } + return NULL; } - + int CMonoFunctions::Ped::GetWeapon( DWORD pUserData, int iWeaponSlot ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GetPedWeapon( RESOURCE->GetLua(), (void*)pUserData, iWeaponSlot ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GetPedWeapon( RESOURCE->GetLua(), (void*)pUserData, iWeaponSlot ); + } + return NULL; } - + MonoString* CMonoFunctions::Ped::GetClothesTexture( DWORD pUserData, unsigned char ucType ) { if( RESOURCE ) @@ -143,7 +137,7 @@ MonoString* CMonoFunctions::Ped::GetClothesTexture( DWORD pUserData, unsigned ch return NULL; } - + MonoString* CMonoFunctions::Ped::GetClothesModel( DWORD pUserData, unsigned char ucType ) { if( RESOURCE ) @@ -158,7 +152,7 @@ MonoString* CMonoFunctions::Ped::GetClothesModel( DWORD pUserData, unsigned char return NULL; } - + bool CMonoFunctions::Ped::DoesHaveJetPack( DWORD pUserData ) { if( RESOURCE ) @@ -173,7 +167,7 @@ bool CMonoFunctions::Ped::DoesHaveJetPack( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::IsOnGround( DWORD pUserData ) { if( RESOURCE ) @@ -188,7 +182,7 @@ bool CMonoFunctions::Ped::IsOnGround( DWORD pUserData ) return false; } - + unsigned char CMonoFunctions::Ped::GetFightingStyle( DWORD pUserData ) { if( RESOURCE ) @@ -203,7 +197,7 @@ unsigned char CMonoFunctions::Ped::GetFightingStyle( DWORD pUserData ) return 0; } - + unsigned int CMonoFunctions::Ped::GetMoveAnim( DWORD pUserData ) { if( RESOURCE ) @@ -218,7 +212,7 @@ unsigned int CMonoFunctions::Ped::GetMoveAnim( DWORD pUserData ) return 0; } - + float CMonoFunctions::Ped::GetGravity( DWORD pUserData ) { if( RESOURCE ) @@ -233,7 +227,7 @@ float CMonoFunctions::Ped::GetGravity( DWORD pUserData ) return 0.0f; } - + DWORD CMonoFunctions::Ped::GetContactElement( DWORD pUserData ) { if( RESOURCE ) @@ -243,7 +237,7 @@ DWORD CMonoFunctions::Ped::GetContactElement( DWORD pUserData ) return NULL; } - + unsigned char CMonoFunctions::Ped::GetWeaponSlot( DWORD pUserData ) { if( RESOURCE ) @@ -258,7 +252,7 @@ unsigned char CMonoFunctions::Ped::GetWeaponSlot( DWORD pUserData ) return 0; } - + bool CMonoFunctions::Ped::IsDoingGangDriveby( DWORD pUserData ) { if( RESOURCE ) @@ -273,7 +267,7 @@ bool CMonoFunctions::Ped::IsDoingGangDriveby( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::IsOnFire( DWORD pUserData ) { if( RESOURCE ) @@ -288,7 +282,7 @@ bool CMonoFunctions::Ped::IsOnFire( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::IsHeadless( DWORD pUserData ) { if( RESOURCE ) @@ -303,7 +297,7 @@ bool CMonoFunctions::Ped::IsHeadless( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::IsFrozen( DWORD pUserData ) { if( RESOURCE ) @@ -318,7 +312,7 @@ bool CMonoFunctions::Ped::IsFrozen( DWORD pUserData ) return false; } - + DWORD CMonoFunctions::Ped::GetOccupiedVehicle( DWORD pUserData ) { if( RESOURCE ) @@ -328,7 +322,7 @@ DWORD CMonoFunctions::Ped::GetOccupiedVehicle( DWORD pUserData ) return NULL; } - + unsigned int CMonoFunctions::Ped::GetOccupiedVehicleSeat( DWORD pUserData ) { if( RESOURCE ) @@ -343,7 +337,7 @@ unsigned int CMonoFunctions::Ped::GetOccupiedVehicleSeat( DWORD pUserData ) return 0; } - + bool CMonoFunctions::Ped::IsInVehicle( DWORD pUserData ) { if( RESOURCE ) @@ -358,7 +352,7 @@ bool CMonoFunctions::Ped::IsInVehicle( DWORD pUserData ) return false; } - + short CMonoFunctions::Ped::GetWeaponProperty( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty ) { if( RESOURCE ) @@ -376,7 +370,7 @@ short CMonoFunctions::Ped::GetWeaponProperty( unsigned char ucWeaponID, MonoStri return 0; } - + short CMonoFunctions::Ped::GetOriginalWeaponProperty( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty ) { if( RESOURCE ) @@ -394,9 +388,9 @@ short CMonoFunctions::Ped::GetOriginalWeaponProperty( unsigned char ucWeaponID, return 0; } - - -// Ped set functions + + +// Ped set functions bool CMonoFunctions::Ped::SetArmor( DWORD pUserData, float fArmor ) { if( RESOURCE ) @@ -406,7 +400,7 @@ bool CMonoFunctions::Ped::SetArmor( DWORD pUserData, float fArmor ) return false; } - + bool CMonoFunctions::Ped::Kill( DWORD pUserData, DWORD pKiller, unsigned char ucKillerWeapon, unsigned char ucBodyPart, bool bStealth ) { if( RESOURCE ) @@ -416,7 +410,7 @@ bool CMonoFunctions::Ped::Kill( DWORD pUserData, DWORD pKiller, unsigned char uc return false; } - + bool CMonoFunctions::Ped::SetStat( DWORD pUserData, unsigned short usStat, float fValue ) { if( RESOURCE ) @@ -426,7 +420,7 @@ bool CMonoFunctions::Ped::SetStat( DWORD pUserData, unsigned short usStat, float return false; } - + bool CMonoFunctions::Ped::AddClothes( DWORD pUserData, MonoString* msTexture, MonoString* msModel, unsigned char ucType ) { if( RESOURCE ) @@ -439,7 +433,7 @@ bool CMonoFunctions::Ped::AddClothes( DWORD pUserData, MonoString* msTexture, Mo return false; } - + bool CMonoFunctions::Ped::RemoveClothes( DWORD pUserData, unsigned char ucType, MonoString* msTexture, MonoString* msModel ) { if( RESOURCE ) @@ -452,7 +446,7 @@ bool CMonoFunctions::Ped::RemoveClothes( DWORD pUserData, unsigned char ucType, return false; } - + bool CMonoFunctions::Ped::GiveJetPack( DWORD pUserData ) { if( RESOURCE ) @@ -462,7 +456,7 @@ bool CMonoFunctions::Ped::GiveJetPack( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::RemoveJetPack( DWORD pUserData ) { if( RESOURCE ) @@ -472,7 +466,7 @@ bool CMonoFunctions::Ped::RemoveJetPack( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::SetFightingStyle( DWORD pUserData, unsigned char ucStyle ) { if( RESOURCE ) @@ -482,7 +476,7 @@ bool CMonoFunctions::Ped::SetFightingStyle( DWORD pUserData, unsigned char ucSty return false; } - + bool CMonoFunctions::Ped::SetMoveAnim( DWORD pUserData, unsigned int iMoveAnim ) { if( RESOURCE ) @@ -492,7 +486,7 @@ bool CMonoFunctions::Ped::SetMoveAnim( DWORD pUserData, unsigned int iMoveAnim ) return false; } - + bool CMonoFunctions::Ped::SetGravity( DWORD pUserData, float fGravity ) { if( RESOURCE ) @@ -502,7 +496,7 @@ bool CMonoFunctions::Ped::SetGravity( DWORD pUserData, float fGravity ) return false; } - + bool CMonoFunctions::Ped::SetChoking( DWORD pUserData, bool bChoking ) { if( RESOURCE ) @@ -512,7 +506,7 @@ bool CMonoFunctions::Ped::SetChoking( DWORD pUserData, bool bChoking ) return false; } - + bool CMonoFunctions::Ped::SetWeaponSlot( DWORD pUserData, unsigned char ucWeaponSlot ) { if( RESOURCE ) @@ -522,7 +516,7 @@ bool CMonoFunctions::Ped::SetWeaponSlot( DWORD pUserData, unsigned char ucWeapon return false; } - + bool CMonoFunctions::Ped::WarpIntoVehicle( DWORD pUserData, DWORD pVehicle, unsigned int uiSeat ) { if( RESOURCE ) @@ -532,7 +526,7 @@ bool CMonoFunctions::Ped::WarpIntoVehicle( DWORD pUserData, DWORD pVehicle, unsi return false; } - + bool CMonoFunctions::Ped::RemoveFromVehicle( DWORD pUserData ) { if( RESOURCE ) @@ -542,7 +536,7 @@ bool CMonoFunctions::Ped::RemoveFromVehicle( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::SetDoingGangDriveby( DWORD pUserData, bool bGangDriveby ) { if( RESOURCE ) @@ -552,7 +546,7 @@ bool CMonoFunctions::Ped::SetDoingGangDriveby( DWORD pUserData, bool bGangDriveb return false; } - + bool CMonoFunctions::Ped::SetAnimation( DWORD pUserData, MonoString* msBlockName, MonoString* msAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame ) { if( RESOURCE ) @@ -565,7 +559,7 @@ bool CMonoFunctions::Ped::SetAnimation( DWORD pUserData, MonoString* msBlockName return false; } - + bool CMonoFunctions::Ped::SetAnimationProgress( DWORD pUserData, MonoString* msAnimName, float fProgress ) { if( RESOURCE ) @@ -577,7 +571,7 @@ bool CMonoFunctions::Ped::SetAnimationProgress( DWORD pUserData, MonoString* msA return false; } - + bool CMonoFunctions::Ped::SetOnFire( DWORD pUserData, bool bIsOnFire ) { if( RESOURCE ) @@ -587,7 +581,7 @@ bool CMonoFunctions::Ped::SetOnFire( DWORD pUserData, bool bIsOnFire ) return false; } - + bool CMonoFunctions::Ped::SetHeadless( DWORD pUserData, bool bIsHeadless ) { if( RESOURCE ) @@ -597,7 +591,7 @@ bool CMonoFunctions::Ped::SetHeadless( DWORD pUserData, bool bIsHeadless ) return false; } - + bool CMonoFunctions::Ped::SetFrozen( DWORD pUserData, bool bIsFrozen ) { if( RESOURCE ) @@ -607,7 +601,7 @@ bool CMonoFunctions::Ped::SetFrozen( DWORD pUserData, bool bIsFrozen ) return false; } - + bool CMonoFunctions::Ped::ReloadWeapon( DWORD pUserData ) { if( RESOURCE ) @@ -617,7 +611,7 @@ bool CMonoFunctions::Ped::ReloadWeapon( DWORD pUserData ) return false; } - + bool CMonoFunctions::Ped::SetWeaponProperty( unsigned char ucWeaponID, MonoString* msWeaponSkill, MonoString* msProperty, short uData ) { if( RESOURCE ) @@ -630,9 +624,9 @@ bool CMonoFunctions::Ped::SetWeaponProperty( unsigned char ucWeaponID, MonoStrin return false; } - - -// Ped body? + + +// Ped body? MonoString* CMonoFunctions::Ped::GetBodyPartName( unsigned char ucID ) { if( RESOURCE ) @@ -647,7 +641,7 @@ MonoString* CMonoFunctions::Ped::GetBodyPartName( unsigned char ucID ) return NULL; } - + MonoArray* CMonoFunctions::Ped::GetClothesByTypeIndex( unsigned char ucType, unsigned char ucIndex ) { if( RESOURCE ) @@ -671,7 +665,7 @@ MonoArray* CMonoFunctions::Ped::GetClothesByTypeIndex( unsigned char ucType, uns return NULL; } - + MonoArray* CMonoFunctions::Ped::GetTypeIndexFromClothes( MonoString* msTexture, MonoString* msModel ) { if( RESOURCE ) @@ -697,7 +691,7 @@ MonoArray* CMonoFunctions::Ped::GetTypeIndexFromClothes( MonoString* msTexture, return NULL; } - + MonoString* CMonoFunctions::Ped::GetClothesTypeName( unsigned char ucType ) { if( RESOURCE ) @@ -712,9 +706,9 @@ MonoString* CMonoFunctions::Ped::GetClothesTypeName( unsigned char ucType ) return NULL; } - - -// Weapon give/take functions + + +// Weapon give/take functions bool CMonoFunctions::Ped::GiveWeapon( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, bool bSetAsCurrent ) { if( RESOURCE ) @@ -724,7 +718,7 @@ bool CMonoFunctions::Ped::GiveWeapon( DWORD pPed, unsigned char ucWeaponID, unsi return false; } - + bool CMonoFunctions::Ped::TakeWeapon( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo ) { if( RESOURCE ) @@ -734,7 +728,7 @@ bool CMonoFunctions::Ped::TakeWeapon( DWORD pPed, unsigned char ucWeaponID, unsi return false; } - + bool CMonoFunctions::Ped::TakeAllWeapons( DWORD pPed ) { if( RESOURCE ) @@ -744,7 +738,7 @@ bool CMonoFunctions::Ped::TakeAllWeapons( DWORD pPed ) return false; } - + bool CMonoFunctions::Ped::SetWeaponAmmo( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, unsigned short usAmmoInClip ) { if( RESOURCE ) diff --git a/mta-mono/src/CMonoFunctions_Pickup.cpp b/mta-mono/src/CMonoFunctions_Pickup.cpp index 8d2ee76..d44b8dd 100644 --- a/mta-mono/src/CMonoFunctions_Pickup.cpp +++ b/mta-mono/src/CMonoFunctions_Pickup.cpp @@ -1,155 +1,149 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Pickup create/destroy funcs +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Pickup create/destroy funcs DWORD CMonoFunctions::Pickup::Create( MonoObject* pPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval, double dSix ) { - if( RESOURCE ) - { - CMonoObject pPosition( pPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - Vector3 vecPosition( fX, fY, fZ ); - - return (DWORD)CLuaFunctionDefinitions::CreatePickup( RESOURCE->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + + return (DWORD)CLuaFunctionDefinitions::CreatePickup( RESOURCE->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix ); + } + return NULL; } - - -// Pickup get funcs + + +// Pickup get funcs unsigned char CMonoFunctions::Pickup::GetType( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned char ucType; - - if( CLuaFunctionDefinitions::GetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType ) ) - { - return ucType; - } + if( RESOURCE ) + { + unsigned char ucType; + + if( CLuaFunctionDefinitions::GetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType ) ) + { + return ucType; + } } return 0; } - + unsigned char CMonoFunctions::Pickup::GetWeapon( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned char ucWeapon; - - if( CLuaFunctionDefinitions::GetPickupWeapon( RESOURCE->GetLua(), (void*)pUserData, ucWeapon ) ) - { - return ucWeapon; - } + if( RESOURCE ) + { + unsigned char ucWeapon; + + if( CLuaFunctionDefinitions::GetPickupWeapon( RESOURCE->GetLua(), (void*)pUserData, ucWeapon ) ) + { + return ucWeapon; + } } return 0; } - + float CMonoFunctions::Pickup::GetAmount( DWORD pUserData ) { - if( RESOURCE ) - { - float fAmount; - - if( CLuaFunctionDefinitions::GetPickupAmount( RESOURCE->GetLua(), (void*)pUserData, fAmount ) ) - { - return fAmount; - } + if( RESOURCE ) + { + float fAmount; + + if( CLuaFunctionDefinitions::GetPickupAmount( RESOURCE->GetLua(), (void*)pUserData, fAmount ) ) + { + return fAmount; + } } return 0; } - + unsigned short CMonoFunctions::Pickup::GetAmmo( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned short usAmmo; - - if( CLuaFunctionDefinitions::GetPickupAmmo( RESOURCE->GetLua(), (void*)pUserData, usAmmo ) ) - { - return usAmmo; - } + if( RESOURCE ) + { + unsigned short usAmmo; + + if( CLuaFunctionDefinitions::GetPickupAmmo( RESOURCE->GetLua(), (void*)pUserData, usAmmo ) ) + { + return usAmmo; + } } return 0; } - + unsigned long CMonoFunctions::Pickup::GetRespawnInterval( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned long ulInterval; - - if( CLuaFunctionDefinitions::GetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ) ) - { - return ulInterval; - } + if( RESOURCE ) + { + unsigned long ulInterval; + + if( CLuaFunctionDefinitions::GetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ) ) + { + return ulInterval; + } } return 0; } - + bool CMonoFunctions::Pickup::IsSpawned( DWORD pUserData ) { - if( RESOURCE ) - { - bool bSpawned; - - if( CLuaFunctionDefinitions::IsPickupSpawned( RESOURCE->GetLua(), (void*)pUserData, bSpawned ) ) - { - return bSpawned; - } + if( RESOURCE ) + { + bool bSpawned; + + if( CLuaFunctionDefinitions::IsPickupSpawned( RESOURCE->GetLua(), (void*)pUserData, bSpawned ) ) + { + return bSpawned; + } } return false; } - - -// Pickup set funcs + + +// Pickup set funcs bool CMonoFunctions::Pickup::SetType( DWORD pUserData, unsigned char ucType, double dThree, double dFour ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType, dThree, dFour ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType, dThree, dFour ); } return false; } - + bool CMonoFunctions::Pickup::SetRespawnInterval( DWORD pUserData, unsigned long ulInterval ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ); } return false; } - + bool CMonoFunctions::Pickup::Use( DWORD pUserData, DWORD pPlayer ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::UsePickup( RESOURCE->GetLua(), (void*)pUserData, (void*)pPlayer ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::UsePickup( RESOURCE->GetLua(), (void*)pUserData, (void*)pPlayer ); } return false; diff --git a/mta-mono/src/CMonoFunctions_Player.cpp b/mta-mono/src/CMonoFunctions_Player.cpp index f6ffea6..04dfbf3 100644 --- a/mta-mono/src/CMonoFunctions_Player.cpp +++ b/mta-mono/src/CMonoFunctions_Player.cpp @@ -1,906 +1,881 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#ifndef _CMONO_FUNCS_PLAYER -#define _CMONO_FUNCS_PLAYER - -#include "CMonoFunctions.h" - -// Player get functions -unsigned int CMonoFunctions::Player::GetCount( void ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GetPlayerCount( RESOURCE->GetLua() ); - } - - return 0; -} - -DWORD CMonoFunctions::Player::GetFromName( MonoString* msNick ) -{ - if( RESOURCE ) - { - const char* szNick = mono_string_to_utf8( msNick ); - - return (DWORD)CLuaFunctionDefinitions::GetPlayerFromName( RESOURCE->GetLua(), szNick ); - } - - return NULL; -} - -unsigned int CMonoFunctions::Player::GetPing( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned int uiPing; - - if( CLuaFunctionDefinitions::GetPlayerPing( RESOURCE->GetLua(), (void*)pUserData, uiPing ) ) - { - return uiPing; - } - } - - return 0; -} - -long CMonoFunctions::Player::GetMoney( DWORD pUserData ) -{ - if( RESOURCE ) - { - long lMoney; - - if( CLuaFunctionDefinitions::GetPlayerMoney( RESOURCE->GetLua(), (void*)pUserData, lMoney ) ) - { - return lMoney; - } - } - - return 0; -} - -DWORD CMonoFunctions::Player::GetRandom( void ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetRandomPlayer( RESOURCE->GetLua() ); - } - - return 0; -} - -bool CMonoFunctions::Player::IsMuted( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bMuted; - - if( CLuaFunctionDefinitions::IsPlayerMuted( RESOURCE->GetLua(), (void*)pUserData, bMuted ) ) - { - return bMuted; - } - } - - return 0; -} - -DWORD CMonoFunctions::Player::GetTeam( DWORD pUserData ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetPlayerTeam( RESOURCE->GetLua(), (void*)pUserData ); - } - - return 0; -} - -unsigned int CMonoFunctions::Player::GetWantedLevel( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned int uiWantedLevel; - - if( CLuaFunctionDefinitions::GetPlayerWantedLevel( RESOURCE->GetLua(), (void*)pUserData, uiWantedLevel ) ) - { - return uiWantedLevel; - } - } - - return 0; -} - -MonoArray* CMonoFunctions::Player::GetAlivePlayers( void ) -{ - if( RESOURCE ) - { - CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetAlivePlayers( RESOURCE->GetLua() ); - - if( pLuaArguments ) - { - MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_uint32_class(), pLuaArguments->Count() ); - - 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; - } - } - - return NULL; -} - -MonoArray* CMonoFunctions::Player::GetDeadPlayers( void ) -{ - if( RESOURCE ) - { - CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetDeadPlayers( RESOURCE->GetLua() ); - - if( pLuaArguments ) - { - MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_uint32_class(), pLuaArguments->Count() ); - - 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; - } - } - - return NULL; -} - -unsigned int CMonoFunctions::Player::GetIdleTime( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned int uiIdleTime; - - if( CLuaFunctionDefinitions::GetPlayerIdleTime( RESOURCE->GetLua(), (void*)pUserData, uiIdleTime ) ) - { - return uiIdleTime; - } - } - - return 0; -} - -bool CMonoFunctions::Player::IsMapForced( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bForced; - - if( CLuaFunctionDefinitions::IsPlayerMapForced( RESOURCE->GetLua(), (void*)pUserData, bForced ) ) - { - return bForced; - } - } - - return 0; -} - -MonoString* CMonoFunctions::Player::GetNametagText( DWORD pUserData ) -{ - if( RESOURCE ) - { - string strOutText; - - if( CLuaFunctionDefinitions::GetPlayerNametagText( RESOURCE->GetLua(), (void*)pUserData, strOutText ) ) - { - return RESOURCE->NewString( strOutText ); - } - } - - return NULL; -} - -MonoObject* CMonoFunctions::Player::GetNametagColor( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned char ucR, ucG, ucB; - - if( CLuaFunctionDefinitions::GetPlayerNametagColor( RESOURCE->GetLua(), (void*)pUserData, ucR, ucG, ucB ) ) - { - void *args[] = - { - &ucR, &ucG, &ucB - }; - - CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "Color", args, 3 ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -bool CMonoFunctions::Player::IsNametagShowing( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bShowing; - - if( CLuaFunctionDefinitions::IsPlayerNametagShowing( RESOURCE->GetLua(), (void*)pUserData, bShowing ) ) - { - return bShowing; - } - } - - return false; -} - -MonoString* CMonoFunctions::Player::GetSerial( DWORD pUserData ) -{ - if( RESOURCE ) - { - return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerSerial( RESOURCE->GetLua(), (void*)pUserData ) ); - } - - return NULL; -} - -MonoString* CMonoFunctions::Player::GetUserName( DWORD pUserData ) -{ - if( RESOURCE ) - { - return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerUserName( RESOURCE->GetLua(), (void*)pUserData ) ); - } - - return NULL; -} - -unsigned char CMonoFunctions::Player::GetBlurLevel( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned char ucBlurLevel; - - if( CLuaFunctionDefinitions::GetPlayerBlurLevel( RESOURCE->GetLua(), (void*)pUserData, ucBlurLevel ) ) - { - return ucBlurLevel; - } - } - - return 0; -} - -MonoString* CMonoFunctions::Player::GetName( DWORD pUserData ) -{ - if( RESOURCE ) - { - string strOutName; - - if( CLuaFunctionDefinitions::GetPlayerName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) - { - return RESOURCE->NewString( strOutName ); - } - } - - return NULL; -} - -MonoString* CMonoFunctions::Player::GetIP( DWORD pUserData ) -{ - if( RESOURCE ) - { - string strIP; - - if( CLuaFunctionDefinitions::GetPlayerIP( RESOURCE->GetLua(), (void*)pUserData, strIP ) ) - { - return RESOURCE->NewString( strIP ); - } - } - - return NULL; -} - -DWORD CMonoFunctions::Player::GetAccount( DWORD pUserData ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetPlayerAccount( RESOURCE->GetLua(), (void*)pUserData ); - } - - return NULL; -} - -MonoString* CMonoFunctions::Player::GetVersion( DWORD pUserData ) -{ - if( RESOURCE ) - { - return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerVersion( RESOURCE->GetLua(), (void*)pUserData ) ); - } - - return NULL; -} - -MonoObject* CMonoFunctions::Player::GetACInfo( DWORD pUserData ) -{ - if( RESOURCE ) - { - LuaTable pLuaTable = CLuaFunctionDefinitions::GetPlayerACInfo( RESOURCE->GetLua(), (void*)pUserData ); - - if( !pLuaTable.empty() ) - { - MonoString* msDetectedAC = RESOURCE->NewString( pLuaTable[ "DetectedAC" ]->GetString() ); - MonoString* msD3D9MD5 = RESOURCE->NewString( pLuaTable[ "d3d9MD5" ]->GetString() ); - MonoString* msD3D9SHA256 = RESOURCE->NewString( pLuaTable[ "d3d9SHA256" ]->GetString() ); - - unsigned int iD3D9Size = pLuaTable[ "d3d9Size" ]->GetNumber< unsigned int >(); - - void *args[] = - { - &msDetectedAC, - &iD3D9Size, - &msD3D9MD5, - &msD3D9SHA256 - }; - - CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "PlayerACInfo", args, 4 ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - return NULL; -} - -MonoString* CMonoFunctions::Player::GetPlayerAnnounceValue( DWORD pElement, MonoString* msKey ) -{ - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - - return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerAnnounceValue( RESOURCE->GetLua(), (void*)pElement, szKey ) ); - } - - return NULL; -} - - -// Player set functions -bool CMonoFunctions::Player::SetMoney( DWORD pUserData, int iAmount, bool bInstant ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerMoney( RESOURCE->GetLua(), (void*)pUserData, iAmount, bInstant ); - } - - return false; -} - -bool CMonoFunctions::Player::GiveMoney( DWORD pUserData, int iAmount ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GivePlayerMoney( RESOURCE->GetLua(), (void*)pUserData, iAmount ); - } - - return false; -} - -bool CMonoFunctions::Player::TakeMoney( DWORD pUserData, int iAmount ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::TakePlayerMoney( RESOURCE->GetLua(), (void*)pUserData, iAmount ); - } - - return false; -} - -bool CMonoFunctions::Player::Spawn( DWORD pUserData, MonoObject* pPosition, int iRotation, int iSkinID, int iInterior, int iDimension, DWORD pTeam ) -{ - if( RESOURCE ) - { - CMonoObject pPosition( pPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - Vector3 vecPosition( fX, fY, fZ ); - - return CLuaFunctionDefinitions::SpawnPlayer( RESOURCE->GetLua(), (void*)pUserData, vecPosition, iRotation, iSkinID, iInterior, iDimension, (void*)pTeam ); - } - - return false; -} - -bool CMonoFunctions::Player::ShowHudComponent( DWORD pUserData, MonoString* msComponent, bool bShow ) -{ - if( RESOURCE ) - { - string strComponent( mono_string_to_utf8( msComponent ) ); - - return CLuaFunctionDefinitions::ShowPlayerHudComponent( RESOURCE->GetLua(), (void*)pUserData, strComponent, bShow ); - } - - return false; -} - -bool CMonoFunctions::Player::SetWantedLevel( DWORD pUserData, int iLevel ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerWantedLevel( RESOURCE->GetLua(), (void*)pUserData, iLevel ); - } - - return false; -} - -bool CMonoFunctions::Player::ForceMap( DWORD pUserData, bool bForceOn ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ForcePlayerMap( RESOURCE->GetLua(), (void*)pUserData, bForceOn ); - } - - return false; -} - -bool CMonoFunctions::Player::SetNametagText( DWORD pUserData, MonoString* sText ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerNametagText( RESOURCE->GetLua(), (void*)pUserData, string( mono_string_to_utf8( sText ) ) ); - } - - return false; -} - -bool CMonoFunctions::Player::SetNametagColor( DWORD pUserData, int iRed, int iGreen, int iBlue ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerNametagColor( RESOURCE->GetLua(), (void*)pUserData, iRed, iGreen, iBlue ); - } - - return false; -} - -bool CMonoFunctions::Player::SetNametagShowing( DWORD pUserData, bool bShowing ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerNametagShowing( RESOURCE->GetLua(), (void*)pUserData, bShowing ); - } - - return false; -} - -bool CMonoFunctions::Player::SetMuted( DWORD pUserData, bool bMuted ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerMuted( RESOURCE->GetLua(), (void*)pUserData, bMuted ); - } - - return false; -} - -bool CMonoFunctions::Player::SetBlurLevel( DWORD pUserData, int iLevel ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerBlurLevel( RESOURCE->GetLua(), (void*)pUserData, iLevel ); - } - - return false; -} - -bool CMonoFunctions::Player::Redirect( DWORD pUserData, MonoString* sServerIP, int iServerPort, MonoString* sServerPassword ) -{ - if( RESOURCE ) - { - const char* szServerIP = mono_string_to_utf8( sServerIP ); - const char* szServerPassword = mono_string_to_utf8( sServerPassword ); - - return CLuaFunctionDefinitions::RedirectPlayer( RESOURCE->GetLua(), (void*)pUserData, szServerIP, iServerPort, szServerPassword ); - } - - return false; -} - -bool CMonoFunctions::Player::SetName( DWORD pUserData, MonoString* sName ) -{ - if( RESOURCE ) - { - const char* szName = mono_string_to_utf8( sName ); - - return CLuaFunctionDefinitions::SetPlayerName( RESOURCE->GetLua(), (void*)pUserData, szName ); - } - - return false; -} - -bool CMonoFunctions::Player::DetonateSatchels( DWORD pUserData ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::DetonateSatchels( RESOURCE->GetLua(), (void*)pUserData ); - } - - return false; -} - -bool CMonoFunctions::Player::TakeScreenShot( DWORD pUserData, int iWidth, int iHeight, MonoString* sTag, int iQuality, int iMaxBandwith ) -{ - if( RESOURCE ) - { - string strTag( mono_string_to_utf8( sTag ) ); - - return CLuaFunctionDefinitions::TakePlayerScreenShot( RESOURCE->GetLua(), (void*)pUserData, iWidth, iHeight, strTag, iQuality, iMaxBandwith ); - } - - return false; -} - -bool CMonoFunctions::Player::SetTeam( DWORD pUserData, DWORD pTeam ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetPlayerTeam( RESOURCE->GetLua(), (void*)pUserData, (void*)pTeam ); - } - - return false; -} - -bool CMonoFunctions::Player::SetPlayerAnnounceValue( DWORD pElement, MonoString* msKey, MonoString* msValue ) -{ - - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - const char* szValue = mono_string_to_utf8( msValue ); - - return CLuaFunctionDefinitions::SetPlayerAnnounceValue( RESOURCE->GetLua(), (void*)pElement, szKey, szValue ); - } - - return NULL; -} - -// Input funcs - -bool CMonoFunctions::Player::BindKey( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName, MonoString* msArguments ) -{ - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - const char* szHitState = mono_string_to_utf8( msHitState ); - const char* szCommandName = mono_string_to_utf8( msCommandName ); - const char* szArguments = mono_string_to_utf8( msArguments ); - - return CLuaFunctionDefinitions::BindKey( RESOURCE->GetLua(), (void*)pUserData, szKey, szHitState, szCommandName, szArguments ); - } - - return false; -} - -bool CMonoFunctions::Player::UnbindKey( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName ) -{ - if( RESOURCE ) - { - const char* szKey = mono_string_to_utf8( msKey ); - const char* szHitState = mono_string_to_utf8( msHitState ); - const char* szCommandName = mono_string_to_utf8( msCommandName ); - - return CLuaFunctionDefinitions::UnbindKey( RESOURCE->GetLua(), (void*)pUserData, szKey, szHitState, szCommandName ); - } - - return false; -} - -bool CMonoFunctions::Player::GetControlState( DWORD pUserData, MonoString* msControl ) -{ - if( RESOURCE ) - { - const char* szControl = mono_string_to_utf8( msControl ); - - bool bState; - - if( CLuaFunctionDefinitions::GetControlState( RESOURCE->GetLua(), (void*)pUserData, szControl, bState ) ) - { - return bState; - } - } - - return false; -} - -bool CMonoFunctions::Player::IsControlEnabled( DWORD pUserData, MonoString* msControl ) -{ - if( RESOURCE ) - { - const char* szControl = mono_string_to_utf8( msControl ); - - bool bEnabled; - - if( CLuaFunctionDefinitions::IsControlEnabled( RESOURCE->GetLua(), (void*)pUserData, szControl, bEnabled ) ) - { - return bEnabled; - } - } - - return false; -} - - -bool CMonoFunctions::Player::SetControlState( DWORD pUserData, MonoString* msControl, bool bState ) -{ - if( RESOURCE ) - { - const char* szControl = mono_string_to_utf8( msControl ); - - return CLuaFunctionDefinitions::SetControlState( RESOURCE->GetLua(), (void*)pUserData, szControl, bState ); - } - - return false; -} - -bool CMonoFunctions::Player::ToggleControl( DWORD pUserData, MonoString* msControl, bool bEnabled ) -{ - if( RESOURCE ) - { - const char* szControl = mono_string_to_utf8( msControl ); - - return CLuaFunctionDefinitions::ToggleControl( RESOURCE->GetLua(), (void*)pUserData, szControl, bEnabled ); - } - - return false; -} - -bool CMonoFunctions::Player::ToggleAllControls( DWORD pUserData, bool bGTAControls, bool bMTAControls, bool bEnabled ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ToggleAllControls( RESOURCE->GetLua(), (void*)pUserData, bGTAControls, bMTAControls, bEnabled ); - } - - return false; -} - - -// Log in/out funcs -bool CMonoFunctions::Player::LogIn( DWORD pPlayer, DWORD pAccount, MonoString* msPassword ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::LogIn( RESOURCE->GetLua(), (void*)pPlayer, (void*)pAccount, mono_string_to_utf8( msPassword ) ); - } - - return false; -} - -bool CMonoFunctions::Player::LogOut( DWORD pPlayer ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::LogOut( RESOURCE->GetLua(), (void*)pPlayer ); - } - - return false; -} - - -// Admin funcs -bool CMonoFunctions::Player::Kick( DWORD pPlayer, MonoString* msResponsible, MonoString* msReason ) -{ - if( RESOURCE ) - { - string - strResponsible( mono_string_to_utf8( msResponsible ) ), - strReason( mono_string_to_utf8( msReason ) ); - - return CLuaFunctionDefinitions::KickPlayer( RESOURCE->GetLua(), (void*)pPlayer, strResponsible, strReason ); - } - - return false; -} - -DWORD CMonoFunctions::Player::Ban( DWORD pPlayer, bool bIP, bool bUsername, bool bSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban ) -{ - if( RESOURCE ) - { - string - strResponsible( mono_string_to_utf8( msResponsible ) ), - strReason( mono_string_to_utf8( msReason ) ); - - return (DWORD)CLuaFunctionDefinitions::BanPlayer( RESOURCE->GetLua(), (void*)pPlayer, bIP, bUsername, bSerial, (void*)pResponsible, strResponsible, strReason, iUnban ); - } - - return false; -} - - -// Cursor get funcs -bool CMonoFunctions::Player::IsCursorShowing( DWORD pPlayer ) -{ - if( RESOURCE ) - { - bool bShowing; - - if( CLuaFunctionDefinitions::IsCursorShowing( RESOURCE->GetLua(), (void*)pPlayer, bShowing ) ) - { - return bShowing; - } - } - - return false; -} - - -// Cursor set funcs -bool CMonoFunctions::Player::ShowCursor( DWORD pPlayer, bool bShow, bool bToggleControls ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ShowCursor( RESOURCE->GetLua(), (void*)pPlayer, bShow, bToggleControls ); - } - - return false; -} - - -// Chat funcs -bool CMonoFunctions::Player::ShowChat( DWORD pPlayer, bool bShow ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ShowChat( RESOURCE->GetLua(), (void*)pPlayer, bShow ); - } - - return false; -} - - -// Camera get functions -MonoObject* CMonoFunctions::Player::GetCameraMatrix( DWORD pPlayer ) -{ - if( RESOURCE ) - { - Vector3 vecPosition, vecLookAt; - - float fRoll, fFOV; - - if( CLuaFunctionDefinitions::GetCameraMatrix( RESOURCE->GetLua(), (void*)pPlayer, vecPosition, vecLookAt, fRoll, fFOV ) ) - { - void *args[] = - { - &vecPosition.fX, - &vecPosition.fY, - &vecPosition.fZ, - &vecLookAt.fX, - &vecLookAt.fY, - &vecLookAt.fZ, - &fRoll, - &fFOV - }; - - CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "CameraMatrix", args, 8 ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -DWORD CMonoFunctions::Player::GetCameraTarget( DWORD pPlayer ) -{ - if( RESOURCE ) - { - return (DWORD)CLuaFunctionDefinitions::GetCameraTarget( RESOURCE->GetLua(), (void*)pPlayer ); - } - - return false; -} - -unsigned char CMonoFunctions::Player::GetCameraInterior( DWORD pPlayer ) -{ - if( RESOURCE ) - { - unsigned char ucInterior; - - if( CLuaFunctionDefinitions::GetCameraInterior( RESOURCE->GetLua(), (void*)pPlayer, ucInterior ) ) - { - return ucInterior; - } - } - - return 0; -} - - -// Camera set functions -bool CMonoFunctions::Player::SetCameraMatrix( DWORD pPlayer, MonoObject* pCameraMatrix ) -{ - if( RESOURCE ) - { - CMonoObject pCameraMatrix( pCameraMatrix ); - - float fX = pCameraMatrix.GetPropertyValue< float >( "X" ); - float fY = pCameraMatrix.GetPropertyValue< float >( "Y" ); - float fZ = pCameraMatrix.GetPropertyValue< float >( "Z" ); - - Vector3 vecPosition( fX, fY, fZ ); - - float fLookAtX = pCameraMatrix.GetPropertyValue< float >( "LookAtX" ); - float fLookAtY = pCameraMatrix.GetPropertyValue< float >( "LookAtY" ); - float fLookAtZ = pCameraMatrix.GetPropertyValue< float >( "LookAtZ" ); - - Vector3* vecLookAt = new Vector3( fLookAtX, fLookAtY, fLookAtZ ); - - float fRoll = pCameraMatrix.GetPropertyValue< float >( "Roll" ); - float fFOV = pCameraMatrix.GetPropertyValue< float >( "FOV" ); - - return CLuaFunctionDefinitions::SetCameraMatrix( RESOURCE->GetLua(), (void*)pPlayer, vecPosition, vecLookAt, fRoll, fFOV ); - } - - return false; -} - -bool CMonoFunctions::Player::SetCameraTarget( DWORD pPlayer, DWORD pTarget ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetCameraTarget( RESOURCE->GetLua(), (void*)pPlayer, (void*)pTarget ); - } - - return false; -} - -bool CMonoFunctions::Player::SetCameraInterior( DWORD pPlayer, unsigned char ucInterior ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetCameraInterior( RESOURCE->GetLua(), (void*)pPlayer, ucInterior ); - } - - return false; -} - -bool CMonoFunctions::Player::FadeCamera( DWORD pPlayer, bool bFadeIn, float fFadeTime, MonoObject* pColor ) -{ - if( RESOURCE ) - { - CMonoObject pColor( pColor ); - - unsigned char ucReed = pColor.GetPropertyValue< unsigned char >( "R" ); - unsigned char ucGreen = pColor.GetPropertyValue< unsigned char >( "G" ); - unsigned char ucBlue = pColor.GetPropertyValue< unsigned char >( "B" ); - - return CLuaFunctionDefinitions::FadeCamera( RESOURCE->GetLua(), (void*)pPlayer, bFadeIn, fFadeTime, ucReed, ucGreen, ucBlue ); - } - - return false; -} - +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#ifndef _CMONO_FUNCS_PLAYER +#define _CMONO_FUNCS_PLAYER + +#include "CMonoFunctions.h" + +// Player get functions +unsigned int CMonoFunctions::Player::GetCount( void ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GetPlayerCount( RESOURCE->GetLua() ); + } + + return 0; +} + +DWORD CMonoFunctions::Player::GetFromName( MonoString* msNick ) +{ + if( RESOURCE ) + { + const char* szNick = mono_string_to_utf8( msNick ); + + return (DWORD)CLuaFunctionDefinitions::GetPlayerFromName( RESOURCE->GetLua(), szNick ); + } + + return NULL; +} + +unsigned int CMonoFunctions::Player::GetPing( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned int uiPing; + + if( CLuaFunctionDefinitions::GetPlayerPing( RESOURCE->GetLua(), (void*)pUserData, uiPing ) ) + { + return uiPing; + } + } + + return 0; +} + +long CMonoFunctions::Player::GetMoney( DWORD pUserData ) +{ + if( RESOURCE ) + { + long lMoney; + + if( CLuaFunctionDefinitions::GetPlayerMoney( RESOURCE->GetLua(), (void*)pUserData, lMoney ) ) + { + return lMoney; + } + } + + return 0; +} + +DWORD CMonoFunctions::Player::GetRandom( void ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetRandomPlayer( RESOURCE->GetLua() ); + } + + return 0; +} + +bool CMonoFunctions::Player::IsMuted( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bMuted; + + if( CLuaFunctionDefinitions::IsPlayerMuted( RESOURCE->GetLua(), (void*)pUserData, bMuted ) ) + { + return bMuted; + } + } + + return 0; +} + +DWORD CMonoFunctions::Player::GetTeam( DWORD pUserData ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetPlayerTeam( RESOURCE->GetLua(), (void*)pUserData ); + } + + return 0; +} + +unsigned int CMonoFunctions::Player::GetWantedLevel( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned int uiWantedLevel; + + if( CLuaFunctionDefinitions::GetPlayerWantedLevel( RESOURCE->GetLua(), (void*)pUserData, uiWantedLevel ) ) + { + return uiWantedLevel; + } + } + + return 0; +} + +MonoArray* CMonoFunctions::Player::GetAlivePlayers( void ) +{ + if( RESOURCE ) + { + CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetAlivePlayers( RESOURCE->GetLua() ); + + if( pLuaArguments ) + { + MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_uint32_class(), pLuaArguments->Count() ); + + 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; + } + } + + return NULL; +} + +MonoArray* CMonoFunctions::Player::GetDeadPlayers( void ) +{ + if( RESOURCE ) + { + CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetDeadPlayers( RESOURCE->GetLua() ); + + if( pLuaArguments ) + { + MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_uint32_class(), pLuaArguments->Count() ); + + 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; + } + } + + return NULL; +} + +unsigned int CMonoFunctions::Player::GetIdleTime( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned int uiIdleTime; + + if( CLuaFunctionDefinitions::GetPlayerIdleTime( RESOURCE->GetLua(), (void*)pUserData, uiIdleTime ) ) + { + return uiIdleTime; + } + } + + return 0; +} + +bool CMonoFunctions::Player::IsMapForced( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bForced; + + if( CLuaFunctionDefinitions::IsPlayerMapForced( RESOURCE->GetLua(), (void*)pUserData, bForced ) ) + { + return bForced; + } + } + + return 0; +} + +MonoString* CMonoFunctions::Player::GetNametagText( DWORD pUserData ) +{ + if( RESOURCE ) + { + string strOutText; + + if( CLuaFunctionDefinitions::GetPlayerNametagText( RESOURCE->GetLua(), (void*)pUserData, strOutText ) ) + { + return RESOURCE->NewString( strOutText ); + } + } + + return NULL; +} + +MonoObject* CMonoFunctions::Player::GetNametagColor( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned char ucR, ucG, ucB; + + if( CLuaFunctionDefinitions::GetPlayerNametagColor( RESOURCE->GetLua(), (void*)pUserData, ucR, ucG, ucB ) ) + { + void *args[] = + { + &ucR, &ucG, &ucB + }; + + return RESOURCE->NewObject( "MultiTheftAuto", "Color", args, 3 ); + } + } + + return NULL; +} + +bool CMonoFunctions::Player::IsNametagShowing( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bShowing; + + if( CLuaFunctionDefinitions::IsPlayerNametagShowing( RESOURCE->GetLua(), (void*)pUserData, bShowing ) ) + { + return bShowing; + } + } + + return false; +} + +MonoString* CMonoFunctions::Player::GetSerial( DWORD pUserData ) +{ + if( RESOURCE ) + { + return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerSerial( RESOURCE->GetLua(), (void*)pUserData ) ); + } + + return NULL; +} + +MonoString* CMonoFunctions::Player::GetUserName( DWORD pUserData ) +{ + if( RESOURCE ) + { + return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerUserName( RESOURCE->GetLua(), (void*)pUserData ) ); + } + + return NULL; +} + +unsigned char CMonoFunctions::Player::GetBlurLevel( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned char ucBlurLevel; + + if( CLuaFunctionDefinitions::GetPlayerBlurLevel( RESOURCE->GetLua(), (void*)pUserData, ucBlurLevel ) ) + { + return ucBlurLevel; + } + } + + return 0; +} + +MonoString* CMonoFunctions::Player::GetName( DWORD pUserData ) +{ + if( RESOURCE ) + { + string strOutName; + + if( CLuaFunctionDefinitions::GetPlayerName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) + { + return RESOURCE->NewString( strOutName ); + } + } + + return NULL; +} + +MonoString* CMonoFunctions::Player::GetIP( DWORD pUserData ) +{ + if( RESOURCE ) + { + string strIP; + + if( CLuaFunctionDefinitions::GetPlayerIP( RESOURCE->GetLua(), (void*)pUserData, strIP ) ) + { + return RESOURCE->NewString( strIP ); + } + } + + return NULL; +} + +DWORD CMonoFunctions::Player::GetAccount( DWORD pUserData ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetPlayerAccount( RESOURCE->GetLua(), (void*)pUserData ); + } + + return NULL; +} + +MonoString* CMonoFunctions::Player::GetVersion( DWORD pUserData ) +{ + if( RESOURCE ) + { + return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerVersion( RESOURCE->GetLua(), (void*)pUserData ) ); + } + + return NULL; +} + +MonoObject* CMonoFunctions::Player::GetACInfo( DWORD pUserData ) +{ + if( RESOURCE ) + { + LuaTable pLuaTable = CLuaFunctionDefinitions::GetPlayerACInfo( RESOURCE->GetLua(), (void*)pUserData ); + + if( !pLuaTable.empty() ) + { + MonoString* msDetectedAC = RESOURCE->NewString( pLuaTable[ "DetectedAC" ]->GetString() ); + MonoString* msD3D9MD5 = RESOURCE->NewString( pLuaTable[ "d3d9MD5" ]->GetString() ); + MonoString* msD3D9SHA256 = RESOURCE->NewString( pLuaTable[ "d3d9SHA256" ]->GetString() ); + + unsigned int iD3D9Size = pLuaTable[ "d3d9Size" ]->GetNumber< unsigned int >(); + + void *args[] = + { + &msDetectedAC, + &iD3D9Size, + &msD3D9MD5, + &msD3D9SHA256 + }; + + return RESOURCE->NewObject( "MultiTheftAuto", "PlayerACInfo", args, 4 ); + } + } + return NULL; +} + +MonoString* CMonoFunctions::Player::GetPlayerAnnounceValue( DWORD pElement, MonoString* msKey ) +{ + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + + return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerAnnounceValue( RESOURCE->GetLua(), (void*)pElement, szKey ) ); + } + + return NULL; +} + + +// Player set functions +bool CMonoFunctions::Player::SetMoney( DWORD pUserData, int iAmount, bool bInstant ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerMoney( RESOURCE->GetLua(), (void*)pUserData, iAmount, bInstant ); + } + + return false; +} + +bool CMonoFunctions::Player::GiveMoney( DWORD pUserData, int iAmount ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GivePlayerMoney( RESOURCE->GetLua(), (void*)pUserData, iAmount ); + } + + return false; +} + +bool CMonoFunctions::Player::TakeMoney( DWORD pUserData, int iAmount ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::TakePlayerMoney( RESOURCE->GetLua(), (void*)pUserData, iAmount ); + } + + return false; +} + +bool CMonoFunctions::Player::Spawn( DWORD pUserData, MonoObject* pPosition, int iRotation, int iSkinID, int iInterior, int iDimension, DWORD pTeam ) +{ + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + + return CLuaFunctionDefinitions::SpawnPlayer( RESOURCE->GetLua(), (void*)pUserData, vecPosition, iRotation, iSkinID, iInterior, iDimension, (void*)pTeam ); + } + + return false; +} + +bool CMonoFunctions::Player::ShowHudComponent( DWORD pUserData, MonoString* msComponent, bool bShow ) +{ + if( RESOURCE ) + { + string strComponent( mono_string_to_utf8( msComponent ) ); + + return CLuaFunctionDefinitions::ShowPlayerHudComponent( RESOURCE->GetLua(), (void*)pUserData, strComponent, bShow ); + } + + return false; +} + +bool CMonoFunctions::Player::SetWantedLevel( DWORD pUserData, int iLevel ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerWantedLevel( RESOURCE->GetLua(), (void*)pUserData, iLevel ); + } + + return false; +} + +bool CMonoFunctions::Player::ForceMap( DWORD pUserData, bool bForceOn ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ForcePlayerMap( RESOURCE->GetLua(), (void*)pUserData, bForceOn ); + } + + return false; +} + +bool CMonoFunctions::Player::SetNametagText( DWORD pUserData, MonoString* sText ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerNametagText( RESOURCE->GetLua(), (void*)pUserData, string( mono_string_to_utf8( sText ) ) ); + } + + return false; +} + +bool CMonoFunctions::Player::SetNametagColor( DWORD pUserData, int iRed, int iGreen, int iBlue ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerNametagColor( RESOURCE->GetLua(), (void*)pUserData, iRed, iGreen, iBlue ); + } + + return false; +} + +bool CMonoFunctions::Player::SetNametagShowing( DWORD pUserData, bool bShowing ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerNametagShowing( RESOURCE->GetLua(), (void*)pUserData, bShowing ); + } + + return false; +} + +bool CMonoFunctions::Player::SetMuted( DWORD pUserData, bool bMuted ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerMuted( RESOURCE->GetLua(), (void*)pUserData, bMuted ); + } + + return false; +} + +bool CMonoFunctions::Player::SetBlurLevel( DWORD pUserData, int iLevel ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerBlurLevel( RESOURCE->GetLua(), (void*)pUserData, iLevel ); + } + + return false; +} + +bool CMonoFunctions::Player::Redirect( DWORD pUserData, MonoString* sServerIP, int iServerPort, MonoString* sServerPassword ) +{ + if( RESOURCE ) + { + const char* szServerIP = mono_string_to_utf8( sServerIP ); + const char* szServerPassword = mono_string_to_utf8( sServerPassword ); + + return CLuaFunctionDefinitions::RedirectPlayer( RESOURCE->GetLua(), (void*)pUserData, szServerIP, iServerPort, szServerPassword ); + } + + return false; +} + +bool CMonoFunctions::Player::SetName( DWORD pUserData, MonoString* sName ) +{ + if( RESOURCE ) + { + const char* szName = mono_string_to_utf8( sName ); + + return CLuaFunctionDefinitions::SetPlayerName( RESOURCE->GetLua(), (void*)pUserData, szName ); + } + + return false; +} + +bool CMonoFunctions::Player::DetonateSatchels( DWORD pUserData ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::DetonateSatchels( RESOURCE->GetLua(), (void*)pUserData ); + } + + return false; +} + +bool CMonoFunctions::Player::TakeScreenShot( DWORD pUserData, int iWidth, int iHeight, MonoString* sTag, int iQuality, int iMaxBandwith ) +{ + if( RESOURCE ) + { + string strTag( mono_string_to_utf8( sTag ) ); + + return CLuaFunctionDefinitions::TakePlayerScreenShot( RESOURCE->GetLua(), (void*)pUserData, iWidth, iHeight, strTag, iQuality, iMaxBandwith ); + } + + return false; +} + +bool CMonoFunctions::Player::SetTeam( DWORD pUserData, DWORD pTeam ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetPlayerTeam( RESOURCE->GetLua(), (void*)pUserData, (void*)pTeam ); + } + + return false; +} + +bool CMonoFunctions::Player::SetPlayerAnnounceValue( DWORD pElement, MonoString* msKey, MonoString* msValue ) +{ + + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + const char* szValue = mono_string_to_utf8( msValue ); + + return CLuaFunctionDefinitions::SetPlayerAnnounceValue( RESOURCE->GetLua(), (void*)pElement, szKey, szValue ); + } + + return NULL; +} + +// Input funcs + +bool CMonoFunctions::Player::BindKey( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName, MonoString* msArguments ) +{ + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + const char* szHitState = mono_string_to_utf8( msHitState ); + const char* szCommandName = mono_string_to_utf8( msCommandName ); + const char* szArguments = mono_string_to_utf8( msArguments ); + + return CLuaFunctionDefinitions::BindKey( RESOURCE->GetLua(), (void*)pUserData, szKey, szHitState, szCommandName, szArguments ); + } + + return false; +} + +bool CMonoFunctions::Player::UnbindKey( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName ) +{ + if( RESOURCE ) + { + const char* szKey = mono_string_to_utf8( msKey ); + const char* szHitState = mono_string_to_utf8( msHitState ); + const char* szCommandName = mono_string_to_utf8( msCommandName ); + + return CLuaFunctionDefinitions::UnbindKey( RESOURCE->GetLua(), (void*)pUserData, szKey, szHitState, szCommandName ); + } + + return false; +} + +bool CMonoFunctions::Player::GetControlState( DWORD pUserData, MonoString* msControl ) +{ + if( RESOURCE ) + { + const char* szControl = mono_string_to_utf8( msControl ); + + bool bState; + + if( CLuaFunctionDefinitions::GetControlState( RESOURCE->GetLua(), (void*)pUserData, szControl, bState ) ) + { + return bState; + } + } + + return false; +} + +bool CMonoFunctions::Player::IsControlEnabled( DWORD pUserData, MonoString* msControl ) +{ + if( RESOURCE ) + { + const char* szControl = mono_string_to_utf8( msControl ); + + bool bEnabled; + + if( CLuaFunctionDefinitions::IsControlEnabled( RESOURCE->GetLua(), (void*)pUserData, szControl, bEnabled ) ) + { + return bEnabled; + } + } + + return false; +} + + +bool CMonoFunctions::Player::SetControlState( DWORD pUserData, MonoString* msControl, bool bState ) +{ + if( RESOURCE ) + { + const char* szControl = mono_string_to_utf8( msControl ); + + return CLuaFunctionDefinitions::SetControlState( RESOURCE->GetLua(), (void*)pUserData, szControl, bState ); + } + + return false; +} + +bool CMonoFunctions::Player::ToggleControl( DWORD pUserData, MonoString* msControl, bool bEnabled ) +{ + if( RESOURCE ) + { + const char* szControl = mono_string_to_utf8( msControl ); + + return CLuaFunctionDefinitions::ToggleControl( RESOURCE->GetLua(), (void*)pUserData, szControl, bEnabled ); + } + + return false; +} + +bool CMonoFunctions::Player::ToggleAllControls( DWORD pUserData, bool bGTAControls, bool bMTAControls, bool bEnabled ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ToggleAllControls( RESOURCE->GetLua(), (void*)pUserData, bGTAControls, bMTAControls, bEnabled ); + } + + return false; +} + + +// Log in/out funcs +bool CMonoFunctions::Player::LogIn( DWORD pPlayer, DWORD pAccount, MonoString* msPassword ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::LogIn( RESOURCE->GetLua(), (void*)pPlayer, (void*)pAccount, mono_string_to_utf8( msPassword ) ); + } + + return false; +} + +bool CMonoFunctions::Player::LogOut( DWORD pPlayer ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::LogOut( RESOURCE->GetLua(), (void*)pPlayer ); + } + + return false; +} + + +// Admin funcs +bool CMonoFunctions::Player::Kick( DWORD pPlayer, MonoString* msResponsible, MonoString* msReason ) +{ + if( RESOURCE ) + { + string + strResponsible( mono_string_to_utf8( msResponsible ) ), + strReason( mono_string_to_utf8( msReason ) ); + + return CLuaFunctionDefinitions::KickPlayer( RESOURCE->GetLua(), (void*)pPlayer, strResponsible, strReason ); + } + + return false; +} + +DWORD CMonoFunctions::Player::Ban( DWORD pPlayer, bool bIP, bool bUsername, bool bSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban ) +{ + if( RESOURCE ) + { + string + strResponsible( mono_string_to_utf8( msResponsible ) ), + strReason( mono_string_to_utf8( msReason ) ); + + return (DWORD)CLuaFunctionDefinitions::BanPlayer( RESOURCE->GetLua(), (void*)pPlayer, bIP, bUsername, bSerial, (void*)pResponsible, strResponsible, strReason, iUnban ); + } + + return false; +} + + +// Cursor get funcs +bool CMonoFunctions::Player::IsCursorShowing( DWORD pPlayer ) +{ + if( RESOURCE ) + { + bool bShowing; + + if( CLuaFunctionDefinitions::IsCursorShowing( RESOURCE->GetLua(), (void*)pPlayer, bShowing ) ) + { + return bShowing; + } + } + + return false; +} + + +// Cursor set funcs +bool CMonoFunctions::Player::ShowCursor( DWORD pPlayer, bool bShow, bool bToggleControls ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ShowCursor( RESOURCE->GetLua(), (void*)pPlayer, bShow, bToggleControls ); + } + + return false; +} + + +// Chat funcs +bool CMonoFunctions::Player::ShowChat( DWORD pPlayer, bool bShow ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ShowChat( RESOURCE->GetLua(), (void*)pPlayer, bShow ); + } + + return false; +} + + +// Camera get functions +MonoObject* CMonoFunctions::Player::GetCameraMatrix( DWORD pPlayer ) +{ + if( RESOURCE ) + { + Vector3 vecPosition, vecLookAt; + + float fRoll, fFOV; + + if( CLuaFunctionDefinitions::GetCameraMatrix( RESOURCE->GetLua(), (void*)pPlayer, vecPosition, vecLookAt, fRoll, fFOV ) ) + { + void *args[] = + { + &vecPosition.fX, + &vecPosition.fY, + &vecPosition.fZ, + &vecLookAt.fX, + &vecLookAt.fY, + &vecLookAt.fZ, + &fRoll, + &fFOV + }; + + return RESOURCE->NewObject( "MultiTheftAuto", "CameraMatrix", args, 8 ); + } + } + + return NULL; +} + +DWORD CMonoFunctions::Player::GetCameraTarget( DWORD pPlayer ) +{ + if( RESOURCE ) + { + return (DWORD)CLuaFunctionDefinitions::GetCameraTarget( RESOURCE->GetLua(), (void*)pPlayer ); + } + + return false; +} + +unsigned char CMonoFunctions::Player::GetCameraInterior( DWORD pPlayer ) +{ + if( RESOURCE ) + { + unsigned char ucInterior; + + if( CLuaFunctionDefinitions::GetCameraInterior( RESOURCE->GetLua(), (void*)pPlayer, ucInterior ) ) + { + return ucInterior; + } + } + + return 0; +} + + +// Camera set functions +bool CMonoFunctions::Player::SetCameraMatrix( DWORD pPlayer, MonoObject* pCameraMatrix ) +{ + if( RESOURCE ) + { + float fX = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "Y" ); + float fZ = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "Z" ); + + Vector3 vecPosition( fX, fY, fZ ); + + float fLookAtX = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "LookAtX" ); + float fLookAtY = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "LookAtY" ); + float fLookAtZ = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "LookAtZ" ); + + Vector3 vecLookAt( fLookAtX, fLookAtY, fLookAtZ ); + + float fRoll = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "Roll" ); + float fFOV = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "FOV" ); + + return CLuaFunctionDefinitions::SetCameraMatrix( RESOURCE->GetLua(), (void*)pPlayer, vecPosition, vecLookAt, fRoll, fFOV ); + } + + return false; +} + +bool CMonoFunctions::Player::SetCameraTarget( DWORD pPlayer, DWORD pTarget ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetCameraTarget( RESOURCE->GetLua(), (void*)pPlayer, (void*)pTarget ); + } + + return false; +} + +bool CMonoFunctions::Player::SetCameraInterior( DWORD pPlayer, unsigned char ucInterior ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetCameraInterior( RESOURCE->GetLua(), (void*)pPlayer, ucInterior ); + } + + return false; +} + +bool CMonoFunctions::Player::FadeCamera( DWORD pPlayer, bool bFadeIn, float fFadeTime, MonoObject* pColor ) +{ + if( RESOURCE ) + { + unsigned char ucReed = CMonoObject::GetPropertyValue< unsigned char >( pColor, "R" ); + unsigned char ucGreen = CMonoObject::GetPropertyValue< unsigned char >( pColor, "G" ); + unsigned char ucBlue = CMonoObject::GetPropertyValue< unsigned char >( pColor, "B" ); + + return CLuaFunctionDefinitions::FadeCamera( RESOURCE->GetLua(), (void*)pPlayer, bFadeIn, fFadeTime, ucReed, ucGreen, ucBlue ); + } + + return false; +} + #endif \ No newline at end of file diff --git a/mta-mono/src/CMonoFunctions_RadarArea.cpp b/mta-mono/src/CMonoFunctions_RadarArea.cpp index 6f0bcb6..03ee380 100644 --- a/mta-mono/src/CMonoFunctions_RadarArea.cpp +++ b/mta-mono/src/CMonoFunctions_RadarArea.cpp @@ -1,166 +1,128 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Radar area create/destroy funcs +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Radar area create/destroy funcs DWORD CMonoFunctions::RadarArea::Create( MonoObject* pPosition, MonoObject* pSize, MonoObject* color, DWORD pVisibleTo ) { - if( RESOURCE ) - { - Vector2 vecPosition, vecSize; - - CMonoObject pPosition( pPosition ); - - vecPosition.fX = pPosition.GetPropertyValue< float >( "X" ); - vecPosition.fY = pPosition.GetPropertyValue< float >( "Y" ); - - CMonoObject pSize( pSize ); - - vecSize.fX = pSize.GetPropertyValue< float >( "X" ); - vecSize.fY = pSize.GetPropertyValue< float >( "Y" ); - - CMonoObject pMonoColor( color ); - - SColor pColor; - - pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" ); - pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" ); - pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" ); - pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" ); - - return (DWORD)CLuaFunctionDefinitions::CreateRadarArea( RESOURCE->GetLua(), vecPosition, vecSize, pColor, (void*)pVisibleTo ); - } - + if( RESOURCE ) + { + Vector2 vecPosition( pPosition ); + Vector2 vecSize( pSize ); + SColor pColor = CMonoObject::GetColor( color ); + + return (DWORD)CLuaFunctionDefinitions::CreateRadarArea( RESOURCE->GetLua(), vecPosition, vecSize, pColor, (void*)pVisibleTo ); + } + return NULL; } - - -// Radar area get funcs + + +// Radar area get funcs MonoObject* CMonoFunctions::RadarArea::GetSize( DWORD pUserData ) { - if( RESOURCE ) - { - Vector2 vecSize; - - if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecSize ); - - if( pObject ) - { - return pObject->GetObject(); - } - } + if( RESOURCE ) + { + Vector2 vecSize; + + if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) ) + { + return RESOURCE->NewObject( vecSize ); + } } return NULL; } - + MonoObject* CMonoFunctions::RadarArea::GetColor( DWORD pUserData ) { - if( RESOURCE ) - { - SColor outColor; - - if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( outColor ); - - if( pObject ) - { - return pObject->GetObject(); - } - } + if( RESOURCE ) + { + SColor outColor; + + if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) + { + return RESOURCE->NewObject( outColor ); + } } return NULL; } - + bool CMonoFunctions::RadarArea::IsFlashing( DWORD pUserData ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::IsRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::IsRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData ); } return false; } - + bool CMonoFunctions::RadarArea::IsInside( DWORD pUserData, MonoObject* pPosition ) { - if( RESOURCE ) - { - bool bInside; - - CMonoObject pPosition( pPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - - Vector2 vecPosition( fX, fY ); - - if( CLuaFunctionDefinitions::IsInsideRadarArea( RESOURCE->GetLua(), (void*)pUserData, vecPosition, bInside ) ) - { - return bInside; - } + if( RESOURCE ) + { + bool bInside; + + float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" ); + + Vector2 vecPosition( fX, fY ); + + if( CLuaFunctionDefinitions::IsInsideRadarArea( RESOURCE->GetLua(), (void*)pUserData, vecPosition, bInside ) ) + { + return bInside; + } } return false; } - - -// Radar area set funcs + + +// Radar area set funcs bool CMonoFunctions::RadarArea::SetSize( DWORD pUserData, MonoObject* pSize ) { - if( RESOURCE ) - { - CMonoObject pSize( pSize ); - - float fX = pSize.GetPropertyValue< float >( "X" ); - float fY = pSize.GetPropertyValue< float >( "Y" ); - - Vector2 vecPosition( fX, fY ); - - return CLuaFunctionDefinitions::SetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecPosition ); + if( RESOURCE ) + { + float fX = CMonoObject::GetPropertyValue< float >( pSize, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pSize, "Y" ); + + Vector2 vecPosition( fX, fY ); + + return CLuaFunctionDefinitions::SetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecPosition ); } return false; } - + bool CMonoFunctions::RadarArea::SetColor( DWORD pUserData, MonoObject* color ) { - if( RESOURCE ) - { - SColor pColor; - - CMonoObject pObject( color ); - - pColor.R = pObject.GetPropertyValue< unsigned char >( "R" ); - pColor.G = pObject.GetPropertyValue< unsigned char >( "G" ); - pColor.B = pObject.GetPropertyValue< unsigned char >( "B" ); - pColor.A = pObject.GetPropertyValue< unsigned char >( "A" ); - - return CLuaFunctionDefinitions::SetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, pColor ); + if( RESOURCE ) + { + SColor pColor = CMonoObject::GetColor( color ); + + return CLuaFunctionDefinitions::SetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, pColor ); } return false; } - + bool CMonoFunctions::RadarArea::SetFlashing( DWORD pUserData, bool bFlashing ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData, bFlashing ); + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData, bFlashing ); } return false; diff --git a/mta-mono/src/CMonoFunctions_Shape.cpp b/mta-mono/src/CMonoFunctions_Shape.cpp index d76277a..b986a9c 100644 --- a/mta-mono/src/CMonoFunctions_Shape.cpp +++ b/mta-mono/src/CMonoFunctions_Shape.cpp @@ -1,100 +1,98 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Shape create funcs +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Shape create funcs DWORD CMonoFunctions::Shape::CreateCircle( MonoObject* pPosition, float fRadius ) { - if( RESOURCE ) - { - Vector2 vecPosition = CMonoObject( pPosition ).GetVector2(); - - return (DWORD)CLuaFunctionDefinitions::CreateColCircle( RESOURCE->GetLua(), vecPosition, fRadius ); - } - + if( RESOURCE ) + { + Vector2 vecPosition( pPosition ); + + return (DWORD)CLuaFunctionDefinitions::CreateColCircle( RESOURCE->GetLua(), vecPosition, fRadius ); + } + return NULL; } - + DWORD CMonoFunctions::Shape::CreateCuboid( MonoObject* pPosition, MonoObject* pSize ) { - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - Vector3 vecSize = CMonoObject( pSize ).GetVector3(); - - return (DWORD)CLuaFunctionDefinitions::CreateColCuboid( RESOURCE->GetLua(), vecPosition, vecSize ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + Vector3 vecSize( pSize ); + + return (DWORD)CLuaFunctionDefinitions::CreateColCuboid( RESOURCE->GetLua(), vecPosition, vecSize ); + } + return NULL; } - + DWORD CMonoFunctions::Shape::CreateSphere( MonoObject* pPosition, float fRadius ) { - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - - return (DWORD)CLuaFunctionDefinitions::CreateColSphere( RESOURCE->GetLua(), vecPosition, fRadius ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + + return (DWORD)CLuaFunctionDefinitions::CreateColSphere( RESOURCE->GetLua(), vecPosition, fRadius ); + } + return NULL; } - + DWORD CMonoFunctions::Shape::CreateRectangle( MonoObject* pPosition, MonoObject* pSize ) { - if( RESOURCE ) - { - Vector2 vecPosition = CMonoObject( pPosition ).GetVector2(); - Vector2 vecSize = CMonoObject( pSize ).GetVector2(); - - return (DWORD)CLuaFunctionDefinitions::CreateColRectangle( RESOURCE->GetLua(), vecPosition, vecSize ); - } - + if( RESOURCE ) + { + Vector2 vecPosition( pPosition ); + Vector2 vecSize( pSize ); + + return (DWORD)CLuaFunctionDefinitions::CreateColRectangle( RESOURCE->GetLua(), vecPosition, vecSize ); + } + return NULL; } - + DWORD CMonoFunctions::Shape::CreatePolygon( MonoArray* pPointList ) { - if( RESOURCE ) - { - vector< Vector2 > vecPointList; - - for( unsigned int i = 0; i < mono_array_length( pPointList ); i++ ) - { - MonoObject* pObject = mono_array_get( pPointList, MonoObject*, i ); - - if( pObject ) - { - Vector2 vecPosition = CMonoObject( pObject ).GetVector2(); - - vecPointList.push_back( vecPosition ); - } - } - - return (DWORD)CLuaFunctionDefinitions::CreateColPolygon( RESOURCE->GetLua(), vecPointList ); - } - + if( RESOURCE ) + { + vector< Vector2 > vecPointList; + + for( unsigned int i = 0; i < mono_array_length( pPointList ); i++ ) + { + MonoObject* pObject = mono_array_get( pPointList, MonoObject*, i ); + + if( pObject ) + { + vecPointList.push_back( Vector2( pObject ) ); + } + } + + return (DWORD)CLuaFunctionDefinitions::CreateColPolygon( RESOURCE->GetLua(), vecPointList ); + } + return NULL; } - + DWORD CMonoFunctions::Shape::CreateTube( MonoObject* pPosition, float fRadius, float fHeight ) { - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - - return (DWORD)CLuaFunctionDefinitions::CreateColTube( RESOURCE->GetLua(), vecPosition, fRadius, fHeight ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + + return (DWORD)CLuaFunctionDefinitions::CreateColTube( RESOURCE->GetLua(), vecPosition, fRadius, fHeight ); + } + return NULL; } diff --git a/mta-mono/src/CMonoFunctions_Team.cpp b/mta-mono/src/CMonoFunctions_Team.cpp index ebdcfb6..d955e7a 100644 --- a/mta-mono/src/CMonoFunctions_Team.cpp +++ b/mta-mono/src/CMonoFunctions_Team.cpp @@ -1,140 +1,135 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Team get funcs -DWORD CMonoFunctions::Team::Create( MonoString* msTeamName, MonoObject* mColor ) -{ - if( RESOURCE ) - { - const char* szTeamName = mono_string_to_utf8( msTeamName ); - SColor pColor = CMonoObject( mColor ).GetColor(); - - return (DWORD)CLuaFunctionDefinitions::CreateTeam( RESOURCE->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B ); - } - - return NULL; -} - -DWORD CMonoFunctions::Team::GetFromName( MonoString* msTeamName ) -{ - if( RESOURCE ) - { - const char* szTeamName = mono_string_to_utf8( msTeamName ); - - return (DWORD)CLuaFunctionDefinitions::GetTeamFromName( RESOURCE->GetLua(), szTeamName ); - } - - return NULL; -} - -MonoString* CMonoFunctions::Team::GetName( DWORD pUserData ) -{ - if( RESOURCE ) - { - string strOutName; - - if( CLuaFunctionDefinitions::GetTeamName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) - { - return RESOURCE->NewString( strOutName ); - } - } - - return NULL; -} - -MonoObject* CMonoFunctions::Team::GetColor( DWORD pUserData ) -{ - if( RESOURCE ) - { - SColor pColor; - - if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( pColor ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - - return NULL; -} - -unsigned int CMonoFunctions::Team::CountPlayers( DWORD pUserData ) -{ - if( RESOURCE ) - { - unsigned int uiCount; - - if( CLuaFunctionDefinitions::CountPlayersInTeam( RESOURCE->GetLua(), (void*)pUserData, uiCount ) ) - { - return uiCount; - } - } - - return 0; -} - -bool CMonoFunctions::Team::GetFriendlyFire( DWORD pUserData ) -{ - if( RESOURCE ) - { - bool bFriendlyFire; - - if( CLuaFunctionDefinitions::GetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire ) ) - { - return bFriendlyFire; - } - } - - return false; -} - - -// Team set funcs -bool CMonoFunctions::Team::SetName( DWORD pUserData, MonoString* msTeamName ) -{ - if( RESOURCE ) - { - const char* szTeamName = mono_string_to_utf8( msTeamName ); - - return CLuaFunctionDefinitions::SetTeamName( RESOURCE->GetLua(), (void*)pUserData, szTeamName ); - } - - return false; -} - -bool CMonoFunctions::Team::SetColor( DWORD pUserData, MonoObject* mColor ) -{ - if( RESOURCE ) - { - SColor pColor = CMonoObject( mColor ).GetColor(); - - return CLuaFunctionDefinitions::SetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ); - } - - return false; -} - -bool CMonoFunctions::Team::SetFriendlyFire( DWORD pUserData, bool bFriendlyFire ) -{ - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire ); - } - - return false; -} +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Team get funcs +DWORD CMonoFunctions::Team::Create( MonoString* msTeamName, MonoObject* mColor ) +{ + if( RESOURCE ) + { + const char* szTeamName = mono_string_to_utf8( msTeamName ); + SColor pColor = CMonoObject::GetColor( mColor ); + + return (DWORD)CLuaFunctionDefinitions::CreateTeam( RESOURCE->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B ); + } + + return NULL; +} + +DWORD CMonoFunctions::Team::GetFromName( MonoString* msTeamName ) +{ + if( RESOURCE ) + { + const char* szTeamName = mono_string_to_utf8( msTeamName ); + + return (DWORD)CLuaFunctionDefinitions::GetTeamFromName( RESOURCE->GetLua(), szTeamName ); + } + + return NULL; +} + +MonoString* CMonoFunctions::Team::GetName( DWORD pUserData ) +{ + if( RESOURCE ) + { + string strOutName; + + if( CLuaFunctionDefinitions::GetTeamName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) + { + return RESOURCE->NewString( strOutName ); + } + } + + return NULL; +} + +MonoObject* CMonoFunctions::Team::GetColor( DWORD pUserData ) +{ + if( RESOURCE ) + { + SColor pColor; + + if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) ) + { + return RESOURCE->NewObject( pColor ); + } + } + + return NULL; +} + +unsigned int CMonoFunctions::Team::CountPlayers( DWORD pUserData ) +{ + if( RESOURCE ) + { + unsigned int uiCount; + + if( CLuaFunctionDefinitions::CountPlayersInTeam( RESOURCE->GetLua(), (void*)pUserData, uiCount ) ) + { + return uiCount; + } + } + + return 0; +} + +bool CMonoFunctions::Team::GetFriendlyFire( DWORD pUserData ) +{ + if( RESOURCE ) + { + bool bFriendlyFire; + + if( CLuaFunctionDefinitions::GetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire ) ) + { + return bFriendlyFire; + } + } + + return false; +} + + +// Team set funcs +bool CMonoFunctions::Team::SetName( DWORD pUserData, MonoString* msTeamName ) +{ + if( RESOURCE ) + { + const char* szTeamName = mono_string_to_utf8( msTeamName ); + + return CLuaFunctionDefinitions::SetTeamName( RESOURCE->GetLua(), (void*)pUserData, szTeamName ); + } + + return false; +} + +bool CMonoFunctions::Team::SetColor( DWORD pUserData, MonoObject* mColor ) +{ + if( RESOURCE ) + { + SColor pColor = CMonoObject::GetColor( mColor ); + + return CLuaFunctionDefinitions::SetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ); + } + + return false; +} + +bool CMonoFunctions::Team::SetFriendlyFire( DWORD pUserData, bool bFriendlyFire ) +{ + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire ); + } + + return false; +} diff --git a/mta-mono/src/CMonoFunctions_Vehicle.cpp b/mta-mono/src/CMonoFunctions_Vehicle.cpp index 086e586..62b8370 100644 --- a/mta-mono/src/CMonoFunctions_Vehicle.cpp +++ b/mta-mono/src/CMonoFunctions_Vehicle.cpp @@ -1,132 +1,123 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Vehicle create/destroy functions -DWORD CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction, int variant1, int variant2 ) -{ - if( RESOURCE ) - { - CMonoObject pPosition( position ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - CMonoObject pRotation( rotation ); - - float fRX = pRotation.GetPropertyValue< float >( "X" ); - float fRY = pRotation.GetPropertyValue< float >( "Y" ); - float fRZ = pRotation.GetPropertyValue< float >( "Z" ); - - string sNumberplate = ""; - - if( numberplate && mono_string_length( numberplate ) > 0 ) - { - sNumberplate = string( mono_string_to_utf8( numberplate ) ); - } - - return (DWORD)CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, sNumberplate, direction, variant1, variant2 ); - } - - return NULL; -} - +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Vehicle create/destroy functions +DWORD CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction, int variant1, int variant2 ) +{ + if( RESOURCE ) + { + float fX = CMonoObject::GetPropertyValue< float >( position, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( position, "Y" ); + float fZ = CMonoObject::GetPropertyValue< float >( position, "Z" ); + + float fRX = CMonoObject::GetPropertyValue< float >( rotation, "X" ); + float fRY = CMonoObject::GetPropertyValue< float >( rotation, "Y" ); + float fRZ = CMonoObject::GetPropertyValue< float >( rotation, "Z" ); + + string sNumberplate = ""; + + if( numberplate && mono_string_length( numberplate ) > 0 ) + { + sNumberplate = string( mono_string_to_utf8( numberplate ) ); + } + + return (DWORD)CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, sNumberplate, direction, variant1, variant2 ); + } + + return NULL; +} + // Vehicle get functions MonoString* CMonoFunctions::Vehicle::GetType( DWORD pUserData ) { - if( RESOURCE ) - { - string strType; - - if( CLuaFunctionDefinitions::GetVehicleType( RESOURCE->GetLua(), (void*)pUserData, strType ) ) - { - return RESOURCE->NewString( strType ); - } - } - + if( RESOURCE ) + { + string strType; + + if( CLuaFunctionDefinitions::GetVehicleType( RESOURCE->GetLua(), (void*)pUserData, strType ) ) + { + return RESOURCE->NewString( strType ); + } + } + return NULL; } MonoArray* CMonoFunctions::Vehicle::GetVariant( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned char ucVariant; - unsigned char ucVariant2; - - if( CLuaFunctionDefinitions::GetVehicleVariant( RESOURCE->GetLua(), (void*)pUserData, ucVariant, ucVariant2 ) ) - { - MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 ); - - if( pArray ) - { - mono_array_set( pArray, unsigned char, 0, ucVariant ); - mono_array_set( pArray, unsigned char, 1, ucVariant2 ); - - return pArray; - } - } - } - + if( RESOURCE ) + { + unsigned char ucVariant; + unsigned char ucVariant2; + + if( CLuaFunctionDefinitions::GetVehicleVariant( RESOURCE->GetLua(), (void*)pUserData, ucVariant, ucVariant2 ) ) + { + MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 ); + + if( pArray ) + { + mono_array_set( pArray, unsigned char, 0, ucVariant ); + mono_array_set( pArray, unsigned char, 1, ucVariant2 ); + + return pArray; + } + } + } + return NULL; } MonoObject* CMonoFunctions::Vehicle::GetColor( DWORD pUserData ) { - if( RESOURCE ) - { - CVehicleColor pColor; - - if( CLuaFunctionDefinitions::GetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, pColor ) ) - { - SColor pColor1 = pColor.GetRGBColor( 0 ); - SColor pColor2 = pColor.GetRGBColor( 1 ); - SColor pColor3 = pColor.GetRGBColor( 2 ); - SColor pColor4 = pColor.GetRGBColor( 3 ); - - void* args[] = - { - &pColor1, - &pColor2, - &pColor3, - &pColor4 - }; - - CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "VehicleColor", args, 4 ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - + if( RESOURCE ) + { + CVehicleColor pColor; + + if( CLuaFunctionDefinitions::GetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, pColor ) ) + { + SColor pColor1 = pColor.GetRGBColor( 0 ); + SColor pColor2 = pColor.GetRGBColor( 1 ); + SColor pColor3 = pColor.GetRGBColor( 2 ); + SColor pColor4 = pColor.GetRGBColor( 3 ); + + void* args[] = + { + &pColor1, + &pColor2, + &pColor3, + &pColor4 + }; + + return RESOURCE->NewObject( "MultiTheftAuto", "VehicleColor", args, 4 ); + } + } + return NULL; } unsigned short CMonoFunctions::Vehicle::GetModelFromName( MonoString* msName ) { - if( RESOURCE ) - { - const char* szName = mono_string_to_utf8( msName ); - - unsigned short usModel; - - if( CLuaFunctionDefinitions::GetVehicleModelFromName( RESOURCE->GetLua(), szName, usModel ) ) - { - return usModel; - } + if( RESOURCE ) + { + const char* szName = mono_string_to_utf8( msName ); + + unsigned short usModel; + + if( CLuaFunctionDefinitions::GetVehicleModelFromName( RESOURCE->GetLua(), szName, usModel ) ) + { + return usModel; + } } return 0; @@ -134,14 +125,14 @@ unsigned short CMonoFunctions::Vehicle::GetModelFromName( MonoString* msName ) bool CMonoFunctions::Vehicle::GetLandingGearDown( DWORD pUserData ) { - if( RESOURCE ) - { - bool bGearDown; - - if( CLuaFunctionDefinitions::GetVehicleLandingGearDown( RESOURCE->GetLua(), (void*)pUserData, bGearDown ) ) - { - return bGearDown; - } + if( RESOURCE ) + { + bool bGearDown; + + if( CLuaFunctionDefinitions::GetVehicleLandingGearDown( RESOURCE->GetLua(), (void*)pUserData, bGearDown ) ) + { + return bGearDown; + } } return false; @@ -149,14 +140,14 @@ bool CMonoFunctions::Vehicle::GetLandingGearDown( DWORD pUserData ) unsigned char CMonoFunctions::Vehicle::GetMaxPassengers( DWORD pUserData ) { - if( RESOURCE ) - { - unsigned char ucPassengers; - - if( CLuaFunctionDefinitions::GetVehicleMaxPassengers( RESOURCE->GetLua(), (void*)pUserData, ucPassengers ) ) - { - return ucPassengers; - } + if( RESOURCE ) + { + unsigned char ucPassengers; + + if( CLuaFunctionDefinitions::GetVehicleMaxPassengers( RESOURCE->GetLua(), (void*)pUserData, ucPassengers ) ) + { + return ucPassengers; + } } return 0; @@ -164,14 +155,14 @@ unsigned char CMonoFunctions::Vehicle::GetMaxPassengers( DWORD pUserData ) MonoString* CMonoFunctions::Vehicle::GetName( DWORD pUserData ) { - if( RESOURCE ) - { - string strOutName; - - if( CLuaFunctionDefinitions::GetVehicleName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) - { - return RESOURCE->NewString( strOutName ); - } + if( RESOURCE ) + { + string strOutName; + + if( CLuaFunctionDefinitions::GetVehicleName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) + { + return RESOURCE->NewString( strOutName ); + } } return NULL; @@ -179,14 +170,14 @@ MonoString* CMonoFunctions::Vehicle::GetName( DWORD pUserData ) MonoString* CMonoFunctions::Vehicle::GetNameFromModel( unsigned short usModel ) { - if( RESOURCE ) - { - string strOutName; - - if( CLuaFunctionDefinitions::GetVehicleNameFromModel( RESOURCE->GetLua(), usModel, strOutName ) ) - { - return RESOURCE->NewString( strOutName ); - } + if( RESOURCE ) + { + string strOutName; + + if( CLuaFunctionDefinitions::GetVehicleNameFromModel( RESOURCE->GetLua(), usModel, strOutName ) ) + { + return RESOURCE->NewString( strOutName ); + } } return NULL; @@ -247,12 +238,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurnVelocity( DWORD pUserData ) if( CLuaFunctionDefinitions::GetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, vecVelocity ) ) { - CMonoObject* pObject = RESOURCE->NewObject( vecVelocity ); - - if( pObject ) - { - return pObject->GetObject(); - } + return RESOURCE->NewObject( vecVelocity ); } } @@ -267,12 +253,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurretPosition( DWORD pUserData ) if( CLuaFunctionDefinitions::GetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) { - CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); - - if( pObject ) - { - return pObject->GetObject(); - } + return RESOURCE->NewObject( vecPosition ); } } @@ -335,14 +316,14 @@ MonoArray* CMonoFunctions::Vehicle::GetUpgrades( DWORD pUserData ) MonoString* CMonoFunctions::Vehicle::GetUpgradeSlotName( unsigned short usUpgrade ) { - if( RESOURCE ) - { - string strOutName; - - if( CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( RESOURCE->GetLua(), usUpgrade, strOutName ) ) - { - return RESOURCE->NewString( strOutName ); - } + if( RESOURCE ) + { + string strOutName; + + if( CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( RESOURCE->GetLua(), usUpgrade, strOutName ) ) + { + return RESOURCE->NewString( strOutName ); + } } return NULL; @@ -388,12 +369,7 @@ MonoObject* CMonoFunctions::Vehicle::GetWheelStates( DWORD pUserData ) &ucFrontLeft, &ucRearLeft, &ucFrontRight, &ucRearRight }; - CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto.Vehicle", "VehicleWheelsState", args, 4 ); - - if( pObject ) - { - return pObject->GetObject(); - } + return RESOURCE->NewObject( "MultiTheftAuto.Vehicle", "VehicleWheelsState", args, 4 ); } } @@ -482,14 +458,14 @@ unsigned char CMonoFunctions::Vehicle::GetPaintjob( DWORD pUserData ) MonoString* CMonoFunctions::Vehicle::GetPlateText( DWORD pUserData ) { - if( RESOURCE ) - { - char* szPlateText = NULL; - - if( CLuaFunctionDefinitions::GetVehiclePlateText( RESOURCE->GetLua(), (void*)pUserData, szPlateText ) ) - { - return RESOURCE->NewString( szPlateText ); - } + if( RESOURCE ) + { + char* szPlateText = NULL; + + if( CLuaFunctionDefinitions::GetVehiclePlateText( RESOURCE->GetLua(), (void*)pUserData, szPlateText ) ) + { + return RESOURCE->NewString( szPlateText ); + } } return NULL; @@ -648,12 +624,7 @@ MonoObject* CMonoFunctions::Vehicle::GetHeadLightColor( DWORD pUserData ) if( CLuaFunctionDefinitions::GetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) { - CMonoObject* pMonoObject = RESOURCE->NewObject( outColor ); - - if( pMonoObject ) - { - return pMonoObject->GetObject(); - } + return RESOURCE->NewObject( outColor ); } } @@ -716,11 +687,9 @@ bool CMonoFunctions::Vehicle::SetTurnVelocity( DWORD pUserData, MonoObject* pVel { if( RESOURCE ) { - CMonoObject pVelocity( pVelocity ); - - float fX = pVelocity.GetPropertyValue< float >( "X" ); - float fY = pVelocity.GetPropertyValue< float >( "Y" ); - float fZ = pVelocity.GetPropertyValue< float >( "Z" ); + float fX = CMonoObject::GetPropertyValue< float >( pVelocity, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pVelocity, "Y" ); + float fZ = CMonoObject::GetPropertyValue< float >( pVelocity, "Z" ); return CLuaFunctionDefinitions::SetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ ); } @@ -732,29 +701,21 @@ bool CMonoFunctions::Vehicle::SetColor( DWORD pUserData, MonoObject* pColor1, Mo { if( RESOURCE ) { - CMonoObject pColor1( pColor1 ); + unsigned char ucR1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "R" ); + unsigned char ucG1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "G" ); + unsigned char ucB1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "B" ); - unsigned char ucR1 = pColor1.GetPropertyValue< unsigned char >( "R" ); - unsigned char ucG1 = pColor1.GetPropertyValue< unsigned char >( "G" ); - unsigned char ucB1 = pColor1.GetPropertyValue< unsigned char >( "B" ); + unsigned char ucR2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "R" ); + unsigned char ucG2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "G" ); + unsigned char ucB2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "B" ); - CMonoObject pColor2( pColor2 ); + unsigned char ucR3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "R" ); + unsigned char ucG3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "G" ); + unsigned char ucB3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "B" ); - unsigned char ucR2 = pColor2.GetPropertyValue< unsigned char >( "R" ); - unsigned char ucG2 = pColor2.GetPropertyValue< unsigned char >( "G" ); - unsigned char ucB2 = pColor2.GetPropertyValue< unsigned char >( "B" ); - - CMonoObject pColor3( pColor3 ); - - unsigned char ucR3 = pColor3.GetPropertyValue< unsigned char >( "R" ); - unsigned char ucG3 = pColor3.GetPropertyValue< unsigned char >( "G" ); - unsigned char ucB3 = pColor3.GetPropertyValue< unsigned char >( "B" ); - - CMonoObject pColor4( pColor4 ); - - unsigned char ucR4 = pColor4.GetPropertyValue< unsigned char >( "R" ); - unsigned char ucG4 = pColor4.GetPropertyValue< unsigned char >( "G" ); - unsigned char ucB4 = pColor4.GetPropertyValue< unsigned char >( "B" ); + unsigned char ucR4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "R" ); + unsigned char ucG4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "G" ); + unsigned char ucB4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "B" ); return CLuaFunctionDefinitions::SetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1, ucR2, ucG2, ucB2, ucR3, ucG3, ucB3, ucR4, ucG4, ucB4 ); } @@ -896,17 +857,13 @@ bool CMonoFunctions::Vehicle::SetRespawnPosition( DWORD pUserData, MonoObject* p { if( RESOURCE ) { - CMonoObject pPosition( pPosition ); + float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" ); + float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" ); - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "X" ); - float fZ = pPosition.GetPropertyValue< float >( "X" ); - - CMonoObject pRotation( pRotation ); - - float fRX = pRotation.GetPropertyValue< float >( "X" ); - float fRY = pRotation.GetPropertyValue< float >( "X" ); - float fRZ = pRotation.GetPropertyValue< float >( "X" ); + float fRX = CMonoObject::GetPropertyValue< float >( pRotation, "X" ); + float fRY = CMonoObject::GetPropertyValue< float >( pRotation, "Y" ); + float fRZ = CMonoObject::GetPropertyValue< float >( pRotation, "Z" ); return CLuaFunctionDefinitions::SetVehicleRespawnPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ ); } @@ -948,17 +905,13 @@ bool CMonoFunctions::Vehicle::Spawn( DWORD pUserData, MonoObject* pPosition, Mon { if( RESOURCE ) { - CMonoObject pPosition( pPosition ); + float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" ); + float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" ); - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "X" ); - float fZ = pPosition.GetPropertyValue< float >( "X" ); - - CMonoObject pRotation( pRotation ); - - float fRX = pRotation.GetPropertyValue< float >( "X" ); - float fRY = pRotation.GetPropertyValue< float >( "X" ); - float fRZ = pRotation.GetPropertyValue< float >( "X" ); + float fRX = CMonoObject::GetPropertyValue< float >( pRotation, "X" ); + float fRY = CMonoObject::GetPropertyValue< float >( pRotation, "Y" ); + float fRZ = CMonoObject::GetPropertyValue< float >( pRotation, "Z" ); return CLuaFunctionDefinitions::SpawnVehicle( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ ); } @@ -1100,11 +1053,9 @@ bool CMonoFunctions::Vehicle::SetHeadLightColor( DWORD pUserData, MonoObject* pC { if( RESOURCE ) { - CMonoObject pColor1( pColor ); - - unsigned char ucR1 = pColor1.GetPropertyValue< unsigned char >( "R" ); - unsigned char ucG1 = pColor1.GetPropertyValue< unsigned char >( "G" ); - unsigned char ucB1 = pColor1.GetPropertyValue< unsigned char >( "B" ); + unsigned char ucR1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "R" ); + unsigned char ucG1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "G" ); + unsigned char ucB1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "B" ); return CLuaFunctionDefinitions::SetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1 ); } @@ -1116,10 +1067,8 @@ bool CMonoFunctions::Vehicle::SetTurretPosition( DWORD pUserData, MonoObject* pP { if( RESOURCE ) { - CMonoObject pPosition( pPosition ); - - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); + float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" ); return CLuaFunctionDefinitions::SetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY ); } @@ -1171,18 +1120,14 @@ bool CMonoFunctions::Vehicle::SetSirens( DWORD pUserData, unsigned char ucSirenI { if( RESOURCE ) { - CMonoObject pPosition( pPosition ); + float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" ); + float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" ); + float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" ); - float fX = pPosition.GetPropertyValue< float >( "X" ); - float fY = pPosition.GetPropertyValue< float >( "Y" ); - float fZ = pPosition.GetPropertyValue< float >( "Z" ); - - CMonoObject pColor( pColor ); - - float fRed = pColor.GetPropertyValue< float >( "R" ); - float fGreen = pColor.GetPropertyValue< float >( "G" ); - float fBlue = pColor.GetPropertyValue< float >( "B" ); - float fAlpha = pColor.GetPropertyValue< float >( "A" ); + float fRed = CMonoObject::GetPropertyValue< float >( pColor, "R" ); + float fGreen = CMonoObject::GetPropertyValue< float >( pColor, "G" ); + float fBlue = CMonoObject::GetPropertyValue< float >( pColor, "B" ); + float fAlpha = CMonoObject::GetPropertyValue< float >( pColor, "A" ); return CLuaFunctionDefinitions::SetVehicleSirens( RESOURCE->GetLua(), (void*)pUserData, ucSirenID, fX, fY, fZ, fRed, fGreen, fBlue, fAlpha, fMinAlpha ); } diff --git a/mta-mono/src/CMonoFunctions_Water.cpp b/mta-mono/src/CMonoFunctions_Water.cpp index 529bdc2..7cf1545 100644 --- a/mta-mono/src/CMonoFunctions_Water.cpp +++ b/mta-mono/src/CMonoFunctions_Water.cpp @@ -1,137 +1,133 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// Water funcs +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// Water funcs DWORD CMonoFunctions::Water::Create( MonoObject* pV1, MonoObject* pV2, MonoObject* pV3, MonoObject* pV4, bool bShallow ) { - if( RESOURCE ) - { - Vector3* vec1 = &CMonoObject( pV1 ).GetVector3(); - Vector3* vec2 = &CMonoObject( pV2 ).GetVector3(); - Vector3* vec3 = &CMonoObject( pV3 ).GetVector3(); - Vector3* vec4 = pV4 ? &CMonoObject( pV4 ).GetVector3() : NULL; - - return (DWORD)CLuaFunctionDefinitions::CreateWater( RESOURCE->GetLua(), vec1, vec2, vec3, vec4, bShallow ); - } - + if( RESOURCE ) + { + Vector3 vec1( pV1 ); + Vector3 vec2( pV2 ); + Vector3 vec3( pV3 ); + Vector3 vec4 = pV4 ? Vector3( pV4 ) : NULL; + + return (DWORD)CLuaFunctionDefinitions::CreateWater( RESOURCE->GetLua(), &vec1, &vec2, &vec3, &vec4, bShallow ); + } + return NULL; } - + bool CMonoFunctions::Water::SetLevel( DWORD pUserData, float fLevel ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetElementWaterLevel( RESOURCE->GetLua(), (void*)pUserData, fLevel ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetElementWaterLevel( RESOURCE->GetLua(), (void*)pUserData, fLevel ); + } + return false; } - + bool CMonoFunctions::Water::SetLevelAll( float fLevel ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetAllElementWaterLevel( RESOURCE->GetLua(), fLevel ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetAllElementWaterLevel( RESOURCE->GetLua(), fLevel ); + } + return false; } - + bool CMonoFunctions::Water::SetLevelWorld( float fLevel, bool bIncludeWorldNonSeaLevel ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetWorldWaterLevel( RESOURCE->GetLua(), fLevel, bIncludeWorldNonSeaLevel ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetWorldWaterLevel( RESOURCE->GetLua(), fLevel, bIncludeWorldNonSeaLevel ); + } + return false; } - + bool CMonoFunctions::Water::ResetLevelWorld( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetWorldWaterLevel( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetWorldWaterLevel( RESOURCE->GetLua() ); + } + return false; } - + MonoObject* CMonoFunctions::Water::GetVertexPosition( DWORD pUserData, int iVertexIndex ) { - if( RESOURCE ) - { - Vector3 vecPosition; - - if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); - - return pObject ? pObject->GetObject() : NULL; - } - } - + if( RESOURCE ) + { + Vector3 vecPosition; + + if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) ) + { + return RESOURCE->NewObject( vecPosition ); + } + } + return NULL; } - + bool CMonoFunctions::Water::SetVertexPosition( DWORD pUserData, int iVertexIndex, MonoObject* mPosition ) { - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( mPosition ).GetVector3(); - - return CLuaFunctionDefinitions::SetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( mPosition ); + + return CLuaFunctionDefinitions::SetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ); + } + return false; } - + MonoObject* CMonoFunctions::Water::GetColor( void ) { - if( RESOURCE ) - { - SColor pColor; - - if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( pColor ); - - return pObject ? pObject->GetObject() : NULL; - } - } - + if( RESOURCE ) + { + SColor pColor; + + if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) ) + { + return RESOURCE->NewObject( pColor ); + } + } + return NULL; } - + bool CMonoFunctions::Water::SetColor( MonoObject* mColor ) { - if( RESOURCE ) - { - SColor pColor = CMonoObject( mColor ).GetColor(); - - return CLuaFunctionDefinitions::SetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ); - } - + if( RESOURCE ) + { + SColor pColor = CMonoObject::GetColor( mColor ); + + return CLuaFunctionDefinitions::SetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ); + } + return false; } - + bool CMonoFunctions::Water::ResetColor( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetWaterColor( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetWaterColor( RESOURCE->GetLua() ); + } + return false; } diff --git a/mta-mono/src/CMonoFunctions_World.cpp b/mta-mono/src/CMonoFunctions_World.cpp index 23bb9cf..e4be1fc 100644 --- a/mta-mono/src/CMonoFunctions_World.cpp +++ b/mta-mono/src/CMonoFunctions_World.cpp @@ -1,904 +1,892 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CMonoFunctions.h" - -// General world get funcs +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CMonoFunctions.h" + +// General world get funcs MonoArray* CMonoFunctions::World::GetTime( void ) { - if( RESOURCE ) - { - unsigned char ucHour, ucMinute; - - if( CLuaFunctionDefinitions::GetTime( RESOURCE->GetLua(), ucHour, ucMinute ) ) - { - MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 ); - - mono_array_set( pArray, unsigned char, 0, ucHour ); - mono_array_set( pArray, unsigned char, 1, ucMinute ); - - return pArray; - } - } - + if( RESOURCE ) + { + unsigned char ucHour, ucMinute; + + if( CLuaFunctionDefinitions::GetTime( RESOURCE->GetLua(), ucHour, ucMinute ) ) + { + MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 ); + + mono_array_set( pArray, unsigned char, 0, ucHour ); + mono_array_set( pArray, unsigned char, 1, ucMinute ); + + return pArray; + } + } + return NULL; } - + MonoArray* CMonoFunctions::World::GetWeather( void ) { - if( RESOURCE ) - { - unsigned char ucWeather, ucWeatherBlending; - - if( CLuaFunctionDefinitions::GetWeather( RESOURCE->GetLua(), ucWeather, ucWeatherBlending ) ) - { - MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 ); - - mono_array_set( pArray, unsigned char, 0, ucWeather ); - mono_array_set( pArray, unsigned char, 1, ucWeatherBlending ); - - return pArray; - } - } - + if( RESOURCE ) + { + unsigned char ucWeather, ucWeatherBlending; + + if( CLuaFunctionDefinitions::GetWeather( RESOURCE->GetLua(), ucWeather, ucWeatherBlending ) ) + { + MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 ); + + mono_array_set( pArray, unsigned char, 0, ucWeather ); + mono_array_set( pArray, unsigned char, 1, ucWeatherBlending ); + + return pArray; + } + } + return NULL; } - + MonoString* CMonoFunctions::World::GetZoneName( MonoObject* mPosition, bool bCitiesOnly ) { - if( RESOURCE ) - { - string strOutName; - - Vector3 vecPosition = CMonoObject( mPosition ).GetVector3(); - - if( CLuaFunctionDefinitions::GetZoneName( RESOURCE->GetLua(), vecPosition, strOutName, bCitiesOnly ) ) - { - return RESOURCE->NewString( strOutName ); - } - } - + if( RESOURCE ) + { + string strOutName; + + Vector3 vecPosition( mPosition ); + + if( CLuaFunctionDefinitions::GetZoneName( RESOURCE->GetLua(), vecPosition, strOutName, bCitiesOnly ) ) + { + return RESOURCE->NewString( strOutName ); + } + } + return NULL; } - + float CMonoFunctions::World::GetGravity( void ) { - if( RESOURCE ) - { - float fGravity; - - if( CLuaFunctionDefinitions::GetGravity( RESOURCE->GetLua(), fGravity ) ) - { - return fGravity; - } - } - + if( RESOURCE ) + { + float fGravity; + + if( CLuaFunctionDefinitions::GetGravity( RESOURCE->GetLua(), fGravity ) ) + { + return fGravity; + } + } + return 0.0f; } - + float CMonoFunctions::World::GetGameSpeed( void ) { - if( RESOURCE ) - { - float fGameSpeed; - - if( CLuaFunctionDefinitions::GetGameSpeed( RESOURCE->GetLua(), fGameSpeed ) ) - { - return fGameSpeed; - } - } - + if( RESOURCE ) + { + float fGameSpeed; + + if( CLuaFunctionDefinitions::GetGameSpeed( RESOURCE->GetLua(), fGameSpeed ) ) + { + return fGameSpeed; + } + } + return 0.0f; } - + float CMonoFunctions::World::GetWaveHeight( void ) { - if( RESOURCE ) - { - float fHeight; - - if( CLuaFunctionDefinitions::GetWaveHeight( RESOURCE->GetLua(), fHeight ) ) - { - return fHeight; - } - } - + if( RESOURCE ) + { + float fHeight; + + if( CLuaFunctionDefinitions::GetWaveHeight( RESOURCE->GetLua(), fHeight ) ) + { + return fHeight; + } + } + return 0.0f; } - + unsigned short CMonoFunctions::World::GetFPSLimit( void ) { - if( RESOURCE ) - { - unsigned short usLimit; - - if( CLuaFunctionDefinitions::GetFPSLimit( RESOURCE->GetLua(), usLimit ) ) - { - return usLimit; - } - } - + if( RESOURCE ) + { + unsigned short usLimit; + + if( CLuaFunctionDefinitions::GetFPSLimit( RESOURCE->GetLua(), usLimit ) ) + { + return usLimit; + } + } + return 0; } - + unsigned long CMonoFunctions::World::GetMinuteDuration( void ) { - if( RESOURCE ) - { - unsigned long usDuration; - - if( CLuaFunctionDefinitions::GetMinuteDuration( RESOURCE->GetLua(), usDuration ) ) - { - return usDuration; - } - } - + if( RESOURCE ) + { + unsigned long usDuration; + + if( CLuaFunctionDefinitions::GetMinuteDuration( RESOURCE->GetLua(), usDuration ) ) + { + return usDuration; + } + } + return 0; } - + bool CMonoFunctions::World::IsGarageOpen( unsigned char ucGarageID ) { - if( RESOURCE ) - { - bool bIsOpen; - - if( CLuaFunctionDefinitions::IsGarageOpen( RESOURCE->GetLua(), ucGarageID, bIsOpen ) ) - { - return bIsOpen; - } - } - + if( RESOURCE ) + { + bool bIsOpen; + + if( CLuaFunctionDefinitions::IsGarageOpen( RESOURCE->GetLua(), ucGarageID, bIsOpen ) ) + { + return bIsOpen; + } + } + return false; } - + unsigned char CMonoFunctions::World::GetTrafficLightState( void ) { - if( RESOURCE ) - { - unsigned char ucState; - - if( CLuaFunctionDefinitions::GetTrafficLightState( RESOURCE->GetLua(), ucState ) ) - { - return ucState; - } - } - + if( RESOURCE ) + { + unsigned char ucState; + + if( CLuaFunctionDefinitions::GetTrafficLightState( RESOURCE->GetLua(), ucState ) ) + { + return ucState; + } + } + return 0; } - + bool CMonoFunctions::World::GetTrafficLightsLocked( void ) { - if( RESOURCE ) - { - bool bIsLocked; - - if( CLuaFunctionDefinitions::GetTrafficLightsLocked( RESOURCE->GetLua(), bIsLocked ) ) - { - return bIsLocked; - } - } - + if( RESOURCE ) + { + bool bIsLocked; + + if( CLuaFunctionDefinitions::GetTrafficLightsLocked( RESOURCE->GetLua(), bIsLocked ) ) + { + return bIsLocked; + } + } + return false; } - + float CMonoFunctions::World::GetJetpackMaxHeight( void ) { - if( RESOURCE ) - { - float fHeight; - - if( CLuaFunctionDefinitions::GetJetpackMaxHeight( RESOURCE->GetLua(), fHeight ) ) - { - return fHeight; - } - } - + if( RESOURCE ) + { + float fHeight; + + if( CLuaFunctionDefinitions::GetJetpackMaxHeight( RESOURCE->GetLua(), fHeight ) ) + { + return fHeight; + } + } + return 0.0f; } - + float CMonoFunctions::World::GetAircraftMaxVelocity( void ) { - if( RESOURCE ) - { - float fVelocity; - - if( CLuaFunctionDefinitions::GetAircraftMaxVelocity( RESOURCE->GetLua(), fVelocity ) ) - { - return fVelocity; - } - } - + if( RESOURCE ) + { + float fVelocity; + + if( CLuaFunctionDefinitions::GetAircraftMaxVelocity( RESOURCE->GetLua(), fVelocity ) ) + { + return fVelocity; + } + } + return 0.0f; } - + bool CMonoFunctions::World::GetInteriorSoundsEnabled( void ) { - if( RESOURCE ) - { - bool bEnabled; - - if( CLuaFunctionDefinitions::GetInteriorSoundsEnabled( RESOURCE->GetLua(), bEnabled ) ) - { - return bEnabled; - } - } - + if( RESOURCE ) + { + bool bEnabled; + + if( CLuaFunctionDefinitions::GetInteriorSoundsEnabled( RESOURCE->GetLua(), bEnabled ) ) + { + return bEnabled; + } + } + return false; } - + float CMonoFunctions::World::GetRainLevel( void ) { - if( RESOURCE ) - { - float fRainLevel; - - if( CLuaFunctionDefinitions::GetRainLevel( RESOURCE->GetLua(), fRainLevel ) ) - { - return fRainLevel; - } - } - + if( RESOURCE ) + { + float fRainLevel; + + if( CLuaFunctionDefinitions::GetRainLevel( RESOURCE->GetLua(), fRainLevel ) ) + { + return fRainLevel; + } + } + return 0.0f; } - + float CMonoFunctions::World::GetSunSize( void ) { - if( RESOURCE ) - { - float fSunSize; - - if( CLuaFunctionDefinitions::GetSunSize( RESOURCE->GetLua(), fSunSize ) ) - { - return fSunSize; - } - } - + if( RESOURCE ) + { + float fSunSize; + + if( CLuaFunctionDefinitions::GetSunSize( RESOURCE->GetLua(), fSunSize ) ) + { + return fSunSize; + } + } + return 0.0f; } - + MonoArray* CMonoFunctions::World::GetSunColor( void ) { - if( RESOURCE ) - { - SColor pCore, pCorona; - - if( CLuaFunctionDefinitions::GetSunColor( RESOURCE->GetLua(), pCore.R, pCore.G, pCore.B, pCorona.R, pCorona.G, pCorona.B ) ) - { - pCore.A = pCorona.A = 255; - - CMonoObject* pCoreObject = RESOURCE->NewObject( pCore ); - CMonoObject* pCoronaObject = RESOURCE->NewObject( pCorona ); - - if( pCoreObject && pCoronaObject ) - { - MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, pCoreObject->GetClass()->GetClass(), 2 ); - - mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject->GetObject() ); - mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject->GetObject() ); - - return pMonoArray; - } - } - } - + if( RESOURCE ) + { + SColor pCore, pCorona; + + if( CLuaFunctionDefinitions::GetSunColor( RESOURCE->GetLua(), pCore.R, pCore.G, pCore.B, pCorona.R, pCorona.G, pCorona.B ) ) + { + pCore.A = pCorona.A = 255; + + MonoObject* pCoreObject = RESOURCE->NewObject( pCore ); + MonoObject* pCoronaObject = RESOURCE->NewObject( pCorona ); + + if( pCoreObject && pCoronaObject ) + { + MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, CMonoObject::GetClass( pCoreObject ), 2 ); + + mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject ); + mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject ); + + return pMonoArray; + } + } + } + return NULL; } - + MonoObject* CMonoFunctions::World::GetWindVelocity( void ) { - if( RESOURCE ) - { - Vector3 vecVelocity; - - if( CLuaFunctionDefinitions::GetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ) ) - { - CMonoObject* pObject = RESOURCE->NewObject( vecVelocity ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - + if( RESOURCE ) + { + Vector3 vecVelocity; + + if( CLuaFunctionDefinitions::GetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ) ) + { + return RESOURCE->NewObject( vecVelocity ); + } + } + return NULL; } - + float CMonoFunctions::World::GetFarClipDistance( void ) { - if( RESOURCE ) - { - float fFarClip; - - if( CLuaFunctionDefinitions::GetFarClipDistance( RESOURCE->GetLua(), fFarClip ) ) - { - return fFarClip; - } - } - + if( RESOURCE ) + { + float fFarClip; + + if( CLuaFunctionDefinitions::GetFarClipDistance( RESOURCE->GetLua(), fFarClip ) ) + { + return fFarClip; + } + } + return 0.0f; } - + float CMonoFunctions::World::GetFogDistance( void ) { - if( RESOURCE ) - { - float fFogDist; - - if( CLuaFunctionDefinitions::GetFogDistance( RESOURCE->GetLua(), fFogDist ) ) - { - return fFogDist; - } - } - + if( RESOURCE ) + { + float fFogDist; + + if( CLuaFunctionDefinitions::GetFogDistance( RESOURCE->GetLua(), fFogDist ) ) + { + return fFogDist; + } + } + return 0.0f; } - + float CMonoFunctions::World::GetAircraftMaxHeight( void ) { - if( RESOURCE ) - { - float fMaxHeight; - - if( CLuaFunctionDefinitions::GetAircraftMaxHeight( RESOURCE->GetLua(), fMaxHeight ) ) - { - return fMaxHeight; - } - } - + if( RESOURCE ) + { + float fMaxHeight; + + if( CLuaFunctionDefinitions::GetAircraftMaxHeight( RESOURCE->GetLua(), fMaxHeight ) ) + { + return fMaxHeight; + } + } + return 0.0f; } - + bool CMonoFunctions::World::GetOcclusionsEnabled( void ) { - if( RESOURCE ) - { - bool bEnabled; - - if( CLuaFunctionDefinitions::GetOcclusionsEnabled( RESOURCE->GetLua(), bEnabled ) ) - { - return bEnabled; - } - } - + if( RESOURCE ) + { + bool bEnabled; + + if( CLuaFunctionDefinitions::GetOcclusionsEnabled( RESOURCE->GetLua(), bEnabled ) ) + { + return bEnabled; + } + } + return false; } - + int CMonoFunctions::World::GetMoonSize( void ) { - if( RESOURCE ) - { - int iSize; - - if( CLuaFunctionDefinitions::GetMoonSize( RESOURCE->GetLua(), iSize ) ) - { - return iSize; - } - } - + if( RESOURCE ) + { + int iSize; + + if( CLuaFunctionDefinitions::GetMoonSize( RESOURCE->GetLua(), iSize ) ) + { + return iSize; + } + } + return 0; } - + MonoArray* CMonoFunctions::World::GetSkyGradient( void ) { - if( RESOURCE ) - { - SColor pCore, pCorona; - - if( CLuaFunctionDefinitions::GetSkyGradient( RESOURCE->GetLua(), pCore.R, pCore.G, pCore.B, pCorona.R, pCorona.G, pCorona.B ) ) - { - pCore.A = pCorona.A = 255; - - CMonoObject* pCoreObject = RESOURCE->NewObject( pCore ); - CMonoObject* pCoronaObject = RESOURCE->NewObject( pCorona ); - - if( pCoreObject && pCoronaObject ) - { - MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, pCoreObject->GetClass()->GetClass(), 2 ); - - mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject->GetObject() ); - mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject->GetObject() ); - - return pMonoArray; - } - } - } - + if( RESOURCE ) + { + SColor pCore, pCorona; + + if( CLuaFunctionDefinitions::GetSkyGradient( RESOURCE->GetLua(), pCore.R, pCore.G, pCore.B, pCorona.R, pCorona.G, pCorona.B ) ) + { + pCore.A = pCorona.A = 255; + + MonoObject* pCoreObject = RESOURCE->NewObject( pCore ); + MonoObject* pCoronaObject = RESOURCE->NewObject( pCorona ); + + if( pCoreObject && pCoronaObject ) + { + MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, CMonoObject::GetClass( pCoreObject ), 2 ); + + mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject ); + mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject ); + + return pMonoArray; + } + } + } + return NULL; } - + MonoObject* CMonoFunctions::World::GetHeatHaze( void ) { - if( RESOURCE ) - { - SHeatHazeSettings heatHazeSettings; - - if( CLuaFunctionDefinitions::GetHeatHaze( RESOURCE->GetLua(), heatHazeSettings ) ) - { - void* args[] = - { - &heatHazeSettings - }; - - CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "HeatHazeSettings", args, 1 ); - - if( pObject ) - { - return pObject->GetObject(); - } - } - } - + if( RESOURCE ) + { + SHeatHazeSettings heatHazeSettings; + + if( CLuaFunctionDefinitions::GetHeatHaze( RESOURCE->GetLua(), heatHazeSettings ) ) + { + void* args[] = + { + &heatHazeSettings + }; + + return RESOURCE->NewObject( "MultiTheftAuto", "HeatHazeSettings", args, 1 ); + } + } + return NULL; } - + bool CMonoFunctions::World::GetJetpackWeaponEnabled( unsigned int uiWeaponType ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GetJetpackWeaponEnabled( RESOURCE->GetLua(), (eWeaponType)uiWeaponType ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GetJetpackWeaponEnabled( RESOURCE->GetLua(), (eWeaponType)uiWeaponType ); + } + return false; } - + bool CMonoFunctions::World::GetCloudsEnabled( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::GetCloudsEnabled( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::GetCloudsEnabled( RESOURCE->GetLua() ); + } + return false; } - - -// General world set funcs + + +// General world set funcs bool CMonoFunctions::World::SetTime( unsigned char ucHour, unsigned char ucMinute ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetTime( RESOURCE->GetLua(), ucHour, ucMinute ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetTime( RESOURCE->GetLua(), ucHour, ucMinute ); + } + return false; } - + bool CMonoFunctions::World::SetWeather( unsigned char ucWeather ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetWeather( RESOURCE->GetLua(), ucWeather ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetWeather( RESOURCE->GetLua(), ucWeather ); + } + return false; } - + bool CMonoFunctions::World::SetWeatherBlended( unsigned char ucWeather ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetWeatherBlended( RESOURCE->GetLua(), ucWeather ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetWeatherBlended( RESOURCE->GetLua(), ucWeather ); + } + return false; } - + bool CMonoFunctions::World::SetGravity( float fGravity ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetGravity( RESOURCE->GetLua(), fGravity ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetGravity( RESOURCE->GetLua(), fGravity ); + } + return false; } - + bool CMonoFunctions::World::SetGameSpeed( float fSpeed ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetGameSpeed( RESOURCE->GetLua(), fSpeed ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetGameSpeed( RESOURCE->GetLua(), fSpeed ); + } + return false; } - + bool CMonoFunctions::World::SetWaveHeight( float fHeight ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetWaveHeight( RESOURCE->GetLua(), fHeight ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetWaveHeight( RESOURCE->GetLua(), fHeight ); + } + return false; } - + bool CMonoFunctions::World::SetSkyGradient( MonoObject* pTopColor, MonoObject* pBottomColor ) { - if( RESOURCE ) - { - SColor pTop = CMonoObject( pTopColor ).GetColor(); - SColor pBottom = CMonoObject( pBottomColor ).GetColor(); - - return CLuaFunctionDefinitions::SetSkyGradient( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B ); - } - + if( RESOURCE ) + { + SColor pTop = CMonoObject::GetColor( pTopColor ); + SColor pBottom = CMonoObject::GetColor( pBottomColor ); + + return CLuaFunctionDefinitions::SetSkyGradient( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B ); + } + return false; } - + bool CMonoFunctions::World::ResetSkyGradient( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetSkyGradient( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetSkyGradient( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::SetHeatHaze( MonoObject* heatHazeSettings ) { if( RESOURCE ) { - CMonoObject* pObject = new CMonoObject( heatHazeSettings ); - SHeatHazeSettings pHeatHazeSettings; - pHeatHazeSettings.ucIntensity = pObject->GetPropertyValue< unsigned char >( "ucIntensity" ); - pHeatHazeSettings.ucRandomShift = pObject->GetPropertyValue< unsigned char >( "ucRandomShift" ); - pHeatHazeSettings.usSpeedMin = pObject->GetPropertyValue< unsigned short >( "usSpeedMin" ); - pHeatHazeSettings.usSpeedMax = pObject->GetPropertyValue< unsigned short >( "usSpeedMax" ); - pHeatHazeSettings.sScanSizeX = pObject->GetPropertyValue< short >( "sScanSizeX" ); - pHeatHazeSettings.sScanSizeY = pObject->GetPropertyValue< short >( "sScanSizeY" ); - pHeatHazeSettings.usRenderSizeX = pObject->GetPropertyValue< unsigned short >( "usRenderSizeX" ); - pHeatHazeSettings.usRenderSizeY = pObject->GetPropertyValue< unsigned short >( "usRenderSizeY" ); - pHeatHazeSettings.bInsideBuilding = pObject->GetPropertyValue< bool >( "bInsideBuilding" ); + pHeatHazeSettings.ucIntensity = CMonoObject::GetPropertyValue< unsigned char >( heatHazeSettings, "ucIntensity" ); + pHeatHazeSettings.ucRandomShift = CMonoObject::GetPropertyValue< unsigned char >( heatHazeSettings, "ucRandomShift" ); + pHeatHazeSettings.usSpeedMin = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usSpeedMin" ); + pHeatHazeSettings.usSpeedMax = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usSpeedMax" ); + pHeatHazeSettings.sScanSizeX = CMonoObject::GetPropertyValue< short >( heatHazeSettings, "sScanSizeX" ); + pHeatHazeSettings.sScanSizeY = CMonoObject::GetPropertyValue< short >( heatHazeSettings, "sScanSizeY" ); + pHeatHazeSettings.usRenderSizeX = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usRenderSizeX" ); + pHeatHazeSettings.usRenderSizeY = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usRenderSizeY" ); + pHeatHazeSettings.bInsideBuilding = CMonoObject::GetPropertyValue< bool >( heatHazeSettings, "bInsideBuilding" ); return CLuaFunctionDefinitions::SetHeatHaze( RESOURCE->GetLua(), pHeatHazeSettings ); } return false; } - + bool CMonoFunctions::World::ResetHeatHaze( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetHeatHaze( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetHeatHaze( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::SetFPSLimit( unsigned short usLimit, bool bSave ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetFPSLimit( RESOURCE->GetLua(), usLimit, bSave ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetFPSLimit( RESOURCE->GetLua(), usLimit, bSave ); + } + return false; } - + bool CMonoFunctions::World::SetMinuteDuration( unsigned long ulDuration ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetMinuteDuration( RESOURCE->GetLua(), ulDuration ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetMinuteDuration( RESOURCE->GetLua(), ulDuration ); + } + return false; } - + bool CMonoFunctions::World::SetGarageOpen( unsigned char ucGarageID, bool bIsOpen ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetGarageOpen( RESOURCE->GetLua(), ucGarageID, bIsOpen ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetGarageOpen( RESOURCE->GetLua(), ucGarageID, bIsOpen ); + } + return false; } - + bool CMonoFunctions::World::SetGlitchEnabled( MonoString* msGlitchName, bool bEnabled ) { - if( RESOURCE ) - { - string strGlitchName( mono_string_to_utf8( msGlitchName ) ); - - return CLuaFunctionDefinitions::SetGlitchEnabled( RESOURCE->GetLua(), strGlitchName, bEnabled ); - } - + if( RESOURCE ) + { + string strGlitchName( mono_string_to_utf8( msGlitchName ) ); + + return CLuaFunctionDefinitions::SetGlitchEnabled( RESOURCE->GetLua(), strGlitchName, bEnabled ); + } + return false; } - + bool CMonoFunctions::World::IsGlitchEnabled( MonoString* msGlitchName ) { - if( RESOURCE ) - { - string strGlitchName( mono_string_to_utf8( msGlitchName ) ); - - return CLuaFunctionDefinitions::IsGlitchEnabled( RESOURCE->GetLua(), strGlitchName ); - } - + if( RESOURCE ) + { + string strGlitchName( mono_string_to_utf8( msGlitchName ) ); + + return CLuaFunctionDefinitions::IsGlitchEnabled( RESOURCE->GetLua(), strGlitchName ); + } + return false; } - + bool CMonoFunctions::World::SetJetpackWeaponEnabled( unsigned int uiWeaponType, bool bEnabled ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetJetpackWeaponEnabled( RESOURCE->GetLua(), (eWeaponType)uiWeaponType, bEnabled ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetJetpackWeaponEnabled( RESOURCE->GetLua(), (eWeaponType)uiWeaponType, bEnabled ); + } + return false; } - + bool CMonoFunctions::World::SetCloudsEnabled( bool bEnabled ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetCloudsEnabled( RESOURCE->GetLua(), bEnabled ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetCloudsEnabled( RESOURCE->GetLua(), bEnabled ); + } + return false; } - + bool CMonoFunctions::World::SetTrafficLightState( unsigned char ucState, bool bForced ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetTrafficLightState( RESOURCE->GetLua(), ucState, bForced ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetTrafficLightState( RESOURCE->GetLua(), ucState, bForced ); + } + return false; } - + bool CMonoFunctions::World::SetTrafficLightsLocked( bool bLocked ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetTrafficLightsLocked( RESOURCE->GetLua(), bLocked ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetTrafficLightsLocked( RESOURCE->GetLua(), bLocked ); + } + return false; } - + bool CMonoFunctions::World::SetJetpackMaxHeight( float fMaxHeight ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetJetpackMaxHeight( RESOURCE->GetLua(), fMaxHeight ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetJetpackMaxHeight( RESOURCE->GetLua(), fMaxHeight ); + } + return false; } - + bool CMonoFunctions::World::SetInteriorSoundsEnabled( bool bEnable ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetInteriorSoundsEnabled( RESOURCE->GetLua(), bEnable ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetInteriorSoundsEnabled( RESOURCE->GetLua(), bEnable ); + } + return false; } - + bool CMonoFunctions::World::SetRainLevel( float fRainLevel ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetRainLevel( RESOURCE->GetLua(), fRainLevel ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetRainLevel( RESOURCE->GetLua(), fRainLevel ); + } + return false; } - + bool CMonoFunctions::World::SetSunSize( float fSunSize ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetSunSize( RESOURCE->GetLua(), fSunSize ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetSunSize( RESOURCE->GetLua(), fSunSize ); + } + return false; } - + bool CMonoFunctions::World::SetSunColor( MonoObject* pCoreColor, MonoObject* pCoronaColor ) { - if( RESOURCE ) - { - SColor pTop = CMonoObject( pCoreColor ).GetColor(); - SColor pBottom = CMonoObject( pCoronaColor ).GetColor(); - - return CLuaFunctionDefinitions::SetSunColor( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B ); - } - + if( RESOURCE ) + { + SColor pTop = CMonoObject::GetColor( pCoreColor ); + SColor pBottom = CMonoObject::GetColor( pCoronaColor ); + + return CLuaFunctionDefinitions::SetSunColor( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B ); + } + return false; } - + bool CMonoFunctions::World::SetWindVelocity( MonoObject* pVelocity ) { - if( RESOURCE ) - { - Vector3 vecVelocity = CMonoObject( pVelocity ).GetVector3(); - - return CLuaFunctionDefinitions::SetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ); - } - + if( RESOURCE ) + { + Vector3 vecVelocity( pVelocity ); + + return CLuaFunctionDefinitions::SetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ); + } + return false; } - + bool CMonoFunctions::World::SetFarClipDistance( float fFarClip ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetFarClipDistance( RESOURCE->GetLua(), fFarClip ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetFarClipDistance( RESOURCE->GetLua(), fFarClip ); + } + return false; } - + bool CMonoFunctions::World::SetFogDistance( float fFogDist ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetFogDistance( RESOURCE->GetLua(), fFogDist ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetFogDistance( RESOURCE->GetLua(), fFogDist ); + } + return false; } - + bool CMonoFunctions::World::SetAircraftMaxHeight( float fMaxHeight ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetAircraftMaxHeight( RESOURCE->GetLua(), fMaxHeight ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetAircraftMaxHeight( RESOURCE->GetLua(), fMaxHeight ); + } + return false; } - + bool CMonoFunctions::World::SetAircraftMaxVelocity( float fVelocity ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetAircraftMaxVelocity( RESOURCE->GetLua(), fVelocity ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetAircraftMaxVelocity( RESOURCE->GetLua(), fVelocity ); + } + return false; } - + bool CMonoFunctions::World::SetOcclusionsEnabled( bool bEnabled ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetOcclusionsEnabled( RESOURCE->GetLua(), bEnabled ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetOcclusionsEnabled( RESOURCE->GetLua(), bEnabled ); + } + return false; } - + bool CMonoFunctions::World::ResetRainLevel( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetRainLevel( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetRainLevel( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::ResetSunSize( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetSunSize( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetSunSize( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::ResetSunColor( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetSunColor( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetSunColor( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::ResetWindVelocity( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetWindVelocity( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetWindVelocity( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::ResetFarClipDistance( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetFarClipDistance( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetFarClipDistance( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::ResetFogDistance( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetFogDistance( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetFogDistance( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::RemoveWorldModel( unsigned short usModel, float fRadius, MonoObject* pPosition, char cInterior ) { - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - - return CLuaFunctionDefinitions::RemoveWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + + return CLuaFunctionDefinitions::RemoveWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior ); + } + return false; } - + bool CMonoFunctions::World::RestoreWorldModel( unsigned short usModel, float fRadius, MonoObject* pPosition, char cInterior ) { - if( RESOURCE ) - { - Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); - - return CLuaFunctionDefinitions::RestoreWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior ); - } - + if( RESOURCE ) + { + Vector3 vecPosition( pPosition ); + + return CLuaFunctionDefinitions::RestoreWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior ); + } + return false; } - + bool CMonoFunctions::World::RestoreAllWorldModels( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::RestoreAllWorldModels( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::RestoreAllWorldModels( RESOURCE->GetLua() ); + } + return false; } - + bool CMonoFunctions::World::SetMoonSize( int iMoonSize ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::SetMoonSize( RESOURCE->GetLua(), iMoonSize ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::SetMoonSize( RESOURCE->GetLua(), iMoonSize ); + } + return false; } - + bool CMonoFunctions::World::ResetMoonSize( void ) { - if( RESOURCE ) - { - return CLuaFunctionDefinitions::ResetMoonSize( RESOURCE->GetLua() ); - } - + if( RESOURCE ) + { + return CLuaFunctionDefinitions::ResetMoonSize( RESOURCE->GetLua() ); + } + return false; } diff --git a/mta-mono/src/CResource.cpp b/mta-mono/src/CResource.cpp index 6f59605..dad9f50 100644 --- a/mta-mono/src/CResource.cpp +++ b/mta-mono/src/CResource.cpp @@ -1,270 +1,265 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CResource.h" -#include "CResourceManager.h" -#include "include/ILuaModuleManager.h" -#include "lua/CLuaFunctionDefinitions.h" - -extern ILuaModuleManager10 *g_pModuleManager; -extern CResourceManager *g_pResourceManager; - -CResource::CResource( lua_State *pLuaVM, string sName ) -{ - this->m_pLuaVM = pLuaVM; - this->m_sName = sName; - - this->m_pMonoAssembly = NULL; - this->m_pMonoAssemblyLib = NULL; - this->m_pMonoGCHandle = NULL; - this->m_pMonoDomain = NULL; - this->m_pMonoImage = NULL; - this->m_pMonoImageLib = NULL; - this->m_pMonoClass = NULL; -} - -CResource::~CResource( void ) -{ - mono_domain_set( mono_get_root_domain(), false ); - - if( this->m_pMonoDomain ) - { - mono_domain_unload( this->m_pMonoDomain ); - } - - mono_gc_collect( mono_gc_max_generation() ); - - g_pResourceManager->RemoveFromList( this ); - - this->m_pMonoAssembly = NULL; - this->m_pMonoAssemblyLib = NULL; - this->m_pMonoGCHandle = NULL; - this->m_pMonoDomain = NULL; - this->m_pMonoImage = NULL; - this->m_pMonoImageLib = NULL; - this->m_pMonoClass = NULL; - - this->m_pLuaVM = NULL; -} - -bool CResource::Init( void ) -{ - if( this->m_pLuaVM ) - { - string sDirectory ( "mods/deathmatch/resources/[ire]/" + this->m_sName + "/" ); - string sPath ( sDirectory + this->m_sName + ".dll" ); - string sNamespace ( this->m_sName ); - string sClass ( "Program" ); - - this->m_pMonoDomain = mono_domain_create_appdomain( const_cast< char* >( this->m_sName.c_str( ) ), NULL ); - - if( !this->m_pMonoDomain ) - { - g_pModuleManager->ErrorPrintf( "%s - failed to create appdomain\n", this->m_sName.c_str() ); - - return false; - } - - mono_domain_set( this->m_pMonoDomain, false ); - - this->m_pMonoAssemblyLib = mono_domain_assembly_open( this->m_pMonoDomain, ( sDirectory + "MultiTheftAuto.dll" ).c_str() ); - - if( this->m_pMonoAssemblyLib ) - { - this->m_pMonoImageLib = mono_assembly_get_image( this->m_pMonoAssemblyLib ); - } - - this->m_pMonoAssembly = mono_domain_assembly_open( this->m_pMonoDomain, sPath.c_str() ); - - if( !this->m_pMonoAssembly ) - { - g_pModuleManager->ErrorPrintf( "failed to open assembly '%s.dll'\n", this->m_sName.c_str() ); - - return false; - } - - this->m_pMonoImage = mono_assembly_get_image( this->m_pMonoAssembly ); - this->m_pMonoClass = mono_class_from_name( this->m_pMonoImage, sNamespace.c_str(), sClass.c_str() ); - +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CResource.h" +#include "CResourceManager.h" +#include "include/ILuaModuleManager.h" +#include "lua/CLuaFunctionDefinitions.h" + +extern ILuaModuleManager10 *g_pModuleManager; +extern CResourceManager *g_pResourceManager; + +CResource::CResource( lua_State *pLuaVM, string sName ) +{ + this->m_pLuaVM = pLuaVM; + this->m_sName = sName; + + this->m_pMonoAssembly = NULL; + this->m_pMonoAssemblyLib = NULL; + this->m_pMonoGCHandle = NULL; + this->m_pMonoDomain = NULL; + this->m_pMonoImage = NULL; + this->m_pMonoImageLib = NULL; + this->m_pMonoClass = NULL; +} + +CResource::~CResource( void ) +{ + mono_domain_set( mono_get_root_domain(), false ); + + if( this->m_pMonoDomain ) + { + mono_domain_unload( this->m_pMonoDomain ); + } + + mono_gc_collect( mono_gc_max_generation() ); + + g_pResourceManager->RemoveFromList( this ); + + this->m_pMonoAssembly = NULL; + this->m_pMonoAssemblyLib = NULL; + this->m_pMonoGCHandle = NULL; + this->m_pMonoDomain = NULL; + this->m_pMonoImage = NULL; + this->m_pMonoImageLib = NULL; + this->m_pMonoClass = NULL; + + this->m_pLuaVM = NULL; +} + +bool CResource::Init( void ) +{ + if( this->m_pLuaVM ) + { + string sDirectory ( "mods/deathmatch/resources/[ire]/" + this->m_sName + "/" ); + string sPath ( sDirectory + this->m_sName + ".dll" ); + string sNamespace ( this->m_sName ); + string sClass ( "Program" ); + + this->m_pMonoDomain = mono_domain_create_appdomain( const_cast< char* >( this->m_sName.c_str( ) ), NULL ); + + if( !this->m_pMonoDomain ) + { + g_pModuleManager->ErrorPrintf( "%s - failed to create appdomain\n", this->m_sName.c_str() ); + + return false; + } + + mono_domain_set( this->m_pMonoDomain, false ); + + this->m_pMonoAssemblyLib = mono_domain_assembly_open( this->m_pMonoDomain, ( sDirectory + "MultiTheftAuto.dll" ).c_str() ); + + if( this->m_pMonoAssemblyLib ) + { + this->m_pMonoImageLib = mono_assembly_get_image( this->m_pMonoAssemblyLib ); + } + + this->m_pMonoAssembly = mono_domain_assembly_open( this->m_pMonoDomain, sPath.c_str() ); + + if( !this->m_pMonoAssembly ) + { + g_pModuleManager->ErrorPrintf( "failed to open assembly '%s.dll'\n", this->m_sName.c_str() ); + + return false; + } + + this->m_pMonoImage = mono_assembly_get_image( this->m_pMonoAssembly ); + this->m_pMonoClass = mono_class_from_name( this->m_pMonoImage, sNamespace.c_str(), sClass.c_str() ); + MonoObject *pMonoObject = mono_object_new( this->m_pMonoDomain, this->m_pMonoClass ); mono_gchandle_new( pMonoObject, false ); - mono_runtime_object_init( pMonoObject ); - - return true; - } - - return false; -} - -void CResource::OnStopping( void ) -{ -} - -void CResource::DoPulse( void ) -{ -} - -bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func ) -{ - if( !g_pModuleManager->RegisterFunction( this->m_pLuaVM, szFunctionName, Func ) ) - { - g_pModuleManager->ErrorPrintf( "Failed to register function '%s' for %s", szFunctionName, this->m_sName.c_str() ); - - return false; - } - - return true; -} - -CMonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName ) -{ - MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName ); - - if( !pMonoClass ) - { - pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName ); - } - - if( pMonoClass ) - { - return new CMonoClass( pMonoClass ); - } - - return NULL; -} - -CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName ) -{ - CMonoClass* pClass = this->GetClassFromName( szNamespace, szName ); - - if( pClass ) - { - CMonoObject* pObject = pClass->New( mono_domain_get() ); - - if( pObject ) - { - return pObject; - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName ); - } - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName ); - } - - return NULL; -} - -CMonoObject* CResource::NewObject( SColor& pColor ) -{ - CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Color" ); - - if( pClass ) - { - CMonoObject* pObject = pClass->New( mono_domain_get(), pColor ); - - if( pObject ) - { - return pObject; - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ ); - } - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ ); - } - - return NULL; -} - -CMonoObject* CResource::NewObject( Vector2& vecVector ) -{ - CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector2" ); - - if( pClass ) - { - CMonoObject* pObject = pClass->New( mono_domain_get(), vecVector ); - - if( pObject ) - { - return pObject; - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ ); - } - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ ); - } - - return NULL; -} - -CMonoObject* CResource::NewObject( Vector3& vecVector ) -{ - CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector3" ); - - if( pClass ) - { - CMonoObject* pObject = pClass->New( mono_domain_get(), vecVector ); - - if( pObject ) - { - return pObject; - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector3'\n", __FILE__, __LINE__ ); - } - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ ); - } - - return NULL; -} - -CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName, void** args, int argc ) -{ - CMonoClass* pClass = this->GetClassFromName( szNamespace, szName ); - - if( pClass ) - { - CMonoObject* pObject = pClass->New( mono_domain_get(), args, argc ); - - if( pObject ) - { - return pObject; - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName ); - } - } - else - { - g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName ); - } - - return NULL; -} + mono_runtime_object_init( pMonoObject ); + + return true; + } + + return false; +} + +void CResource::OnStopping( void ) +{ +} + +void CResource::DoPulse( void ) +{ +} + +bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func ) +{ + if( !g_pModuleManager->RegisterFunction( this->m_pLuaVM, szFunctionName, Func ) ) + { + g_pModuleManager->ErrorPrintf( "Failed to register function '%s' for %s", szFunctionName, this->m_sName.c_str() ); + + return false; + } + + return true; +} + +MonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName ) +{ + MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName ); + + if( !pMonoClass ) + { + pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName ); + } + + return pMonoClass; +} + +MonoObject* CResource::NewObject( const char* szNamespace, const char* szName ) +{ + MonoClass* pClass = this->GetClassFromName( szNamespace, szName ); + + if( pClass ) + { + MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get() ); + + if( pObject ) + { + return pObject; + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName ); + } + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName ); + } + + return nullptr; +} + +MonoObject* CResource::NewObject( SColor& pColor ) +{ + MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Color" ); + + if( pClass ) + { + MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), pColor ); + + if( pObject ) + { + return pObject; + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Color'\n", __FILE__, __LINE__ ); + } + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Color' not found\n", __FILE__, __LINE__ ); + } + + return nullptr; +} + +MonoObject* CResource::NewObject( Vector2& vecVector ) +{ + MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector2" ); + + if( pClass ) + { + MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector ); + + if( pObject ) + { + return pObject; + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ ); + } + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ ); + } + + return nullptr; +} + +MonoObject* CResource::NewObject( Vector3& vecVector ) +{ + MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector3" ); + + if( pClass ) + { + MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector ); + + if( pObject ) + { + return pObject; + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector3'\n", __FILE__, __LINE__ ); + } + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ ); + } + + return nullptr; +} + +MonoObject* CResource::NewObject( const char* szNamespace, const char* szName, void** args, int argc ) +{ + MonoClass* pClass = this->GetClassFromName( szNamespace, szName ); + + if( pClass ) + { + MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), args, argc ); + + if( pObject ) + { + return pObject; + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName ); + } + } + else + { + g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName ); + } + + return nullptr; +} diff --git a/mta-mono/src/CResource.h b/mta-mono/src/CResource.h index b3beeb6..c2b14ef 100644 --- a/mta-mono/src/CResource.h +++ b/mta-mono/src/CResource.h @@ -1,104 +1,104 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -class CResource; - -#ifndef __CRESOURCE_H -#define __CRESOURCE_H - -#include "Common.h" -#include "CMonoClass.h" -#include "extra/CLuaArguments.h" - -class CResource -{ -private: - string m_sName; - - MonoAssembly *m_pMonoAssembly; - MonoAssembly *m_pMonoAssemblyLib; - MonoImage *m_pMonoImage; - MonoImage *m_pMonoImageLib; - MonoClass *m_pMonoClass; - uint32_t m_pMonoGCHandle; - -public: - lua_State *m_pLuaVM; - MonoDomain *m_pMonoDomain; - - CResource ( lua_State *pLuaVM, string sName ); - ~CResource ( void ); - - bool Init ( void ); - void OnStopping ( void ); - void DoPulse ( void ); - bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func ); - - CMonoClass* GetClassFromName( const char* szNamespace, const char* szName ); - - CMonoObject* NewObject( const char* szNamespace, const char* szName ); - CMonoObject* NewObject( SColor& pColor ); - CMonoObject* NewObject( Vector2& vecVector ); - CMonoObject* NewObject( Vector3& vecVector ); - CMonoObject* NewObject( const char* szNamespace, const char* szName, void** args, int argc ); - - MonoString* NewString( const char* szText ) - { - return mono_string_new( this->m_pMonoDomain, szText ); - } - - MonoString* NewString( string strText ) - { - return mono_string_new( this->m_pMonoDomain, strText.c_str() ); - } - - template MonoArray* NewArray( MonoClass* pMonoClass, CLuaArguments* pLuaArguments = NULL ) - { - MonoArray* pArray = mono_array_new( this->m_pMonoDomain, pMonoClass, pLuaArguments ? pLuaArguments->Count() : 0 ); - - if( pLuaArguments ) - { - vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin(); - - for( unsigned int i = 0; iter != pLuaArguments->IterEnd(); iter++, i++ ) - { - if( LuaType == LUA_TBOOLEAN ) - { - mono_array_set( pArray, T, i, (T)( ( *iter )->GetBoolean() ) ); - } - else if( LuaType == LUA_TLIGHTUSERDATA ) - { - mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) ); - } - else if( LuaType == LUA_TNUMBER ) - { - mono_array_set( pArray, T, i, ( *iter )->GetNumber< T >() ); - } - else if( LuaType == LUA_TSTRING ) - { - mono_array_set( pArray, T, i, (T)( ( *iter )->GetString() ) ); - } - else if( LuaType == LUA_TUSERDATA ) - { - mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) ); - } - } - } - - return pArray; - } - - string GetName ( void ) { return this->m_sName; } - lua_State *GetLua ( void ) { return this->m_pLuaVM; } -}; - +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +class CResource; + +#ifndef __CRESOURCE_H +#define __CRESOURCE_H + +#include "Common.h" +#include "CMonoClass.h" +#include "extra/CLuaArguments.h" + +class CResource +{ +private: + string m_sName; + + MonoAssembly *m_pMonoAssembly; + MonoAssembly *m_pMonoAssemblyLib; + MonoImage *m_pMonoImage; + MonoImage *m_pMonoImageLib; + MonoClass *m_pMonoClass; + uint32_t m_pMonoGCHandle; + +public: + lua_State *m_pLuaVM; + MonoDomain *m_pMonoDomain; + + CResource ( lua_State *pLuaVM, string sName ); + ~CResource ( void ); + + bool Init ( void ); + void OnStopping ( void ); + void DoPulse ( void ); + bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func ); + + MonoClass* GetClassFromName( const char* szNamespace, const char* szName ); + + MonoObject* NewObject( const char* szNamespace, const char* szName ); + MonoObject* NewObject( SColor& pColor ); + MonoObject* NewObject( Vector2& vecVector ); + MonoObject* NewObject( Vector3& vecVector ); + MonoObject* NewObject( const char* szNamespace, const char* szName, void** args, int argc ); + + MonoString* NewString( const char* szText ) + { + return mono_string_new( this->m_pMonoDomain, szText ); + } + + MonoString* NewString( string strText ) + { + return mono_string_new( this->m_pMonoDomain, strText.c_str() ); + } + + template MonoArray* NewArray( MonoClass* pMonoClass, CLuaArguments* pLuaArguments = NULL ) + { + MonoArray* pArray = mono_array_new( this->m_pMonoDomain, pMonoClass, pLuaArguments ? pLuaArguments->Count() : 0 ); + + if( pLuaArguments ) + { + vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin(); + + for( unsigned int i = 0; iter != pLuaArguments->IterEnd(); iter++, i++ ) + { + if( LuaType == LUA_TBOOLEAN ) + { + mono_array_set( pArray, T, i, (T)( ( *iter )->GetBoolean() ) ); + } + else if( LuaType == LUA_TLIGHTUSERDATA ) + { + mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) ); + } + else if( LuaType == LUA_TNUMBER ) + { + mono_array_set( pArray, T, i, ( *iter )->GetNumber< T >() ); + } + else if( LuaType == LUA_TSTRING ) + { + mono_array_set( pArray, T, i, (T)( ( *iter )->GetString() ) ); + } + else if( LuaType == LUA_TUSERDATA ) + { + mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) ); + } + } + } + + return pArray; + } + + string GetName ( void ) { return this->m_sName; } + lua_State *GetLua ( void ) { return this->m_pLuaVM; } +}; + #endif \ No newline at end of file