SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 15/10/2014, 11:59 PM   #1
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,412
Reputation: 439
Default GetObjectOffset - Get an object's offset to: player, vehicle or object

This is a very basic include which detects offsets of objects in regards to either a player, - a vehicle or another object. It's calculated using very simple math calculations to find the offset. The offset's are passed by reference. You can also get the same thing for dynamic objects(using the streamer plug-in).

pawn Code:
public GetObjectOffset(objectid, extraid, extratype, &Float: oX, &Float: oY, &Float: oZ, &Float: orZ)
pawn Code:
public GetDynamicObjectOffset(objectid, extraid, extratype, &Float: oX, &Float: oY, &Float: oZ, &Float: orZ)
pawn Code:
public IsObjectInRangeOfPlayer(objectid, playerid, Float: radius)
pawn Code:
public IsDynamicObjectInRangeOfPlayer(objectid, playerid, Float: radius)

pawn Code:
public GetObjectOffsetFromPoint(objectid, Float: pos[0], Float: pos[1], Float: pos[2], &Float: oX, &Float: oY, &Float: oZ);
pawn Code:
public GetDynamicObjectOffsetFromPoint(objectid, Float: pos[0], Float: pos[1], Float: pos[2], &Float: oX, &Float: oY, &Float: oZ);

Params:
- objectid: The base object you're getting the offset from.
- extraid: The extra ID relevative to the extratype specified. This could be a : playerID, vehicleID, or an object ID.
- extratype: The type of "thing" you're getting the offset from relevative to the extraID.
- Extra Types:
EXTRA_TYPE_PLAYER 1
EXTRA_TYPE_VEHICLE 2
EXTRA_TYPE_OBJECT 3
- &Float: oX, &Float: oY, &Float: oZ, &Float: orZ: The variables that the data will be stored upon(values passed by reference).

If the extratype is invalid(or just 0/null) INVALID_EXTRA_ID(-1) gets returned. How-ever, - if the extraID is invalid correlating to the extratype it won't go through and will just return INVALID_EXTRA_ID aswell. Anything else will return true.

Download:
OPEN IN BROWSER(https)

Last edited by Abagail; 24/08/2015 at 03:17 PM.
Abagail is offline   Reply With Quote
Old 16/10/2014, 12:13 AM   #2
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,192
Reputation: 1241
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

GetDynamicObjectOffset() is using GetObjectPos() instead of GetDynamicObjectPos()
Pottus is offline   Reply With Quote
Old 16/10/2014, 12:16 AM   #3
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,412
Reputation: 439
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

Fail my mistake. Fixed.
Abagail is offline   Reply With Quote
Old 16/10/2014, 12:18 AM   #4
IDarkness
Huge Clucker
 
IDarkness's Avatar
 
Join Date: Jul 2014
Posts: 198
Reputation: 71
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

Good job evan
__________________
Its all about me.
IDarkness is offline   Reply With Quote
Old 16/10/2014, 12:22 AM   #5
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,192
Reputation: 1241
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

I have another function you could try get center of several objects.
Which is basically

centerx = (minx + maxx) / 2
centery = (miny + maxy) / 2
centerz = (minz + maxz) / 2
Pottus is offline   Reply With Quote
Old 16/10/2014, 01:50 AM   #6
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,412
Reputation: 439
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

Quote:
Originally Posted by Pottus View Post
I have another function you could try get center of several objects.
Which is basically

centerx = (minx + maxx) / 2
centery = (miny + maxy) / 2
centerz = (minz + maxz) / 2
For now I've added IsObjectInRangeOfPlayer, I'll see what I can do with this for the next update.
Abagail is offline   Reply With Quote
Old 22/10/2014, 11:11 PM   #7
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,412
Reputation: 439
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

Version 1.1.3:
- You can now get an(dynamic)object's offset from a certain point(coordinate). You can do this using GetObjectOffsetfromPoint for non-streamed objects, or GetDynamicObjectfromPoint for streamed(streamer) objects.
Abagail is offline   Reply With Quote
Old 23/10/2014, 01:02 AM   #8
Iillminetor1
Big Clucker
 
Join Date: May 2014
Location: Earth
Posts: 109
Reputation: 15
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

Good job, thank you.
__________________
"Fail To Prepare, Prepare To Fail""
Iillminetor1 is offline   Reply With Quote
Old 26/12/2014, 02:16 PM   #9
taxi0
Little Clucker
 
Join Date: Sep 2011
Posts: 2
Reputation: 0
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

Can anyone reupload it?
taxi0 is offline   Reply With Quote
Old 26/12/2014, 03:54 PM   #10
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,412
Reputation: 439
Default Re: GetObjectOffset - Get an object's offset to: player, vehicle or object

Updated.
- Rewrote entire include.

The new version of this include can be found here:
- Opens in Browser(.inc) -
Abagail 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
Aim an object to a player or vehicle kadaradam Scripting Help 0 22/04/2012 04:00 PM
[Tool/Web/Other] Object Offset Zezombia Tools and Files 3 06/11/2011 09:09 AM
how can i detect if a player is shooting at a vehicle + offset? Donya Help Archive 2 14/05/2011 01:49 AM
Offset And Object Loacations Problems [Just Some Error Messages! Please Help!] [HLF]Southclaw Help Archive 2 23/03/2011 05:09 AM


All times are GMT. The time now is 08:18 AM.


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