diff --git a/bot/main.h b/bot/main.h index 5b74f62..610061f 100644 --- a/bot/main.h +++ b/bot/main.h @@ -93,3 +93,40 @@ typedef struct _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; diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 055134b..0e0b66b 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -21,12 +21,6 @@ typedef struct _AIM_SYNC_DATA // size: 31 char _gap0[31]; } AIM_SYNC_DATA; -#pragma pack(1) -typedef struct _PASSENGER_SYNC_DATA // size: 24 -{ - char _gap0[24]; -} PASSENGER_SYNC_DATA; - #pragma pack(1) typedef struct _TRAILER_SYNC_DATA // size: 54 { @@ -38,10 +32,10 @@ PASSENGER_SYNC_DATA unnamed_5[MAX_PLAYERS]; char unnamed_9; BOOL bPlayerSlotState[MAX_PLAYERS]; ONFOOT_SYNC_DATA ofSync; -char unnamed_3[1000][68]; +ONFOOT_SYNC_DATA unnamed_3[MAX_PLAYERS]; BYTE bytePlayerState[MAX_PLAYERS]; BOOL bVehicleSlotState[MAX_VEHICLES]; -char unnamed_4[1000][63]; +INCAR_SYNC_DATA unnamed_4[MAX_PLAYERS]; BYTE byteMySeatID; bool bSpawned = false; @@ -78,6 +72,34 @@ BYTE CNetGame::GetPlayerState(PLAYERID 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 BOOL CNetGame::IsPlayerAdded(PLAYERID playerId) diff --git a/bot/net/netgame.h b/bot/net/netgame.h index ee2f042..c5f40e1 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -108,6 +108,7 @@ public: void SetVehicleAdded(VEHICLEID VehicleID, BOOL a2); void SetPlayerState(PLAYERID playerId, BYTE byteState); BYTE GetPlayerState(PLAYERID playerId); + BOOL GetPlayerPos(PLAYERID playerId, PVECTOR Vector); void StopRecordingPlayback(); void PauseRecordingPlayback(); void ResumeRecordingPlayback(); diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index 51bcf35..d0fc51a 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -145,7 +145,21 @@ static cell AMX_NATIVE_CALL n_GetPlayerState(AMX *amx, cell *params) // native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z) 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; }