SF API | anticarjacking

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include <windows.h>
#include <string>
#include <assert.h>
#include "CSAMPFUNCS.h"
CSAMPFUNCS *SF = new CSAMPFUNCS();
bool CALLBACK incomingData(stRakNetHookParams *params)
{
if (params->packetId == PacketEnumeration::ID_VEHICLE_SYNC)
{
byte packet;
uint16_t playerID;
uint16_t vehicleID;
params->bitStream->ResetReadPointer();
params->bitStream->Read(packet);
params->bitStream->Read(playerID);
params->bitStream->Read(vehicleID);
params->bitStream->ResetReadPointer();
int userVehID = SF->getSAMP()->getPlayers()->pLocalPlayer->sCurrentVehicleID;
if (vehicleID == userVehID)
{
stOnFootData onfootsync;
memset(&onfootsync, 0, sizeof(stOnFootData));
stInCarData mysync;
memset(&mysync, 0, sizeof(stInCarData));
mysync = SF->getSAMP()->getPlayers()->pLocalPlayer->inCarData;
onfootsync.sLeftRightKeys = mysync.sLeftRightKeys;
onfootsync.sUpDownKeys = mysync.sUpDownKeys;
onfootsync.sKeys = mysync.sKeys;
onfootsync.fPosition[0] = mysync.fPosition[0];
onfootsync.fPosition[1] = mysync.fPosition[1];
onfootsync.fPosition[2] = mysync.fPosition[2];
onfootsync.fQuaternion[0] = mysync.fQuaternion[0];
onfootsync.fQuaternion[1] = mysync.fQuaternion[1];
onfootsync.fQuaternion[2] = mysync.fQuaternion[2];
onfootsync.fQuaternion[3] = mysync.fQuaternion[3];
onfootsync.byteHealth = mysync.bytePlayerHealth;
onfootsync.byteArmor = mysync.byteArmor;
onfootsync.byteCurrentWeapon = mysync.byteCurrentWeapon;
onfootsync.fMoveSpeed[0] = mysync.fMoveSpeed[0];
onfootsync.fMoveSpeed[1] = mysync.fMoveSpeed[1];
onfootsync.fMoveSpeed[2] = mysync.fMoveSpeed[2];
onfootsync.sCurrentAnimationID = 0;
onfootsync.sAnimFlags = 0;
onfootsync.sSurfingVehicleID = -1;
onfootsync.fSurfingOffsets[0] = 0;
onfootsync.fSurfingOffsets[1] = 0;
onfootsync.fSurfingOffsets[2] = 0;
onfootsync.byteSpecialAction = 0;
BitStream bsOnFootSync;
bsOnFootSync.Write((BYTE)ID_PLAYER_SYNC);
bsOnFootSync.Write((PCHAR)&onfootsync, sizeof(stOnFootData));
SF->getRakNet()->SendPacket(&bsOnFootSync);
SF->getSAMP()->sendEnterVehicle(userVehID, 0);
/*
stInCarData sync; // объявляем объект структуры stInCarData, в которой хранятся данные.
memset(&sync, 0, sizeof(stInCarData)); // обнуляем.
sync = SF->getSAMP()->getPlayers()->pLocalPlayer->inCarData; // копируем данные из структуры локального игрока.
BitStream bsInCarSync; // объявляем объект класса BitStream, в котором хранятся пакетные данные.
bsInCarSync.Write((BYTE)ID_VEHICLE_SYNC); // записываем ID пакета.
bsInCarSync.Write((PCHAR)&sync, sizeof(stInCarData)); // записываем данные из структуры sync
SF->getRakNet()->SendPacket(&bsInCarSync); // отправляем пакет на сервер.*/
return false;
}
};
return true;
};
/*bool CALLBACK incomingRPC(stRakNetHookParams *params)
{
if (params->packetId == RPCEnumeration::RPC_EnterVehicle) // WORD playerID, WORD vehicleID, BYTE seat
{
uint16_t playerID;
uint16_t vehicleID;
params->bitStream->ResetReadPointer();
params->bitStream->Read(playerID);
params->bitStream->Read(vehicleID);
params->bitStream->ResetReadPointer();
int userVehID = SF->getSAMP()->getPlayers()->pLocalPlayer->sCurrentVehicleID;
if (vehicleID == userVehID)
{
stOnFootData onfootsync;
memset(&onfootsync, 0, sizeof(stOnFootData));
stInCarData mysync;
memset(&mysync, 0, sizeof(stInCarData));
mysync = SF->getSAMP()->getPlayers()->pLocalPlayer->inCarData;
onfootsync.sLeftRightKeys = mysync.sLeftRightKeys;
onfootsync.sUpDownKeys = mysync.sUpDownKeys;
onfootsync.sKeys = mysync.sKeys;
onfootsync.fPosition[0] = mysync.fPosition[0];
onfootsync.fPosition[1] = mysync.fPosition[1];
onfootsync.fPosition[2] = mysync.fPosition[2];
onfootsync.fQuaternion[0] = mysync.fQuaternion[0];
onfootsync.fQuaternion[1] = mysync.fQuaternion[1];
onfootsync.fQuaternion[2] = mysync.fQuaternion[2];
onfootsync.fQuaternion[3] = mysync.fQuaternion[3];
onfootsync.byteHealth = mysync.bytePlayerHealth;
onfootsync.byteArmor = mysync.byteArmor;
onfootsync.byteCurrentWeapon = mysync.byteCurrentWeapon;
onfootsync.fMoveSpeed[0] = mysync.fMoveSpeed[0];
onfootsync.fMoveSpeed[1] = mysync.fMoveSpeed[1];
onfootsync.fMoveSpeed[2] = mysync.fMoveSpeed[2];
onfootsync.sCurrentAnimationID = 0;
onfootsync.sAnimFlags = 0;
onfootsync.sSurfingVehicleID = -1;
onfootsync.fSurfingOffsets[0] = 0;
onfootsync.fSurfingOffsets[1] = 0;
onfootsync.fSurfingOffsets[2] = 0;
onfootsync.byteSpecialAction = 0;
BitStream bsOnFootSync;
bsOnFootSync.Write((BYTE)ID_PLAYER_SYNC);
bsOnFootSync.Write((PCHAR)&onfootsync, sizeof(stOnFootData));
SF->getRakNet()->SendPacket(&bsOnFootSync);
/*SF->getSAMP()->sendEnterVehicle(userVehID, 0);
stInCarData sync; // объявляем объект структуры stInCarData, в которой хранятся данные.
memset(&sync, 0, sizeof(stInCarData)); // обнуляем.
sync = SF->getSAMP()->getPlayers()->pLocalPlayer->inCarData; // копируем данные из структуры локального игрока.
BitStream bsInCarSync; // объявляем объект класса BitStream, в котором хранятся пакетные данные.
bsInCarSync.Write((BYTE)ID_VEHICLE_SYNC); // записываем ID пакета.
bsInCarSync.Write((PCHAR)&sync, sizeof(stInCarData)); // записываем данные из структуры sync
SF->getRakNet()->SendPacket(&bsInCarSync); // отправляем пакет на сервер.
return false;
}
};
return true;
};*/
void CALLBACK mainloop( void )
{
static bool init = false;
if( !init )
{
if( !SF->getSAMP()->IsInitialized() )
return;
SF->getSAMP()->getChat()->AddChatMessage(0xFFCC00, "[BLASTHACK] {EAEAEA}AntiCarJacking plugin loaded // by hnnssy.");
SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_PACKET, incomingData); // регистрируем callback
//SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_RPC, incomingRPC);
init = true;
}
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved )
{
switch ( dwReasonForCall )
{
case DLL_PROCESS_ATTACH:
SF->initPlugin( mainloop, hModule );
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}