SA-MP Forums Archive
Need help with GetXYZInrear. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with GetXYZInrear. (/showthread.php?tid=243286)



Need help with GetXYZInrear. - Borg - 22.03.2011

Hi, I'm looking for a function GetXYZInrear. I used ****** and clambered many forums, but never found. I have GetXYInrearOfPlayer, but it does not return Z. If someone has this feature, please share.
P.S. Sorry for bad English


Re: Need help with GetXYZInrear. - Norck - 22.03.2011

Probably this plugin is what are you looking for: https://sampforum.blast.hk/showthread.php?tid=120013


Re: Need help with GetXYZInrear. - Borg - 22.03.2011

But I think GetXYZInrear will be better, especially since I can not spend a lot of RAM


Re: Need help with GetXYZInrear. - Norck - 22.03.2011

You also can use player's current Z position. I don't see any way to get rear Z pos without that plugin.


Re: Need help with GetXYZInrear. - Borg - 22.03.2011

This feature exists and I wonder whether it is from someone


Re: Need help with GetXYZInrear. - dice7 - 22.03.2011

There is no other way. Use that plugin or use the players Z pos


Respuesta: Need help with GetXYZInrear. - [DOG]irinel1996 - 31.05.2012

Too late but:
pawn Код:
stock GetXYZInrear(Float:distance, Float:angle, Float:pitch, &Float:x, &Float:y, &Float:z)
{
    x -= (distance * floatsin(-angle, degrees));
    y -= (distance * floatcos(-angle, degrees));
    z -= (distance * floatsin(pitch, degrees));
}
Sorry for bumping...


Re: Need help with GetXYZInrear. - MP2 - 31.05.2012

If you want to get the position behind a vehicle, I made this:

pawn Код:
stock GetPosBehindVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=1.0)
{
    new Float:vehicleSize[3], Float:vehiclePos[3];
    GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
    GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, vehicleSize[0], vehicleSize[1], vehicleSize[2]);
    GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset);
    x = vehiclePos[0];
    y = vehiclePos[1];
    z = vehiclePos[2];
    return 1;
}

GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance)
{
    new Float:a;
    GetVehiclePos(vehicleid, q, w, a);
    GetVehicleZAngle(vehicleid, a);
    q += (distance * -floatsin(-a, degrees));
    w += (distance * -floatcos(-a, degrees));
}
If you want to get the position behind a PLAYER:

pawn Код:
GetXYBehindPlayer(playerid, &Float:q, &Float:w, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, q, w, a);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    else GetPlayerFacingAngle(playerid, a);
    q += (distance * -floatsin(-a, degrees));
    w += (distance * -floatcos(-a, degrees));
}