void InCarDataSync(int i,float x1,float y1,float z1)
{
int icar;
stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[ i ];
if(!pPlayer) return;
icar = pPlayer->pPlayerData->sVehicleID;
if(!icar) return;
CVehicle *veh = PEDSELF->GetVehicle();
if (!veh) return;
stInCarData sync;
memset( &sync, 0, sizeof( stInCarData ) );
sync = pPlayer->pPlayerData->inCarData;
sync.fPosition[0] = x1;
sync.fPosition[1] = y1;
sync.fPosition[2] = z1;
BitStream CarSync;
CarSync.Write( ( BYTE ) ID_VEHICLE_SYNC );
CarSync.Write( ( PCHAR ) &sync, sizeof( stInCarData ) );
SF->getRakNet()->SendPacket( &CarSync );
}
void BulletData(int i)
{
stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[ i ];
if(!pPlayer) return;
stBulletData sync;
ZeroMemory(&sync, sizeof(stBulletData));
sync.sTargetID = i;
sync.fOrigin[0] = PEDSELF->GetPosition()->fX;
sync.fOrigin[1] = PEDSELF->GetPosition()->fY;
sync.fOrigin[2] = PEDSELF->GetPosition()->fZ;
sync.fTarget[0] = pPlayer->pPlayerData->fOnFootPos[0];
sync.fTarget[1] = pPlayer->pPlayerData->fOnFootPos[1];
sync.fTarget[2] = pPlayer->pPlayerData->fOnFootPos[2];
sync.fCenter[0] = 0.0;
sync.fCenter[1] = 0.0;
sync.fCenter[2] = 0.5;
sync.byteWeaponID = SF->getSAMP()->getPlayers()->pLocalPlayer->byteCurrentWeapon;
sync.byteType = 1;
BitStream BulletSync;
BulletSync.Write((BYTE)PacketEnumeration::ID_BULLET_SYNC);
BulletSync.Write( ( PCHAR ) &sync, sizeof( stBulletData ) );
SF->getRakNet()->SendPacket( &BulletSync );
}
void OnFootSync(float CX,float CY,float CZ)
{
stOnFootData OF;
memset( &OF, 0, sizeof( stOnFootData ) );
OF.fPosition[0] = CX;
OF.fPosition[1] = CY;
OF.fPosition[2] = CZ;
BitStream OFsync;
OFsync.Write( ( BYTE ) ID_PLAYER_SYNC );
OFsync.Write( ( PCHAR ) &OF, sizeof( stOnFootData ) );
SF->getRakNet()->SendPacket( &OFsync );
}
Функция телепортирует игрока в определенную точку.
Код:void actor_teleport(float x, float y, float z) { actor_info *self = SF->getGame()->actorInfoGet(ACTOR_SELF, ACTOR_ALIVE); self->base.matrix[4 * 3] = x; self->base.matrix[4 * 3 + 1] = y; self->base.matrix[4 * 3 + 2] = z; }
#include "game_api\game_api.h"
PEDSELF->Teleport(x, y, z);
bool Driving(int PlayerID)
{
if (PlayerID == ACTOR_SELF) PlayerID = SF->getSAMP()->getPlayers()->sLocalPlayerID;
int state;
if (PlayerID == SF->getSAMP()->getPlayers()->sLocalPlayerID)
state = SF->getSAMP()->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped->state;
else
state = SF->getSAMP()->getPlayers()->pRemotePlayer[PlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->state;
if (state == 50)
return true;
else
return false;
};
bool isDriver(int PlayerID)
{
if (PlayerID == ACTOR_SELF) PlayerID = SF->getSAMP()->getPlayers()->sLocalPlayerID;
if (PlayerID == SF->getSAMP()->getPlayers()->sLocalPlayerID)
{
if (SF->getSAMP()->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped->state == 50)
if (SF->getSAMP()->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped->vehicle->passengers[0] == SF->getSAMP()->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped)
return true;
}
else
{
if (SF->getSAMP()->getPlayers()->pRemotePlayer[PlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->state == 50)
if (SF->getSAMP()->getPlayers()->pRemotePlayer[PlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->vehicle->passengers[0] == SF->getSAMP()->getPlayers()->pRemotePlayer[PlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped)
return true;
}
return false;
};
float getSkill(int weaponId)
{
float Skill = 1000.0f;
if ((weaponId >= 22) && (weaponId <= 32))
{
if (weaponId == 32)
weaponId -= 4;
Skill = *(float*)((weaponId - 22) * 4 + 0xB79494);
}
return Skill / 10.0f;
};
bool IsOnScreen(DWORD OBJECT)
{
DWORD dwFunc = FUNC_IsVisible;
DWORD dwThis = (DWORD)SF->getSAMP()->getInfo()->pPools->pObject->object[OBJECT]->pGTAEntity;
bool bReturn = false;
_asm
{
mov ecx, dwThis
call dwFunc
mov bReturn, al
}
return bReturn;
}
void VehTP(float x, float y, float z)
{
actor_info *self = SF->getGame()->actorInfoGet(VEHICLE_SELF, VEHICLE_ALIVE);
self->vehicle->base.matrix[4 * 3] = x;
self->vehicle->base.matrix[4 * 3 + 1] = y;
self->vehicle->base.matrix[4 * 3 + 2] = z;
}
PEDSELF->GetVehicle()->SetPosition(&CVector(0.0f, 0.0f, 0.0f));Телепортирует машину игрока
C++:void VehTP(float x, float y, float z) { actor_info *self = SF->getGame()->actorInfoGet(VEHICLE_SELF, VEHICLE_ALIVE); self->vehicle->base.matrix[4 * 3] = x; self->vehicle->base.matrix[4 * 3 + 1] = y; self->vehicle->base.matrix[4 * 3 + 2] = z; }
void mapMenuTeleport ( void )
{
if ( (*(int *)0xBA6774 != 0) )
{
// ty to Racer_S for this
float mapPos[3];
for ( int i = 0; i < (0xAF * 0x28); i += 0x28 )
{
if ( *(short *)(0xBA873D + i) == 4611 )
{
float *pos = (float *)( 0xBA86F8 + 0x28 + i );
mapPos[0] = *pos;
mapPos[1] = *( pos + 1 );
mapPos[2] = GAME->GetWorld()->FindGroundZForPosition(pos[0], pos[1]) + 2.0f;
PEDSELF->Teleport(mapPos[0], mapPos[1], mapPos[2]);
}
}
}
}
int GetWeaponID()
{
return PEDSELF->GetWeapon(PEDSELF->GetCurrentWeaponSlot())->GetType();
}
eWeaponState GetWeaponState()
{
return PEDSELF->GetWeapon(PEDSELF->GetCurrentWeaponSlot())->GetState();
}
int GetAmmoInClip()
{
return PEDSELF->GetWeapon(PEDSELF->GetCurrentWeaponSlot())->GetAmmoInClip();
}
int GetAmmoTotal()
{
return PEDSELF->GetWeapon(PEDSELF->GetCurrentWeaponSlot())->GetAmmoTotal();
}
int GetWantedLevel()
{
return *(DWORD*)0x58DB60;
}
void emulateRPC_giveweapon(uint32_t weapon_id, uint32_t ammo)
{
BitStream bsClass;
bsClass.Write(uint32_t(weapon_id)); // WeaponID
bsClass.Write(uint32_t(ammo)); // Ammo
SF->getRakNet()->emulateRecvRPC(22, &bsClass);
}
void emulateRPC_setskin(uint32_t player_id, uint32_t skin_id)
{
BitStream bsClass;
bsClass.Write(uint32_t(player_id));
bsClass.Write(uint32_t(skin_id));
SF->getRakNet()->emulateRecvRPC(153, &bsClass);
}
void send_onfootdata(float x, float y, float z)
{
if (BS->getPlugin()->actor_driving(-1)) return;
BitStream bsOnfootSync;
stOnFootData ofSync;
memset(&ofSync, 0, sizeof(stOnFootData));
ofSync.byteArmor = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteArmor;
ofSync.byteCurrentWeapon = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteCurrentWeapon;
ofSync.byteHealth = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteHealth;
ofSync.byteSpecialAction = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.byteSpecialAction;
ofSync.fMoveSpeed[0] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fMoveSpeed[0];
ofSync.fMoveSpeed[1] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fMoveSpeed[1];
ofSync.fMoveSpeed[2] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fMoveSpeed[2];
ofSync.fPosition[0] = x;
ofSync.fPosition[1] = y;
ofSync.fPosition[2] = z;
ofSync.fQuaternion[0] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[0];
ofSync.fQuaternion[1] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[1];
ofSync.fQuaternion[2] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[2];
ofSync.fQuaternion[3] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fQuaternion[3];
ofSync.fSurfingOffsets[0] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fSurfingOffsets[0];
ofSync.fSurfingOffsets[1] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fSurfingOffsets[1];
ofSync.fSurfingOffsets[2] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fSurfingOffsets[2];
ofSync.sAnimFlags = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sAnimFlags;
ofSync.sCurrentAnimationID = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sCurrentAnimationID;
ofSync.sKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sKeys;
ofSync.sLeftRightKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sLeftRightKeys;
ofSync.sSurfingVehicleID = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sSurfingVehicleID;
ofSync.stSampKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.stSampKeys;
ofSync.sUpDownKeys = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.sUpDownKeys;
bsOnfootSync.Write((BYTE)ID_PLAYER_SYNC);
bsOnfootSync.Write((PCHAR)&ofSync, sizeof(stOnFootData));
SF->getRakNet()->SendPacket(&bsOnfootSync);
}
void send_death(uint16_t player_id, uint8_t weapon)
{
BitStream bsDeath;
bsDeath.Write(weapon);
bsDeath.Write(player_id);
SF->getRakNet()->SendRPC(RPC_Death, &bsDeath);
}
void CalcScreenCoors(D3DXVECTOR3 *vecWorld, D3DXVECTOR3 *vecScreen)
{
D3DXMATRIX m((float *)(0xB6FA2C));
DWORD *dwLenX = (DWORD *)(0xC17044);
DWORD *dwLenY = (DWORD *)(0xC17048);
vecScreen->x = (vecWorld->z * m._31) + (vecWorld->y * m._21) + (vecWorld->x * m._11) + m._41;
vecScreen->y = (vecWorld->z * m._32) + (vecWorld->y * m._22) + (vecWorld->x * m._12) + m._42;
vecScreen->z = (vecWorld->z * m._33) + (vecWorld->y * m._23) + (vecWorld->x * m._13) + m._43;
double fRecip = (double)1.0 / vecScreen->z;
vecScreen->x *= (float)(fRecip * (*dwLenX));
vecScreen->y *= (float)(fRecip * (*dwLenY));
}
int GetPlayerTarget(int radius)
{
static int iX;
static int iY;
for (int i = 0; i < SAMP_MAX_PLAYERS; i++)
{
if (SF->getSAMP()->getPlayers()->iIsListed[i] != 1)
continue;
if (SF->getSAMP()->getPlayers()->pRemotePlayer[i] == NULL)
continue;
if (SF->getSAMP()->getPlayers()->pRemotePlayer[i]->pPlayerData == NULL || SF->getSAMP()->getPlayers()->pRemotePlayer[i]->pPlayerData->pSAMP_Actor == NULL)
continue;
D3DXVECTOR3 vecPos;
vecPos.x = SF->getSAMP()->getPlayers()->pRemotePlayer[i]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[12];
vecPos.y = SF->getSAMP()->getPlayers()->pRemotePlayer[i]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[13];
vecPos.z = SF->getSAMP()->getPlayers()->pRemotePlayer[i]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[14];
D3DXVECTOR3 screenPos;
CalcScreenCoors(&vecPos, &screenPos);
if (screenPos.z < 1.f)
continue;
iX = GetSystemMetrics(SM_CXSCREEN) * 0.5299999714f;
iY = GetSystemMetrics(SM_CYSCREEN) * 0.4f;
if ((screenPos.x >iX + (radius )) || (screenPos.y > iY + (radius )) || (screenPos.x < iX - (radius )) || (screenPos.y < iY - (radius )))
continue;
return i;
}
return -1;
}
static int iID = -1;
iID = GetPlayerTarget(50)