29.07.2011, 14:21
I didn't understand you fully, but try this:
pawn Код:
stock SetPlayerCameraInFrontOfPlayer(playerid, Float:distance, Float:heightoffset) // iPLEOMAX
{
new Float:P[3];
GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerCameraLookAt(playerid, P[0], P[1], P[2]);
GetXYInFrontOfPlayer(playerid, P[0], P[1], distance);
SetPlayerCameraPos(playerid, P[0], P[1], P[2]+heightoffset);
}
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{ // Created by ******
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); }
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
pawn Код:
//Example usage:
public OnPlayerSpawn(playerid)
{
SetPlayerCameraInFrontOfPlayer(playerid, 6, 2);
}