SAMP/GetPlayerCameraFrontVector

Материал из WiKiPi

GetPlayerCameraFrontVector

Wiki added.png

Добавлено

функция работает только начиная с версии SA-MP 0.3a и не будет работать в предыдущих версиях!

Wiki note.png

Примечание

In 0.3a the camera front vector is only obtainable when player is inside a rhino, S.W.A.T tank, fire truck, or on foot.
Since 0.3b the camera data can be obtained when the player is in any vehicle or on foot.


Описание:

This function will return the current direction of player's aiming in 3-D space, the coords are relative to the camera position, see GetPlayerCameraPos.


Параметры:

(playerid, Float:x, Float:y, Float:z)


Тип данных Параметр Описание параметра
int playerid ID игрока, направление вектора камеры которого необходимо узнать.
float x Координата направления камеры по оси X.
float y Координата направления камеры по оси Y.
float z Координата направления камеры по оси Z.


Возвращаемые значения:

x, y, z - координаты, занесённые по ссылкам в переменные.


Пример использования:

// A simple command to manipulate this vector using the
// positions from GetPlayerCameraPos. This command will create
// a hydra missile in the direction of where the player is looking.
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/test camera vector"))
    {
        new Float:fPX, Float:fPY, Float:fPZ, Float:fVX, Float:fVY, Float:fVZ, Float:object_x, Float:object_y, Float:object_z;
        // Change me to change the scale you want. A larger scale increases the distance from the camera.
        // A negative scale will inverse the vectors and make them face in the opposite direction.
        const Float:fScale = 5.0;
        GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
        GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
        object_x = fPX + floatmul(fVX, fScale);
        object_y = fPY + floatmul(fVY, fScale);
        object_z = fPZ + floatmul(fVZ, fScale);
        CreateObject(345, object_x, object_y, object_z, 0.0, 0.0, 0.0);
        return 1;
    }
    return 0;
}


Связанные функции

Следующие функции также могут быть полезны, поскольку они так или иначе связаны с рассматриваемой функцией.