Set Object Position

qICEp

Member
Joined
Oct 5, 2014
Messages
13
Reaction score
0
Hey guys how to set specific object rotation using samp funcs?

I understand i need to use:
Code:
SF->getSAMP()->getInfo()->pPools->pObject->GetObjectHandleByID(objectid);
But it returns DWORD (probably pointer) but to what? how to set its position and rotation?
I even tried calling cleo opcodes from C++ just to set object's pos but no luck as i always crash (probably doing something wrong).
 

y0mike

Active member
Joined
May 10, 2014
Messages
97
Reaction score
41
Location
mizus girl's house
don't use SAMPFUNCs, but assuming that its returning pGTAEntity or ulGTAEntityHandle
Code:
template <typename T>
struct stSAMPEntity
{
	void		*pVTBL;
	uint8_t		byteUnk0[60]; // game CEntity object maybe. always empty.
	T			*pGTAEntity;
	uint32_t	ulGTAEntityHandle;
};
struct stObject : public stSAMPEntity < object_info >
{
	uint8_t				byteUnk0[2];
	uint32_t			ulUnk1;
	int					iModel;
	uint16_t			byteUnk2;
	float				fDrawDistance;
	float				fUnk;
	float				fPos[3];
	uint8_t				byteUnk3[68];
	uint8_t				byteUnk4;
	float				fRot[3];
	// ...
};

you can set the position using CPlaceable::SetPosn (0x420B80)

so u can try this
Code:
void* pObject = (void*)SF->getSAMP()->getInfo()->pPools->pObject->GetObjectHandleByID(objectid);
reinterpret_cast<void (__thiscall *)(void*, CVector const&)>(0x4241C0)(pObject,  PositionVector );
not sure what you would need it for anyways.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
SAMPFUNCS uses MTA interface, cast the return to a CEntity*. And use SetPosition and SetOrientation methods.
 

qICEp

Member
Joined
Oct 5, 2014
Messages
13
Reaction score
0
springfield said:
SAMPFUNCS uses MTA interface, cast the return to a CEntity*. And use SetPosition and SetOrientation methods.

Could you please give example? I tried with CEntety but always crash (pretty sure im getting handle the wrong way)
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
I'm not sure, never really used MTA/SF and i'm not sure what GetObjectHandle returns. 
Try like this, ofc. make sure whatever GetObjectHandle returns is valid.

[shcode=cpp]
((CEntity*)test)->SetPosition(posn);
[/shcode]
 
Top