Quick help
#1

pawn Код:
GetPlayerPos(playerid, x, y, z);
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
So basically I just want to know how to make this object get position infront of you about 1 (foot? idk what the measurement system is)
Reply
#2

So you want to create the object infront of the player?
Reply
#3

pawn Код:
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));
}
GetXYInFrontOfPlayer(playerid,x,y,1.0);
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
Reply
#4

Quote:
Originally Posted by FarSe.
Посмотреть сообщение
pawn Код:
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));
}
GetXYInFrontOfPlayer(playerid,x,y,1.0);
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
I've never seen that function, nor know where to put the coding at to be honest. :S

Reading about it saying it's a stock function, still getting errors. Gonna figure this out though.
Reply
#5

The function below, put it somewhere above the code you posted. It must go above that code.
pawn Код:
stock Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    else GetPlayerFacingAngle(playerid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
    return a;
}
Then your code:

pawn Код:
GetPlayerPos(playerid, x, y, z);//This is important
GetXYInFrontOfPlayer(playerid,x,y,1.0);//Make sure this goes below GetPlayerPos (just so it overwrites X and Y because we'll be using Z)
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
Well it would create the object infront of the player.
Reply
#6

Can i troll here Oh? Thanks
Reply
#7

Use SA-MP Default Function GetPlayerCameraFrontVector..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)