CarSpawn Problem (floatsin , floatcos)
#1

Hello Community,
can someone help me ?
I want to create a Car allways spawn behind a player but it wont works.

pawn Код:
dcmd_car(playerid, params[])
#pragma unused params
{
    new Float:X, Float:Y, Float:Z, Float:A;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    X = X + floatsin(A,-degrees);
    Y = Y + floatcos(A,-degrees);
    CreateVehicle(411, X, Y-2.0, Z, A, -1, -1, -1);
    return 1;
}
I dont get any Errors / Warnings,

can someone help me to get it working so the car sill spawn behind me ?
Reply
#2

pawn Код:
stock GetXYBehindPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x2, y2, a);
    GetPlayerFacingAngle(playerid, a);
    if(GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    x2 += (distance * floatsin(-a+180, degrees));
    y2 += (distance * floatcos(-a+180, degrees));
}
Maybe it'll help you. Give a try! :3

PD: I didn't make it. I don't know who.
Reply
#3

Here, try this:
pawn Код:
dcmd_car(playerid, params[])
{
    #pragma unused params
    new
        Float:X,
        Float:Y,
        Float:Z,
        Float:A;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    X += (3.0 * floatsin(-A+180, degrees));
    Y += (3.0 * floatcos(-A+180, degrees));
    //----^
    // Change this to your desired distance
    CreateVehicle(411, X, Y, Z, A, 0, 0, -1);
    return 1;
}
Reply
#4

Nope i played around abit and found my Fail!
Thanks irinel1996 ^^

Solution:
pawn Код:
#removed
Reply
#5

Nice code extraction. xD
Glad that you could fix it.
Reply
#6

Yep i tryed about 2 weeks to get it now o.O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)