SetVehicleZAngle(Question)
#1

hey all, this is probably a really silly question but i was wondering if there is any possible way to make players vehicle or rather alot of vehicles that players are currently driving face a certain position X,Y,Z?

for example i am currently working on a Destruction Derby - Blood Bowl Event (last man standing),
an i just need to find a way to make all the players cars face the center of the Blood Bowl.
"-1406.9946,993.5972,1024.0857"

or somehow define this x,y,z as the BloodBowlCenter or something similar?

thanks.
Reply
#2

There are functions already , they end with PointTo , like PlayerPointToPos etc.. you can use the search button But i'll search a bit around too for you as finding the correct function can be due to failures in formulas so you won't get the right angle.
It's mainly using sinus and cosine or tangens. nothing hard teoritically.

Edit : I got the function somewhere in my camerazoom? lemme search my pc..

Edit 2 : I think I have to wait before I am @ my own pc. All my script aren't on my USB ~.~
Reply
#3

Thanks, very much appreciated im going to keep trying
Reply
#4

pawn Код:
#include <a_samp>

enum CalcPos {
    Float:X,
    Float:Y,
    Float:Z
}
public OnFilterScriptInit(){
    print("0");
    new Float:ddd[3];
    print("1");
    CalcPsBtwnPssWhDst(3.0,4.0,5.0,9.0,7.0,10.0,2.23, ddd[0], ddd[1], ddd[2]);// By Gamer_Z!!!!!!!!!!!!! Credits to unknown for "yaw/pitch", and MadeMan for helping
    print("2");
    new Float:vv,Float:vvv,Float:vvp,Float:aa;
    print("3");
    vv = ddd[0]+ddd[1]+ddd[2]+0.29269+27;
    print("4");
    vvv = 11634455+15919.0028807889235515962218448528;
    print("5");
    vvp = vv*vv;
    print("6");
    aa = vvp-vvv;
    print("7");
    printf("|%f|%f|%f|%f|",ddd[0],ddd[1],ddd[2],aa);
    print("8");
    nCalcPsBtwnPssWhDst(9,7,3,4,0);
    return 1;
}

/*
// if u don't have calcpos:
enum CalcPos {
    Float:X,
    Float:Y,
    Float:Z
}
*/

/*
stock CalcPsBtwnPssWhDst(Float:X1 ,Float:Y1 ,Float:Z1 ,Float:X2 ,Float:Y2 ,Float:Z2,Float:dist, &Float:rD1, &Float:rD2, &Float:rD3)// By Gamer_Z!!!!!!!!!!!!! Credits to unknown for "yaw/pitch", and MadeMan for helping
{



    new
        Float:A[CalcPos],
        Float:B[CalcPos],
        Float:C[CalcPos],
        Float:degreeC1,
        Float:degreeC2,
        Float:roznica,
        Float:CD,
        Float:AB,
        Float:CA,
        Float:CF,
        Float:FD;

    //start calculations, calculating position X Y Z of point D with the given 'dist', making a 'vitrual' triangle.

    C[X] = X1;
    C[Y] = Y1;
    C[Z] = Z1;

    B[X] = X2;
    B[Y] = Y2;
    B[Z] = Z2;

    A[X] = X1;
    A[Y] = Y1;
    A[Z] = Z2;

    CD = dist;

    AB = floatsqroot(floatpower(floatabs(floatsub(A[X], B[X])), 2) + floatpower(floatabs(floatsub(A[Y], B[Y])), 2) + floatpower(floatabs(floatsub(A[Z], B[Z])), 2));
    CA = floatsqroot(floatpower(floatabs(floatsub(C[X], A[X])), 2) + floatpower(floatabs(floatsub(C[Y], A[Y])), 2) + floatpower(floatabs(floatsub(C[Z], A[Z])), 2));

    degreeC1 = atan(AB/CA);
    degreeC2 = (90-degreeC1);

    CF = (floatcos(degreeC2,degrees)*dist);
    FD = floatsqroot((floatpower(CD,2)-floatpower(CF,2)));

    rD3 = ((CA-FD)+A[Z]);//we got the Z of position D

    roznica = atan2(-(X2-X1), (Y2-Y1));
   
    rD1 = dist*floatsin(-roznica, degrees)+X1;
    rD2 = dist*floatcos(-roznica, degrees)+Y1;
}
*/


stock CalcPsBtwnPssWhDst(Float:X1 ,Float:Y1 ,Float:Z1 ,Float:X2 ,Float:Y2 , Float:Z2, Float:dist, &Float:rD1, &Float:rD2, &Float:rD3)
{
    new Float:degreeC1,
        Float:roznica,
        Float:AB,
        Float:CA,
        Float:CF,
        Float:FD;

    AB = floatpower(((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2)+(Z1-Z2)*(Z1-Z2)), 0.5); //8411.896484
    CA = floatpower(((X1-X1)*(X1-X1)+(Y1-Y1)*(Y1-Y1)+(Z1-Z2)*(Z1-Z2)), 0.5); //109.000000 Z1-Z2 ?

    degreeC1 = atan(CA/AB); //0.742387

    CF = (floatcos(degreeC1, degrees)*dist); //99.991605
    FD = (floatsin(degreeC1, degrees)*dist); //1.295675

    rD3 = (CA-FD+Z2); //130.704424

    roznica = atan2((Y2-Y1),(X2-X1)); //-91.743949

    rD1 = floatsin(roznica, degrees)*CF+X1; //4906.054687
    rD2 = floatcos(roznica, degrees)*CF+Y1; //1078.956909
}

stock nCalcPsBtwnPssWhDst(Float:X1 ,Float:Y1 ,Float:Z1 ,Float:X2 ,Float:Y2 , Float:Z2, Float:dist, &Float:rD1, &Float:rD2, &Float:rD3)
{
    new Float:angle,Float:temp,Float:pitch;
    //temp = (Z1-Z2);
   
    angle = atan2(Y1-Y2,X1-X2);
    if(X1 > X2 && Y1 <= Y2){
        temp = angle + 90;
        pitch = pitch - 45;
    }
    else if(X1 <= X2 && Y1 < Y2){
        temp = 90 - angle;
        pitch = pitch - 45;
    }
    else if(X1 < X2 && Y1 >= Y2){
        temp = angle - 90;
        pitch = pitch - 45;
    }
    else if(X1 >= X2 && Y1 > Y2){
        temp = 270 - angle;
        pitch = pitch + 315;
    }
    if(Z1 < Z2)
        pitch = 360-pitch;
    }
       
    rD1 = (X1+dist*asin(temp,degrees));
    rD2 = (Y1+dist*acos(temp,degrees));
   
    printf("A: %f, A2: %f",angle,temp);
}

stock bCalcPsBtwnPssWhDst(Float:X1 ,Float:Y1 /*,Float:Z1*/ ,Float:X2 ,Float:Y2 /*, Float:Z2*/, Float:dist, &Float:rD1, &Float:rD2/*, &Float:rD3*/)
{
    new Float:angle,Float:temp;
    angle = atan2(Y1-Y2,X1-X2);
    if(X1 > X2 && Y1 <= Y2){
        temp = angle + 90;
    }
    else if(X1 <= X2 && Y1 < Y2){
        temp = 90 - angle;
    }
    else if(X1 < X2 && Y1 >= Y2){
        temp = angle - 90;
    }
    else if(X1 >= X2 && Y1 > Y2){
        temp = 270 - angle;
    }
    rD1 = (X1+dist*asin(temp,degrees));
    rD2 = (Y1+dist*acos(temp,degrees));
    printf("A: %f, A2: %f",angle,temp);
}
I don't know if this is the right one but I couldn't find any others on my desktop

Edit this code to suit your needs

pawn Код:
stock bCalcPsBtwnPssWhDst(Float:X1 ,Float:Y1 /*,Float:Z1*/ ,Float:X2 ,Float:Y2 /*, Float:Z2*/, Float:dist, &Float:rD1, &Float:rD2/*, &Float:rD3*/)
{
    new Float:angle,Float:temp;
    angle = atan2(Y1-Y2,X1-X2);
    if(X1 > X2 && Y1 <= Y2){
        temp = angle + 90;
    }
    else if(X1 <= X2 && Y1 < Y2){
        temp = 90 - angle;
    }
    else if(X1 < X2 && Y1 >= Y2){
        temp = angle - 90;
    }
    else if(X1 >= X2 && Y1 > Y2){
        temp = 270 - angle;
    }
    rD1 = (X1+dist*asin(temp,degrees));
    rD2 = (Y1+dist*acos(temp,degrees));
    printf("A: %f, A2: %f",angle,temp);
}
I think this is the one you need and more exact:
pawn Код:
new Float:angle,Float:temp;
    angle = atan2(Y1-Y2,X1-X2);
Reply
#5

Woah, i may have to read through that a bit to understand how it actually works before i try an use it but thank you very much for all your help.
i will post back an let you know how i go if i actually manage to get it lol!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)