#include "main.h" SAMPFUNCS * SF = new SAMPFUNCS ( ) ; CVector orig , pos ; bool check ; int dist { 5 } , delay { 30 } ; void InCarSync ( float x , float y , float z ) { stInCarData data { } ; data = SF -> getSAMP ( ) -> getPlayers ( ) -> pLocalPlayer -> inCarData ; data . fPosition [ 0 ] = x ; data . fPosition [ 1 ] = y ; data . fPosition [ 2 ] = z ; BitStream bs ; bs . Write ( static_cast ( ID_VEHICLE_SYNC ) ) ; bs . Write ( reinterpret_cast ( & data ) , sizeof ( stInCarData ) ) ; SF -> getRakNet ( ) -> SendPacket ( & bs ) ; } CVector mark ( ) { CVector marker ; for ( int i = 0 ; i ( 0xBA873D + i ) == 4611 ) { marker = * reinterpret_cast ( 0xBA86F8 + 0x28 + i ) ; reinterpret_cast ( 0x40ED80 ) ( & marker ) ; marker . fZ = GAME -> GetWorld ( ) -> FindGroundZForPosition ( marker . fX , marker . fY ) ; } } return marker ; } void CALLBACK cmd ( std :: string ) { if ( ! PEDSELF -> GetVehicle ( ) || * reinterpret_cast ( 0xBA6774 ) == 0 ) return ; orig = * PEDSELF -> GetVehicle ( ) -> GetPosition ( ) ; pos = mark ( ) ; check = ! check ; SF -> getSAMP ( ) -> getChat ( ) -> AddChatMessage ( - 1 , check ? "on" : "off" ) ; } bool CALLBACK outcomingData ( stRakNetHookParams * params ) { if ( params -> packetId == PacketEnumeration :: ID_VEHICLE_SYNC && check ) return false ; return true ; } void CALLBACK mainloop ( ) { static bool init { } ; if ( ! init ) { if ( GAME == nullptr || GAME -> GetSystemState ( ) != eSystemState :: GS_PLAYING_GAME || ! SF -> getSAMP ( ) -> IsInitialized ( ) ) return ; SF -> getSAMP ( ) -> registerChatCommand ( "coord" , cmd ) ; SF -> getRakNet ( ) -> registerRakNetCallback ( RakNetScriptHookType :: RAKHOOK_TYPE_OUTCOMING_PACKET , outcomingData ) ; init = true ; } if ( check ) { if ( PEDSELF -> GetVehicle ( ) ) { static DWORD time { } ; if ( GetTickCount ( ) - delay > time ) { CVector bet = pos - orig ; if ( bet . Length ( ) GetVehicle ( ) -> Teleport ( pos . fX , pos . fY , pos . fZ + 1.f ) ; SF -> getSAMP ( ) -> getChat ( ) -> AddChatMessage ( - 1 , "success" ) ; check = false ; } else { bet . Normalize ( ) ; orig . fX += bet . fX * dist ; orig . fY += bet . fY * dist ; orig . fZ += bet . fZ * dist ; InCarSync ( orig . fX , orig . fY , orig . fZ ) ; time = GetTickCount ( ) ; } } } else { SF -> getSAMP ( ) -> getChat ( ) -> AddChatMessage ( - 1 , "off" ) ; check = false ; } } } BOOL WINAPI DllMain ( HINSTANCE hinstDLL , DWORD fdwReason , LPVOID ) { if ( fdwReason == DLL_PROCESS_ATTACH ) SF -> initPlugin ( mainloop , hinstDLL ) ; return TRUE ; }