SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 25/08/2015, 07:19 PM   #1
IstuntmanI
High-roller
 
IstuntmanI's Avatar
 
Join Date: Mar 2009
Location: Romania
Posts: 1,801
Reputation: 375
Default Simulate "SyncRotation" positions

Hello,

As you may know, the AttachObjectToObject has a "SyncRotation" parameter, which changes the position of the attached object when the base object is rotated. When I try to get the position of the attached object, the old position (before attaching) is displayed (GetObjectPos), so I can't get the positions with attaching a object to the first one.

Basically, I need something like
pawn Code:
GetPosFromObjectOffset( objectid, Float:oX, Float:oY, Float:oZ, &Float:X, &Float:Y, &Float:Z );
(which simulates SyncRotation when set to 1, so it changes the returned position based on the specified offsets and also based on the objectid's position and ROTATION).

I think this is why Incognito is also fixing this problem: https://github.com/samp-incognito/sa...ugin/issues/68 . I think he can't manage to do this calculation.
__________________


IstuntmanI is offline   Reply With Quote
Old 25/08/2015, 07:30 PM   #2
Spmn
Gangsta
 
Join Date: Jun 2015
Location: Romania
Posts: 490
Reputation: 131
Default Re: Simulate "SyncRotation" positions

Code:
stock GetAttachedObjectPos(Float: object_px, Float: object_py, Float: object_pz, Float: object_rx, Float: object_ry, Float: object_rz, Float:offset_x, Float:offset_y, Float:offset_z, &Float:x, &Float:y, &Float:z)
{
    new Float:cos_x = floatcos(object_rx, degrees),
        Float:cos_y = floatcos(object_ry, degrees),
        Float:cos_z = floatcos(object_rz, degrees),
        Float:sin_x = floatsin(object_rx, degrees),
        Float:sin_y = floatsin(object_ry, degrees),
        Float:sin_z = floatsin(object_rz, degrees);
    x = object_px + (offset_x * cos_z * cos_y) - (offset_x * sin_x * sin_y * sin_z) - (offset_y * sin_z * cos_x) + (offset_z * cos_z * sin_y) + (offset_z * sin_x * cos_y * sin_z);
    y = object_py + (offset_x * sin_z * cos_y) + (offset_x * sin_x * sin_y * cos_z) + (offset_y * cos_z * cos_x) + (offset_z * sin_z * sin_y) - (offset_z * sin_x * cos_y * cos_z);
    z = object_pz - (offset_x * sin_y * cos_x) + (offset_y * sin_x) + (offset_z * cos_y * cos_x);
}
I think this is what you need. However, I don't remember who came up with this function, maybe it's from Southclaw's SS gamemode.
Spmn is offline   Reply With Quote
Old 25/08/2015, 08:51 PM   #3
IstuntmanI
High-roller
 
IstuntmanI's Avatar
 
Join Date: Mar 2009
Location: Romania
Posts: 1,801
Reputation: 375
Default Re: Simulate "SyncRotation" positions

Yes, it's exactly what I wanted. Shame on me that I didn't know how to search that function by name, the name is pretty obvious.

Thanks.
__________________


IstuntmanI is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error 032: array index out of bounds (variable "Positions") Drago987 Scripting Help 3 22/11/2013 12:18 PM
error: undefine symbol "j" and expected token ";" but found "]" JEkvall95 Scripting Help 9 27/07/2013 11:09 AM
5 Dialog errors - Input line too long, undefined symbol "t","is" and "only" Deal-or-die Scripting Help 6 01/05/2012 01:08 PM
Annoying "bug" with vehicle positions Outbreak Help Archive 1 12/09/2009 08:21 PM


All times are GMT. The time now is 11:19 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.