вот так я могу получить массу while true do wait(0) if isCharInAnyCar(playerPed) then…
- User
вот так я могу получить массу while true do wait(0) if isCharInAnyCar(playerPed) then local car = storeCarCharIsInNoSave(playerPed) if doesVehicleExist(car) then local carPointer = getCarPointer(car) local vehicle = samem.cast("CVehicle *", carPointer) if vehicle ~= samem.nullptr then if vehicle.nVehicleClass == 0 then -- na samom dele eto ne klass, a tip. VEHICLE_TYPE_AUTOMOBILE = 0 local automobile = samem.cast('CAutomobile *', vehicle)
local mass = automobile.fMass --print end end end end end--[[ Project: SA Memory (Available from https://blast.hk/) Developers: LUCHARE, FYP
Special thanks: plugin-sdk (https://github.com/DK22Pac/plugin-sdk) for the structures and addresses. Copyright (c) 2018 BlastHack.]]
local shared = require 'SAMemory.shared'
shared.require 'CDamageManager' shared.require 'CEntity' shared.require 'CDoor' shared.require 'CBouncingPanel' shared.require 'CColPoint' shared.require 'CVehicle' shared.require 'vector3d'
shared.ffi.cdef[[ typedef enum eCarNodes { CAR_NODE_NONE = 0, CAR_CHASSIS = 1, CAR_WHEEL_RF = 2, CAR_WHEEL_RM = 3, CAR_WHEEL_RB = 4, CAR_WHEEL_LF = 5, CAR_WHEEL_LM = 6, CAR_WHEEL_LB = 7, CAR_DOOR_RF = 8, CAR_DOOR_RR = 9, CAR_DOOR_LF = 10, CAR_DOOR_LR = 11, CAR_BUMP_FRONT = 12, CAR_BUMP_REAR = 13, CAR_WING_RF = 14, CAR_WING_LF = 15, CAR_BONNET = 16, CAR_BOOT = 17, CAR_WINDSCREEN = 18, CAR_EXHAUST = 19, CAR_MISC_A = 20, CAR_MISC_B = 21, CAR_MISC_C = 22, CAR_MISC_D = 23, CAR_MISC_E = 24, CAR_NUNODES } eCarNodes;
typedef struct CAutomobile : CVehicle { CDamageManager damageManager; CDoor doors[6]; RwFrame *pCarNodes[CAR_NUNODES]; CBouncingPanel panels[3]; CDoor swingingChassis; CColPoint wheelColPoint[4]; float wheelsDistancesToGround1[4]; float wheelsDistancesToGround2[4]; float field_7F4[4]; float field_800; float field_804; float field_80C; int field_810[4]; char field_81C[4]; int field_820; float fWheelRotation[4]; float field_838[4]; float fWheelSpeed[4]; int field_858[4]; char taxiAvaliable; char field_869; char field_86A; char field_867; short wMiscComponentAngle; short wVoodooSuspension; int dwBusDoorTimerEnd; int dwBusDoorTimerStart; float field_878; float wheelOffsetZ[4]; int field_88C[3]; float fFrontHeightAboveRoad; float fRearHeightAboveRoad; float fCarTraction; float fNitroValue; int field_8A4; int fRotationBalance; float fMoveDirection; int field_8B4[6]; int field_8C8[6]; int dwBurnTimer; CEntity *pWheelCollisionEntity[4]; vector3d vWheelCollisionPos[4]; char field_924; char field_925; char field_926; char field_927; char field_928; char field_929; char field_92A; char field_92B; char field_92C; char field_92D; char field_92E; char field_92F; char field_930; char field_931; char field_932; char field_933; char field_934; char field_935; char field_936; char field_937; char field_938; char field_939; char field_93A; char field_93B; char field_93C; char field_93D; char field_93E; char field_93F; int field_940; int field_944; float fDoomVerticalRotation; float fDoomHorizontalRotation; float fForcedOrientation; float fUpDownLightAngle[2]; unsigned char nNumContactWheels; unsigned char nWheelsOnGround; char field_962; char field_963; float field_964; int field_968[4]; void *pNitroParticle[2]; char field_980; char field_981; short field_982; float field_984; } CAutomobile;]]
shared.validate_size('CAutomobile', 0x988)
а как мне получить nCurrentGear отсюда?
--[[ Project: SA Memory (Available from https://blast.hk/) Developers: LUCHARE, FYP
Special thanks: plugin-sdk (https://github.com/DK22Pac/plugin-sdk) for the structures and addresses. Copyright (c) 2018 BlastHack.]]
local shared = require 'SAMemory.shared'
shared.require 'RenderWare' shared.require 'CPhysical' shared.require 'CAEVehicleAudioEntity' shared.require 'tHandlingData' shared.require 'tFlyingHandlingData' shared.require 'CAutoPilot' shared.require 'CPed' shared.require 'CEntity' shared.require 'CFire' shared.require 'CStoredCollPoly' shared.require 'FxSystem_c'
shared.ffi.cdef[[ typedef enum eCarWeapon { CAR_WEAPON_NOT_USED, CAR_WEAPON_HEAVY_GUN, CAR_WEAPON_FREEFALL_BOMB, CAR_WEAPON_LOCK_ON_ROCKET, CAR_WEAPON_DOUBLE_ROCKET } eCarWeapon;
typedef enum eCarLock { CARLOCK_NOT_USED, CARLOCK_UNLOCKED, CARLOCK_LOCKED, CARLOCK_LOCKOUT_PLAYER_ONLY, CARLOCK_LOCKED_PLAYER_INSIDE, CARLOCK_COP_CAR, CARLOCK_FORCE_SHUT_DOORS, CARLOCK_SKIP_SHUT_DOORS } eCarLock; typedef enum eVehicleType { VEHICLE_AUTOMOBILE, VEHICLE_MTRUCK, VEHICLE_QUAD, VEHICLE_HELI, VEHICLE_PLANE, VEHICLE_BOAT, VEHICLE_TRAIN, VEHICLE_FHELI, VEHICLE_FPLANE, VEHICLE_BIKE, VEHICLE_BMX, VEHICLE_TRAILER } eVehicleType; typedef enum eVehicleApperance { VEHICLE_APPEARANCE_AUTOMOBILE = 1, VEHICLE_APPEARANCE_BIKE, VEHICLE_APPEARANCE_HELI, VEHICLE_APPEARANCE_BOAT, VEHICLE_APPEARANCE_PLANE, } eVehicleApperance; typedef enum eVehicleLightsFlags { VEHICLE_LIGHTS_TWIN = 1, VEHICLE_LIGHTS_IGNORE_DAMAGE = 4, VEHICLE_LIGHTS_DISABLE_FRONT = 16, VEHICLE_LIGHTS_DISABLE_REAR = 32 } eVehicleLightsFlags; typedef enum eVehicleCreatedBy { RANDOVEHICLE = 0, MISSION_VEHICLE = 2, PARKED_VEHICLE = 3, PERMANENT_VEHICLE = 4 } eVehicleCreatedBy; typedef enum eBombState { BOMB_TIMED_NOT_ACTIVATED = 1, BOMB_IGNITION = 2, BOMB_STICKY = 3, BOMB_TIMED_ACTIVATED = 4, BOMB_IGNITION_ACTIVATED = 5 } eBombState; typedef struct CVehicle CVehicle; struct CVehicle : CPhysical { CAEVehicleAudioEntity vehicleAudio; tHandlingData *pHandlingData; tFlyingHandlingData *pFlyingHandlingData; union { eVehicleHandlingFlags nHandlingFlagsIntValue; struct { unsigned int b1gBoost : 1; unsigned int b2gBoost : 1; unsigned int bNpcAntiRoll : 1; unsigned int bNpcNeutralHandl : 1; unsigned int bNoHandbrake : 1; unsigned int bSteerRearwheels : 1; unsigned int bHbRearwheelSteer : 1; unsigned int bAltSteerOpt : 1; unsigned int bWheelFNarrow2 : 1; unsigned int bWheelFNarrow : 1; unsigned int bWheelFWide : 1; unsigned int bWheelFWide2 : 1; unsigned int bWheelRNarrow2 : 1; unsigned int bWheelRNarrow : 1; unsigned int bWheelRWide : 1; unsigned int bWheelRWide2 : 1; unsigned int bHydraulicGeom : 1; unsigned int bHydraulicInst : 1; unsigned int bHydraulicNone : 1; unsigned int bNosInst : 1; unsigned int bOffroadAbility : 1; unsigned int bOffroadAbility2 : 1; unsigned int bHalogenLights : 1; unsigned int bProcRearwheelFirst : 1; unsigned int bUseMaxspLimit : 1; unsigned int bLowRider : 1; unsigned int bStreetRacer : 1; unsigned int bSwingingChassis : 1; } nHandlingFlags; }; CAutoPilot autoPilot; struct { unsigned char bIsLawEnforcer : 1; unsigned char bIsAmbulanceOnDuty : 1; unsigned char bIsFireTruckOnDuty : 1; unsigned char bIsLocked : 1; unsigned char bEngineOn : 1; unsigned char bIsHandbrakeOn : 1; unsigned char bLightsOn : 1; unsigned char bFreebies : 1; unsigned char bIsVan : 1; unsigned char bIsBus : 1; unsigned char bIsBig : 1; unsigned char bLowVehicle : 1; unsigned char bComedyControls : 1; unsigned char bWarnedPeds : 1; unsigned char bCraneMessageDone : 1; unsigned char bTakeLessDamage : 1; unsigned char bIsDamaged : 1; unsigned char bHasBeenOwnedByPlayer : 1; unsigned char bFadeOut : 1; unsigned char bIsBeingCarJacked : 1; unsigned char bCreateRoadBlockPeds : 1; unsigned char bCanBeDamaged : 1; unsigned char bOccupantsHaveBeenGenerated : 1; unsigned char bGunSwitchedOff : 1; unsigned char bVehicleColProcessed : 1; unsigned char bIsCarParkVehicle : 1; unsigned char bHasAlreadyBeenRecorded : 1; unsigned char bPartOfConvoy : 1; unsigned char bHeliMinimumTilt : 1; unsigned char bAudioChangingGear : 1; unsigned char bIsDrowning : 1; unsigned char bTyresDontBurst : 1; unsigned char bCreatedAsPoliceVehicle : 1; unsigned char bRestingOnPhysical : 1; unsigned char bParking : 1; unsigned char bCanPark : 1; unsigned char bFireGun : 1; unsigned char bDriverLastFrame : 1; unsigned char bNeverUseSmallerRemovalRange : 1; unsigned char bIsRCVehicle : 1; unsigned char bAlwaysSkidMarks : 1; unsigned char bEngineBroken : 1; unsigned char bVehicleCanBeTargetted : 1; unsigned char bPartOfAttackWave : 1; unsigned char bWinchCanPickMeUp : 1; unsigned char bImpounded : 1; unsigned char bVehicleCanBeTargettedByHS : 1; unsigned char bSirenOrAlarm : 1; unsigned char bHasGangLeaningOn : 1; unsigned char bGangMembersForRoadBlock : 1; unsigned char bDoesProvideCover : 1; unsigned char bMadDriver : 1; unsigned char bUpgradedStereo : 1; unsigned char bConsideredByPlayer : 1; unsigned char bPetrolTankIsWeakPoint : 1; unsigned char bDisableParticles : 1; unsigned char bHasBeenResprayed : 1; unsigned char bUseCarCheats : 1; unsigned char bDontSetColourWhenRemapping : 1; unsigned char bUsedForReplay : 1; } nFlags; unsigned int nCreationTime; unsigned char nPrimaryColor; unsigned char nSecondaryColor; unsigned char nTertiaryColor; unsigned char nQuaternaryColor; char anExtras[2]; short anUpgrades[15]; float fWheelScale; unsigned short nAlarmState; short nForcedRandomRouteSeed; CPed *pDriver; CPed *apPassengers[8]; unsigned char nNumPassengers; unsigned char nNumGettingIn; unsigned char nGettingInFlags; unsigned char nGettingOutFlags; unsigned char nMaxPassengers; unsigned char nWindowsOpenFlags; unsigned char nNitroBoosts; unsigned char nSpecialColModel; CEntity *pEntityWeAreOn; CFire *pFire; float fSteerAngle; float f2ndSteerAngle; float fGasPedal; float fBreakPedal; unsigned char nCreatedBy; short nExtendedRemovalRange; unsigned char nBombOnBoard : 3; unsigned char nOverrideLights : 2; unsigned char nWinchType : 2; unsigned char nGunsCycleIndex : 2; unsigned char nOrdnanceCycleIndex : 2; unsigned char nUsedForCover; unsigned char nAmmoInClip; unsigned char nPacMansCollected; unsigned char nPedsPositionForRoadBlock; unsigned char nNumCopsForRoadBlock; float fDirtLevel; unsigned char nCurrentGear; float fGearChangeCount; float fWheelSpinForAudio; float fHealth; CVehicle *pTractor; CVehicle *pTrailer; CPed *pWhoInstalledBombOnMe; unsigned int nTimeTillWeNeedThisCar; unsigned int nGunFiringTime; unsigned int nTimeWhenBlowedUp; short nCopsInCarTimer; short wBombTimer; CPed *pWhoDetonatedMe; float fVehicleFrontGroundZ; float fVehicleRearGroundZ; char field_4EC; char field_4ED[11]; unsigned int nDoorLock; unsigned int nProjectileWeaponFiringTime; unsigned int nAdditionalProjectileWeaponFiringTime; unsigned int nTimeForMinigunFiring; unsigned char nLastWeaponDamageType; CEntity *pLastDamageEntity; char field_510; char field_511; char field_512; char nVehicleWeaponInUse; unsigned int nHornCounter; char field_518; char field_519; char field_51A; char nHasslePosId; CStoredCollPoly FrontCollPoly; CStoredCollPoly RearCollPoly; unsigned char anCollisionLighting[4]; FxSystem_c *pOverheatParticle; FxSystem_c *pFireParticle; FxSystem_c *pDustParticle; union { unsigned char nRenderLightsFlags; struct { unsigned char bRightFront : 1; unsigned char bLeftFront : 1; unsigned char bRightRear : 1; unsigned char bLeftRear : 1; } renderLights; }; RwTexture *pCustomCarPlate; CVehicle *field_58C; unsigned int nVehicleClass; unsigned int nVehicleSubClass; short nPreviousRemapTxd; short nRemapTxd; RwTexture *pRemapTexture; };]]
shared.validate_size('CVehicle', 0x5A0)
- Assistant
To access the
nCurrentGearproperty for a vehicle in your code, you need to navigate through theCAutomobileorCVehiclestructure where this property is located.Given your code structure, you are already accessing the
CAutomobileobject and its properties. ThenCurrentGearproperty is part of theCVehiclestructure, which is a base part of theCAutomobilestructure. So you can access it directly from theautomobileobject you already have.Here's how you can retrieve the
nCurrentGearvalue:while true do wait(0) if isCharInAnyCar(playerPed) then local car = storeCarCharIsInNoSave(playerPed) if doesVehicleExist(car) then local carPointer = getCarPointer(car) local vehicle = samem.cast("CVehicle *", carPointer) if vehicle ~= samem.nullptr then if vehicle.nVehicleClass == 0 then -- VEHICLE_TYPE_AUTOMOBILE = 0 local automobile = samem.cast('CAutomobile *', vehicle) -- Get the mass local mass = automobile.fMass -- Get the current gear local currentGear = automobile.nCurrentGear -- Print or use the current gear value print("Current Gear: ", currentGear) end end end end endNote:
- Ensure that the
CVehiclestructure in memory and its offsets are correctly defined so that accessingnCurrentGeardoesn't cause a segmentation fault or invalid access. - The offset for
nCurrentGearis correct as defined byfloat fDirtLevel; unsigned char nCurrentGear;in theCVehiclestruct, and it should be consistent with your FFI definitions.
- Ensure that the
- User
/* Plugin-SDK file Authors: GTA Community. See more here https://github.com/DK22Pac/plugin-sdk Do not delete this comment block. Respect others' work! */ #pragma once
#include "Automobile.h"
enum ePlaneNodes { PLANE_NODE_NONE = 0, PLANE_CHASSIS = 1, PLANE_WHEEL_RF = 2, PLANE_WHEEL_RM = 3, PLANE_WHEEL_RB = 4, PLANE_WHEEL_LF = 5, PLANE_WHEEL_LM = 6, PLANE_WHEEL_LB = 7, PLANE_DOOR_RF = 8, PLANE_DOOR_RR = 9, PLANE_DOOR_LF = 10, PLANE_DOOR_LR = 11, PLANE_STATIC_PROP = 12, PLANE_MOVING_PROP = 13, PLANE_STATIC_PROP2 = 14, PLANE_MOVING_PROP2 = 15, PLANE_RUDDER = 16, PLANE_ELEVATOR_L = 17, PLANE_ELEVATOR_R = 18, PLANE_AILERON_L = 19, PLANE_AILERON_R = 20, PLANE_GEAR_L = 21, PLANE_GEAR_R = 22, PLANE_MISC_A = 23, PLANE_MISC_B = 24, PLANE_NUM_NODES };
class NOTSA_EXPORT_VTABLE CPlane : public CAutomobile { public: float m_fLeftRightSkid; float m_fSteeringUpDown; float m_fSteeringLeftRight; float m_fAccelerationBreakStatus; float m_fAccelerationBreakStatusPrev; float m_fSteeringFactor; float field_9A0; float m_planeCreationHeading; // The heading when plane is created or placed on road properly float m_maxAltitude; float m_altitude; float m_minAltitude; float m_planeHeading; float m_planeHeadingPrev; float m_forwardZ; uint32 m_nStartedFlyingTime; float m_fPropSpeed; float field_9C8; float m_fLandingGearStatus; int32 m_planeDamageWave; FxSystem_c** m_pGunParticles; uint8 m_nFiringMultiplier; int32 field_9DC; int32 field_9E0; int32 field_9E4; std::array<FxSystem_c*, 4> m_apJettrusParticles; FxSystem_c* m_pSmokeParticle; uint32 m_nSmokeTimer; bool m_bSmokeEjectorEnabled;
static constexpr auto Type = VEHICLE_TYPE_PLANE;public: static int32& GenPlane_ModelIndex; static uint32& GenPlane_Status; static uint32& GenPlane_LastTimeGenerated;
static bool& GenPlane_Active; static float& ANDROM_COL_ANGLE_MULT; static uint16& HARRIER_NOZZLE_ROTATE_LIMIT; static uint16& HARRIER_NOZZLE_SWITCH_LIMIT; static float& PLANE_MIN_PROP_SPEED; static float& PLANE_STD_PROP_SPEED; static float& PLANE_MAX_PROP_SPEED; static float& PLANE_ROC_PROP_SPEED;public: CPlane(int32 modelIndex, eVehicleCreatedBy createdBy); ~CPlane() override;
bool SetUpWheelColModel(CColModel* wheelCol) override; bool BurstTyre(uint8 tyreComponentId, bool bPhysicalEffect) override; void ProcessControl() override; void ProcessControlInputs(uint8 playerNum) override; void ProcessFlyingCarStuff() override; void PreRender() override; void Render() override; void BlowUpCar(CEntity* damager, bool bHideExplosion) override; void Fix() override; void OpenDoor(CPed* ped, int32 componentId, eDoors door, float doorOpenRatio, bool playSound) override; void SetupDamageAfterLoad() override; void VehicleDamage(float damageIntensity, eVehicleCollisionComponent component, CEntity* damager, CVector* vecCollisionCoors, CVector* vecCollisionDirection, eWeaponType weapon) override; static void InitPlaneGenerationAndRemoval(); void IsAlreadyFlying(); void SetGearUp(); void SetGearDown(); static uint32 CountPlanesAndHelis(); static bool AreWeInNoPlaneZone(); static bool AreWeInNoBigPlaneZone(); static void SwitchAmbientPlanes(bool enable); static void FindPlaneCreationCoors(CVector* center, CVector* playerCoords, float* outHeading, float* outHeight, bool arg4); static void DoPlaneGenerationAndRemoval();private: friend void InjectHooksMain(); static void InjectHooks();
CPlane* Constructor(int32 modelIndex, eVehicleCreatedBy createdBy) { this->CPlane::CPlane(modelIndex, createdBy); return this; } CPlane* Destroy() { this->CPlane::~CPlane(); return this; }};
VALIDATE_SIZE(CPlane, 0xA04);
тут есть что нибудь указывающее на макс скорость?
- Assistant
In the
CPlaneclass you've provided, there are several properties related to speed and flight dynamics, but none explicitly named as "max speed." However, you can infer some aspects of the plane's performance from existing properties:-
m_fPropSpeed: This property likely represents the speed of the plane's propeller. While it doesn't directly indicate the plane's maximum speed, it could be a factor influencing it. -
PLANE_MIN_PROP_SPEED,PLANE_STD_PROP_SPEED,PLANE_MAX_PROP_SPEED, andPLANE_ROC_PROP_SPEED: These variables seem to be static properties related to propeller speed. The namePLANE_MAX_PROP_SPEEDsuggests it could relate to the maximum speed of the plane's propeller, which might indirectly impact the plane's maximum speed. -
m_fAccelerationBreakStatusandm_fAccelerationBreakStatusPrev: These floating-point variables might relate to the acceleration or speed modifier, possibly affecting how quickly the plane can reach its top speed or decelerate.
Ultimately, determining maximum speed might require seeing how these factors interrelate within the game's engine. It could also involve referencing the handling or mechanics configuration data that the SDK or game uses. You might want to check handling files or related sections in the SDK documentation for explicit maximum speed definitions for aircraft in Grand Theft Auto.
-
- User
а вот тут вот есть --[[ Project: SA Memory (Available from https://blast.hk/) Developers: LUCHARE, FYP
Special thanks: plugin-sdk (https://github.com/DK22Pac/plugin-sdk) for the structures and addresses. Copyright (c) 2018 BlastHack.]]
local shared = require 'SAMemory.shared'
shared.require 'RenderWare' shared.require 'CPhysical' shared.require 'CAEVehicleAudioEntity' shared.require 'tHandlingData' shared.require 'tFlyingHandlingData' shared.require 'CAutoPilot' shared.require 'CPed' shared.require 'CEntity' shared.require 'CFire' shared.require 'CStoredCollPoly' shared.require 'FxSystem_c'
shared.ffi.cdef[[ typedef enum eCarWeapon { CAR_WEAPON_NOT_USED, CAR_WEAPON_HEAVY_GUN, CAR_WEAPON_FREEFALL_BOMB, CAR_WEAPON_LOCK_ON_ROCKET, CAR_WEAPON_DOUBLE_ROCKET } eCarWeapon;
typedef enum eCarLock { CARLOCK_NOT_USED, CARLOCK_UNLOCKED, CARLOCK_LOCKED, CARLOCK_LOCKOUT_PLAYER_ONLY, CARLOCK_LOCKED_PLAYER_INSIDE, CARLOCK_COP_CAR, CARLOCK_FORCE_SHUT_DOORS, CARLOCK_SKIP_SHUT_DOORS } eCarLock; typedef enum eVehicleType { VEHICLE_AUTOMOBILE, VEHICLE_MTRUCK, VEHICLE_QUAD, VEHICLE_HELI, VEHICLE_PLANE, VEHICLE_BOAT, VEHICLE_TRAIN, VEHICLE_FHELI, VEHICLE_FPLANE, VEHICLE_BIKE, VEHICLE_BMX, VEHICLE_TRAILER } eVehicleType; typedef enum eVehicleApperance { VEHICLE_APPEARANCE_AUTOMOBILE = 1, VEHICLE_APPEARANCE_BIKE, VEHICLE_APPEARANCE_HELI, VEHICLE_APPEARANCE_BOAT, VEHICLE_APPEARANCE_PLANE, } eVehicleApperance; typedef enum eVehicleLightsFlags { VEHICLE_LIGHTS_TWIN = 1, VEHICLE_LIGHTS_IGNORE_DAMAGE = 4, VEHICLE_LIGHTS_DISABLE_FRONT = 16, VEHICLE_LIGHTS_DISABLE_REAR = 32 } eVehicleLightsFlags; typedef enum eVehicleCreatedBy { RANDOVEHICLE = 0, MISSION_VEHICLE = 2, PARKED_VEHICLE = 3, PERMANENT_VEHICLE = 4 } eVehicleCreatedBy; typedef enum eBombState { BOMB_TIMED_NOT_ACTIVATED = 1, BOMB_IGNITION = 2, BOMB_STICKY = 3, BOMB_TIMED_ACTIVATED = 4, BOMB_IGNITION_ACTIVATED = 5 } eBombState; typedef struct CVehicle CVehicle; struct CVehicle : CPhysical { CAEVehicleAudioEntity vehicleAudio; tHandlingData *pHandlingData; tFlyingHandlingData *pFlyingHandlingData; union { eVehicleHandlingFlags nHandlingFlagsIntValue; struct { unsigned int b1gBoost : 1; unsigned int b2gBoost : 1; unsigned int bNpcAntiRoll : 1; unsigned int bNpcNeutralHandl : 1; unsigned int bNoHandbrake : 1; unsigned int bSteerRearwheels : 1; unsigned int bHbRearwheelSteer : 1; unsigned int bAltSteerOpt : 1; unsigned int bWheelFNarrow2 : 1; unsigned int bWheelFNarrow : 1; unsigned int bWheelFWide : 1; unsigned int bWheelFWide2 : 1; unsigned int bWheelRNarrow2 : 1; unsigned int bWheelRNarrow : 1; unsigned int bWheelRWide : 1; unsigned int bWheelRWide2 : 1; unsigned int bHydraulicGeom : 1; unsigned int bHydraulicInst : 1; unsigned int bHydraulicNone : 1; unsigned int bNosInst : 1; unsigned int bOffroadAbility : 1; unsigned int bOffroadAbility2 : 1; unsigned int bHalogenLights : 1; unsigned int bProcRearwheelFirst : 1; unsigned int bUseMaxspLimit : 1; unsigned int bLowRider : 1; unsigned int bStreetRacer : 1; unsigned int bSwingingChassis : 1; } nHandlingFlags; }; CAutoPilot autoPilot; struct { unsigned char bIsLawEnforcer : 1; unsigned char bIsAmbulanceOnDuty : 1; unsigned char bIsFireTruckOnDuty : 1; unsigned char bIsLocked : 1; unsigned char bEngineOn : 1; unsigned char bIsHandbrakeOn : 1; unsigned char bLightsOn : 1; unsigned char bFreebies : 1; unsigned char bIsVan : 1; unsigned char bIsBus : 1; unsigned char bIsBig : 1; unsigned char bLowVehicle : 1; unsigned char bComedyControls : 1; unsigned char bWarnedPeds : 1; unsigned char bCraneMessageDone : 1; unsigned char bTakeLessDamage : 1; unsigned char bIsDamaged : 1; unsigned char bHasBeenOwnedByPlayer : 1; unsigned char bFadeOut : 1; unsigned char bIsBeingCarJacked : 1; unsigned char bCreateRoadBlockPeds : 1; unsigned char bCanBeDamaged : 1; unsigned char bOccupantsHaveBeenGenerated : 1; unsigned char bGunSwitchedOff : 1; unsigned char bVehicleColProcessed : 1; unsigned char bIsCarParkVehicle : 1; unsigned char bHasAlreadyBeenRecorded : 1; unsigned char bPartOfConvoy : 1; unsigned char bHeliMinimumTilt : 1; unsigned char bAudioChangingGear : 1; unsigned char bIsDrowning : 1; unsigned char bTyresDontBurst : 1; unsigned char bCreatedAsPoliceVehicle : 1; unsigned char bRestingOnPhysical : 1; unsigned char bParking : 1; unsigned char bCanPark : 1; unsigned char bFireGun : 1; unsigned char bDriverLastFrame : 1; unsigned char bNeverUseSmallerRemovalRange : 1; unsigned char bIsRCVehicle : 1; unsigned char bAlwaysSkidMarks : 1; unsigned char bEngineBroken : 1; unsigned char bVehicleCanBeTargetted : 1; unsigned char bPartOfAttackWave : 1; unsigned char bWinchCanPickMeUp : 1; unsigned char bImpounded : 1; unsigned char bVehicleCanBeTargettedByHS : 1; unsigned char bSirenOrAlarm : 1; unsigned char bHasGangLeaningOn : 1; unsigned char bGangMembersForRoadBlock : 1; unsigned char bDoesProvideCover : 1; unsigned char bMadDriver : 1; unsigned char bUpgradedStereo : 1; unsigned char bConsideredByPlayer : 1; unsigned char bPetrolTankIsWeakPoint : 1; unsigned char bDisableParticles : 1; unsigned char bHasBeenResprayed : 1; unsigned char bUseCarCheats : 1; unsigned char bDontSetColourWhenRemapping : 1; unsigned char bUsedForReplay : 1; } nFlags; unsigned int nCreationTime; unsigned char nPrimaryColor; unsigned char nSecondaryColor; unsigned char nTertiaryColor; unsigned char nQuaternaryColor; char anExtras[2]; short anUpgrades[15]; float fWheelScale; unsigned short nAlarmState; short nForcedRandomRouteSeed; CPed *pDriver; CPed *apPassengers[8]; unsigned char nNumPassengers; unsigned char nNumGettingIn; unsigned char nGettingInFlags; unsigned char nGettingOutFlags; unsigned char nMaxPassengers; unsigned char nWindowsOpenFlags; unsigned char nNitroBoosts; unsigned char nSpecialColModel; CEntity *pEntityWeAreOn; CFire *pFire; float fSteerAngle; float f2ndSteerAngle; float fGasPedal; float fBreakPedal; unsigned char nCreatedBy; short nExtendedRemovalRange; unsigned char nBombOnBoard : 3; unsigned char nOverrideLights : 2; unsigned char nWinchType : 2; unsigned char nGunsCycleIndex : 2; unsigned char nOrdnanceCycleIndex : 2; unsigned char nUsedForCover; unsigned char nAmmoInClip; unsigned char nPacMansCollected; unsigned char nPedsPositionForRoadBlock; unsigned char nNumCopsForRoadBlock; float fDirtLevel; unsigned char nCurrentGear; float fGearChangeCount; float fWheelSpinForAudio; float fHealth; CVehicle *pTractor; CVehicle *pTrailer; CPed *pWhoInstalledBombOnMe; unsigned int nTimeTillWeNeedThisCar; unsigned int nGunFiringTime; unsigned int nTimeWhenBlowedUp; short nCopsInCarTimer; short wBombTimer; CPed *pWhoDetonatedMe; float fVehicleFrontGroundZ; float fVehicleRearGroundZ; char field_4EC; char field_4ED[11]; unsigned int nDoorLock; unsigned int nProjectileWeaponFiringTime; unsigned int nAdditionalProjectileWeaponFiringTime; unsigned int nTimeForMinigunFiring; unsigned char nLastWeaponDamageType; CEntity *pLastDamageEntity; char field_510; char field_511; char field_512; char nVehicleWeaponInUse; unsigned int nHornCounter; char field_518; char field_519; char field_51A; char nHasslePosId; CStoredCollPoly FrontCollPoly; CStoredCollPoly RearCollPoly; unsigned char anCollisionLighting[4]; FxSystem_c *pOverheatParticle; FxSystem_c *pFireParticle; FxSystem_c *pDustParticle; union { unsigned char nRenderLightsFlags; struct { unsigned char bRightFront : 1; unsigned char bLeftFront : 1; unsigned char bRightRear : 1; unsigned char bLeftRear : 1; } renderLights; }; RwTexture *pCustomCarPlate; CVehicle *field_58C; unsigned int nVehicleClass; unsigned int nVehicleSubClass; short nPreviousRemapTxd; short nRemapTxd; RwTexture *pRemapTexture; };]]
shared.validate_size('CVehicle', 0x5A0)
autoPilot
Как мне его использовать и менять там тип значения
- Assistant
The
autoPilotfield in theCVehiclestructure represents an instance of theCAutoPilotclass or structure, which typically manages a vehicle's autonomous behavior in Grand Theft Auto games. TheCAutoPilotstructure controls aspects like pathfinding, driving behavior, and destination handling for non-player vehicles. To modify or use this field programmatically, you need to understand theCAutoPilotstructure and its members.Steps to Use and Modify
autoPilot:-
Understand the
CAutoPilotStructure: Ensure you have the structure definition forCAutoPilotfrom the SDK or related resources, as it will detail the properties and methods available for use. This might include fields for speed, target positions, and behavior flags. -
Accessing the
autoPilotField: You can interact with theautoPilotfield similar to how you access other structure fields in the FFI setup. In Lua, using an FFI-based approach, you would typically cast theCVehiclepointer to accessCAutoPilotfields. -
Sample Code to Access and Modify
autoPilot: Assuming you have correctly definedCAutoPilotand the necessary fields:-- Access the vehicle local vehicle = samem.cast("CVehicle *", carPointer) -- Ensure the vehicle and autopilot are valid if vehicle ~= samem.nullptr and vehicle.autoPilot ~= nil then local autoPilot = vehicle.autoPilot -- Example: Modify a field in the AutoPilot structure -- Assume 'destination' is a field within 'CAutoPilot' autoPilot.destination.x = newX autoPilot.destination.y = newY autoPilot.destination.z = newZ -- Example: Toggle an autopilot behavior flag -- Ensure the flag exists in your CAutoPilot definition autoPilot.someBehaviorFlag = 1 -- Turn on some behavior end -
Define
CAutoPilotStructure: Make sure you have theCAutoPilotstructure definition included in your project. This definition should cover all the fields and enable you to adjust or read data from theautoPilotinstance. This might look something like:shared.ffi.cdef[[ typedef struct CAutoPilot { float speed; vector3d destination; int behaviorFlags; // other fields... } CAutoPilot; ]] -
Compile and Test: After setting up the definitions and writing the code, compile if necessary and test to ensure your changes take effect as expected.
Note:
- Dependencies: Ensure all required libraries and dependencies for manipulating vehicles and structures in memory are available.
- Game Modifications: Modifying autopilot settings might affect gameplay. Do this responsibly, especially if others will use the tool or mod you are developing.
- Safety and Validity: Always check for null pointers and handle exceptions or errors that may arise from memory access violations.
-
- User
--[[ Project: SA Memory (Available from https://blast.hk/) Developers: LUCHARE, FYP
Special thanks: plugin-sdk (https://github.com/DK22Pac/plugin-sdk) for the structures and addresses. Copyright (c) 2018 BlastHack.]]
local shared = require 'SAMemory.shared'
shared.require 'vector3d' shared.require 'CVehicle' shared.require 'CEntity'
shared.ffi.cdef[[ typedef struct CNodeAddress { short wAreaId; short wNodeId; } CNodeAddress;
typedef struct CCarPathLinkAddress { short wCarPathLinkId : 10; short wAreaId : 6; } CCarPathLinkAddress; typedef struct CAutoPilot { CNodeAddress currentAddress; CNodeAddress startingRouteNode; CNodeAddress field_8; int field_C; unsigned int nSpeedScaleFactor; CCarPathLinkAddress nCurrentPathNodeInfo; CCarPathLinkAddress nNextPathNodeInfo; CCarPathLinkAddress nPreviousPathNodeInfo; char field_1A[2]; unsigned int nTimeToStartMission; unsigned int nTimeSwitchedToRealPhysics; char field_24; char _smthCurr; char _smthNext; char nCurrentLane; char nNextLane; char nCarDrivingStyle; char nCarMission; char nTempAction; unsigned int nTempActionTime; unsigned int _someStartTime; char field_34; char field_35; char field_36[2]; float field_38; float fMaxTrafficSpeed; char nCruiseSpeed; char field_41; char field_42[2]; float field_44; char field_48[1]; char field_49; char field_4A; unsigned char nCarCtrlFlags; char field_4C; char nStraightLineDistance; char field_4E; char field_4F; char field_50; char field_51; char field_52[10]; vector3d vecDestinationCoors; CNodeAddress aPathFindNodesInfo[8]; unsigned short nPathFindNodesCount; char field_8A[2]; struct CVehicle *pTargetCar; struct CEntity *pCarWeMakingSlowDownFor; char field_94; char field_95; short field_96; } CAutoPilot;]]
shared.validate_size('CAutoPilot', 0x98)
- Assistant
The
CAutoPilotstructure you've provided represents the autopilot system for vehicles in the game, which manages its pathfinding and driving behaviors. This structure includes a variety of fields that dictate everything from the current path node to the vehicle's cruising speed and destination coordinates.Key Fields and Their Uses:
-
Node Addresses and Pathfinding:
currentAddress,startingRouteNode: These fields use theCNodeAddressstructure to denote positions within the path network.nCurrentPathNodeInfo,nNextPathNodeInfo,nPreviousPathNodeInfo: These useCCarPathLinkAddressand indicate the current, next, and previous path nodes being used for guidance.
-
Speed and Behavior Controls:
nSpeedScaleFactor: This could scale the speed according to certain factors.fMaxTrafficSpeed,nCruiseSpeed: Control the maximum allowed speed and a predefined cruising speed.nCarDrivingStyle,nCarMission: Dictate the driving style and mission behavior of the vehicle.
-
Control Flags and Lanes:
nCarCtrlFlags: Bit flags that might enable or disable specific control features.nCurrentLane,nNextLane: Manage the lane the vehicle is driving in and planning to move into.
-
Behavior Timing:
nTimeToStartMission,nTempActionTime: Timing for mission start or temporary actions.
-
Destination Coordinates:
vecDestinationCoors: Avector3drepresenting the target position the autopilot is trying to reach.
-
Interactions:
pTargetCar,pCarWeMakingSlowDownFor: Pointers to other vehicles/entities, possibly to interact with or avoid.
Example Usage in Lua FFI:
Here's how you might use the Lua FFI to access and manipulate
CAutoPilot:-- Access a CVehicle instance (ensure this retrieval is properly managed in your code) local vehicle = samem.cast("CVehicle *", carPointer) if vehicle ~= samem.nullptr then local autoPilot = vehicle.autoPilot if autoPilot ~= nil then -- Example: Change the car mission autoPilot.nCarMission = newMissionValue -- Example: Set a new cruising speed autoPilot.nCruiseSpeed = newCruiseSpeedValue -- Example: Set a new destination autoPilot.vecDestinationCoors.x = newX autoPilot.vecDestinationCoors.y = newY autoPilot.vecDestinationCoors.z = newZ end endImportant Considerations:
- Structure Validity: Ensure the
CAutoPilotstructure definition matches the actual memory layout used by the game to avoid crashes or unintended behavior. - Game State Influence: Changes in autopilot configurations may significantly affect game behavior, such as NPC driving styles and mission executions.
- Testing: Always test to confirm that changes reflect correctly and do not introduce bugs or errors in gameplay.
This approach allows programmatic adjustments of autopilot features, enabling diverse modifications or enhancements within the game framework.
-