How do I calculate the gta cords from objects/car offsets?
#1

How do I calculate the GTA cords from objects/car offsets?

For example how do I calculate the GTA cords from this offset: 1.051757,-2.713012,-0.012840 if the cars GTA cords are: -1377.2820,-256.9163,14.0373,328.7105

I have tried something like this:
x += (tmpX * floatsin(-angle, degrees));
x += (tmpX * floatcos(-angle, degrees));
y += (tmpY * floatsin(-angle, degrees));
y += (tmpY * floatcos(-angle, degrees));

But it didn't work.
Reply
#2

Not really 0.3z relevant, try scripting help section.
Reply
#3

Quote:
Originally Posted by KyleSmith
View Post
Not really 0.3z relevant, try scripting help section.
Yeah you're sort of right I had OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ); in my mind the whole time.
Reply
#4

Just add the offset to the coordinate. Simples.
Reply
#5

Quote:
Originally Posted by MP2
View Post
Just add the offset to the coordinate. Simples.
Thank you but I'm already doing this and it's only working when the angel is 0. If the angel is not 0 but instead like my example 328.7105 it will not work.
Reply
#6

Not.

This will only work if your angle is 0.0.
Reply
#7

Quote:
Originally Posted by kurta999
View Post
Not.

This will only work if your angle is 0.0.
But I should be able to make some calculations from the offsets and the angel to get to the real cords? If not why? I mean I got the cars cords and it's angel + the offset. I can't understand why you can't calculate the real GTA cord from that.
Reply
#8

I replyed for this:

Just add the offset to the coordinate. Simples.

Anyway, I found this:

http://forum.sa-mp.com/showthread.ph...68#post2854568
Reply
#9

Non-sense
Reply
#10

Ok I worked this out over several hours and found it's actually very very easy to do.

You'll need this by GamerZ
http://gpb.******code.com/svn/trunk/...icleMatrix.inc

Here is some test code.

pawn Code:
#include <a_samp>
#include <vmatrix>

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(hittype == BULLET_HIT_TYPE_VEHICLE)
    {
        new tmp, Float:x, Float:y, Float:z;

        // This will get the world offset based on vehicle rotation and return the
        // correct position to spawn an object
        PositionFromVehicleOffset(hitid,fX,fY,fZ, x, y, z);
        tmp = CreateObject(1974, x, y, z, 0.0, 0.0, 300.0);

        // Simple attach offsets are automatically calculated you just need to supply a offset for some objects
        AttachObjectToVehicle(tmp, hitid, fX,fY,fZ, 0.0, 0.0, 0.0);

        SetTimerEx("RemoveObject", 9000, false, "i", tmp);

    }
    return 1;
}

forward RemoveObject(id);
public RemoveObject(id)
{
    DestroyObject(id);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)