SA-MP Forums Archive
Need SetCameraInFrontOfPlayer - 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 SetCameraInFrontOfPlayer (/showthread.php?tid=482292)



Need SetCameraInFrontOfPlayer - RedSnow - 20.12.2013

hey guys, I need the stock SetCameraInFrontOfPlayer. (The opposite from the function SetCameraBehindPlayer(playerid).

Thanks.


Re: Need SetCameraInFrontOfPlayer - Stuffs - 20.12.2013

You mean this?
pawn Код:
stock SetCameraInFrontOfPlayer(PlayerID, Float: Distance = 2.5, Float: Lift = 0.5) {
    if(IsPlayerConnected(PlayerID)) return false;
   
    new Float: X,
        Float: Y,
        Float: Z,
        Float: A;
    GetPlayerPos(PlayerID, X, Y, Z);
    if(IsPlayerInAnyVehicle(PlayerID)) {
        GetVehicleZAngle(GetPlayerVehicleID(PlayerID), A);
    } else {
        GetPlayerFacingAngle(PlayerID, A);
    }
    // GetPlayerPosition(PlayerID, W, I, X, Y, Z, A);

    SetPlayerCameraLookAt(playerid, X, Y, Z);

    // Credits to ****** for the GetXYInFrontOfPlayer function.
    X += (Distance * floatsin(-A, degrees));
    Y += (Distance * floatcos(-A, degrees));

    SetPlayerCameraPos(playerid, X, Y, (Z + Lift));
    return true;
}
EDIT: Credits to TheLazySloth.


Re: Need SetCameraInFrontOfPlayer - RedSnow - 20.12.2013

Quote:
Originally Posted by Stuffs
Посмотреть сообщение
You mean this?
pawn Код:
stock SetCameraInFrontOfPlayer(PlayerID, Float: Distance = 2.5, Float: Lift = 0.5) {
    if(IsPlayerConnected(PlayerID)) return false;
   
    new Float: X,
        Float: Y,
        Float: Z,
        Float: A;
    GetPlayerPos(PlayerID, X, Y, Z);
    if(IsPlayerInAnyVehicle(PlayerID)) {
        GetVehicleZAngle(GetPlayerVehicleID(PlayerID), A);
    } else {
        GetPlayerFacingAngle(PlayerID, A);
    }
    // GetPlayerPosition(PlayerID, W, I, X, Y, Z, A);

    SetPlayerCameraLookAt(playerid, X, Y, Z);

    // Credits to ****** for the GetXYInFrontOfPlayer function.
    X += (Distance * floatsin(-A, degrees));
    Y += (Distance * floatcos(-A, degrees));

    SetPlayerCameraPos(playerid, X, Y, (Z + Lift));
    return true;
}
EDIT: Credits to TheLazySloth.
yes, but this stock not working.