mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-09-20 12:46:07 +08:00
[bot] Implement/match n_GetPlayerPos(...)
* Implement `CNetGame::GetPlayerPos(...)`
This commit is contained in:
37
bot/main.h
37
bot/main.h
@ -93,3 +93,40 @@ typedef struct _ONFOOT_SYNC_DATA
|
|||||||
|
|
||||||
} ONFOOT_SYNC_DATA;
|
} ONFOOT_SYNC_DATA;
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct _INCAR_SYNC_DATA
|
||||||
|
{
|
||||||
|
VEHICLEID VehicleID;
|
||||||
|
WORD lrAnalog;
|
||||||
|
WORD udAnalog;
|
||||||
|
WORD wKeys;
|
||||||
|
QUATERNION quatRotation;
|
||||||
|
VECTOR vecPos;
|
||||||
|
|
||||||
|
char _gap24[16];
|
||||||
|
|
||||||
|
BYTE bytePlayerHealth;
|
||||||
|
BYTE bytePlayerArmour;
|
||||||
|
BYTE byteCurrentWeapon : 6;
|
||||||
|
BYTE byteSpecialKey : 2;
|
||||||
|
|
||||||
|
char _gap37[8];
|
||||||
|
|
||||||
|
} INCAR_SYNC_DATA;
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct _PASSENGER_SYNC_DATA
|
||||||
|
{
|
||||||
|
VEHICLEID VehicleID;
|
||||||
|
|
||||||
|
char _gap2;
|
||||||
|
|
||||||
|
BYTE byteCurrentWeapon : 6;
|
||||||
|
BYTE byteSpecialKey : 2;
|
||||||
|
BYTE bytePlayerHealth;
|
||||||
|
BYTE bytePlayerArmour;
|
||||||
|
WORD lrAnalog;
|
||||||
|
WORD udAnalog;
|
||||||
|
WORD wKeys;
|
||||||
|
VECTOR vecPos;
|
||||||
|
} PASSENGER_SYNC_DATA;
|
||||||
|
@ -21,12 +21,6 @@ typedef struct _AIM_SYNC_DATA // size: 31
|
|||||||
char _gap0[31];
|
char _gap0[31];
|
||||||
} AIM_SYNC_DATA;
|
} AIM_SYNC_DATA;
|
||||||
|
|
||||||
#pragma pack(1)
|
|
||||||
typedef struct _PASSENGER_SYNC_DATA // size: 24
|
|
||||||
{
|
|
||||||
char _gap0[24];
|
|
||||||
} PASSENGER_SYNC_DATA;
|
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
typedef struct _TRAILER_SYNC_DATA // size: 54
|
typedef struct _TRAILER_SYNC_DATA // size: 54
|
||||||
{
|
{
|
||||||
@ -38,10 +32,10 @@ PASSENGER_SYNC_DATA unnamed_5[MAX_PLAYERS];
|
|||||||
char unnamed_9;
|
char unnamed_9;
|
||||||
BOOL bPlayerSlotState[MAX_PLAYERS];
|
BOOL bPlayerSlotState[MAX_PLAYERS];
|
||||||
ONFOOT_SYNC_DATA ofSync;
|
ONFOOT_SYNC_DATA ofSync;
|
||||||
char unnamed_3[1000][68];
|
ONFOOT_SYNC_DATA unnamed_3[MAX_PLAYERS];
|
||||||
BYTE bytePlayerState[MAX_PLAYERS];
|
BYTE bytePlayerState[MAX_PLAYERS];
|
||||||
BOOL bVehicleSlotState[MAX_VEHICLES];
|
BOOL bVehicleSlotState[MAX_VEHICLES];
|
||||||
char unnamed_4[1000][63];
|
INCAR_SYNC_DATA unnamed_4[MAX_PLAYERS];
|
||||||
BYTE byteMySeatID;
|
BYTE byteMySeatID;
|
||||||
|
|
||||||
bool bSpawned = false;
|
bool bSpawned = false;
|
||||||
@ -78,6 +72,34 @@ BYTE CNetGame::GetPlayerState(PLAYERID playerId)
|
|||||||
return bytePlayerState[playerId];
|
return bytePlayerState[playerId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL CNetGame::GetPlayerPos(PLAYERID playerId, PVECTOR Vector)
|
||||||
|
{
|
||||||
|
if(playerId >= MAX_PLAYERS || !bPlayerSlotState[playerId])
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
switch(bytePlayerState[playerId])
|
||||||
|
{
|
||||||
|
case PLAYER_STATE_ONFOOT:
|
||||||
|
Vector->X = unnamed_3[playerId].vecPos.X;
|
||||||
|
Vector->Y = unnamed_3[playerId].vecPos.Y;
|
||||||
|
Vector->Z = unnamed_3[playerId].vecPos.Z;
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case PLAYER_STATE_DRIVER:
|
||||||
|
Vector->X = unnamed_4[playerId].vecPos.X;
|
||||||
|
Vector->Y = unnamed_4[playerId].vecPos.Y;
|
||||||
|
Vector->Z = unnamed_4[playerId].vecPos.Z;
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case PLAYER_STATE_PASSENGER:
|
||||||
|
Vector->X = unnamed_5[playerId].vecPos.X;
|
||||||
|
Vector->Y = unnamed_5[playerId].vecPos.Y;
|
||||||
|
Vector->Z = unnamed_5[playerId].vecPos.Z;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
// MATCH
|
// MATCH
|
||||||
BOOL CNetGame::IsPlayerAdded(PLAYERID playerId)
|
BOOL CNetGame::IsPlayerAdded(PLAYERID playerId)
|
||||||
|
@ -108,6 +108,7 @@ public:
|
|||||||
void SetVehicleAdded(VEHICLEID VehicleID, BOOL a2);
|
void SetVehicleAdded(VEHICLEID VehicleID, BOOL a2);
|
||||||
void SetPlayerState(PLAYERID playerId, BYTE byteState);
|
void SetPlayerState(PLAYERID playerId, BYTE byteState);
|
||||||
BYTE GetPlayerState(PLAYERID playerId);
|
BYTE GetPlayerState(PLAYERID playerId);
|
||||||
|
BOOL GetPlayerPos(PLAYERID playerId, PVECTOR Vector);
|
||||||
void StopRecordingPlayback();
|
void StopRecordingPlayback();
|
||||||
void PauseRecordingPlayback();
|
void PauseRecordingPlayback();
|
||||||
void ResumeRecordingPlayback();
|
void ResumeRecordingPlayback();
|
||||||
|
@ -145,7 +145,21 @@ static cell AMX_NATIVE_CALL n_GetPlayerState(AMX *amx, cell *params)
|
|||||||
// native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z)
|
// native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z)
|
||||||
static cell AMX_NATIVE_CALL n_GetPlayerPos(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL n_GetPlayerPos(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
// TODO: n_GetPlayerPos
|
if(!pNetGame->GetPlayerPool()) return 0;
|
||||||
|
if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)params[1])) return 0;
|
||||||
|
|
||||||
|
VECTOR vecPos;
|
||||||
|
if(pNetGame->GetPlayerPos((PLAYERID)params[1], &vecPos))
|
||||||
|
{
|
||||||
|
cell* cptr;
|
||||||
|
amx_GetAddr(amx, params[2], &cptr);
|
||||||
|
*cptr = amx_ftoc(vecPos.X);
|
||||||
|
amx_GetAddr(amx, params[3], &cptr);
|
||||||
|
*cptr = amx_ftoc(vecPos.Y);
|
||||||
|
amx_GetAddr(amx, params[4], &cptr);
|
||||||
|
*cptr = amx_ftoc(vecPos.Z);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user