Vehicle Zangle calculations problem
#3

Two methods:

1) Create ready-made slots for spawn x,y,z,za for all racers.

2) Automatic: (Note: Will be buggy if the surface isn't flat)

pawn Код:
#define OPPONENT_FRONT  0
#define OPPONENT_BACK   180
#define OPPONENT_LEFT   90
#define OPPONENT_RIGHT  270

stock GetOpponentPositionFrom(vehicleid, direction, Float:offset, &Float:X, &Float:Y, &Float:Z, &Float:ZA)
{   //iPLEOMAX

    GetVehiclePos(vehicleid, X, Y, Z);
    GetVehicleZAngle(vehicleid, ZA);

    X += offset * floatsin(-(ZA+direction), degrees);
    Y += offset * floatcos(-(ZA+direction), degrees);
}
Appropriate offset for FRONT/BACK would be 8 and for LEFT/RIGHT is 5.

Usage:
pawn Код:
CMD:createracer(playerid, params[])
{
    new Float:X, Float:Y, Float:Z, Float:ZA;
    switch(strval(params))
    {
        case 0: GetOpponentPositionFrom(GetPlayerVehicleID(playerid), OPPONENT_FRONT, 5, X, Y, Z, ZA);
        case 1: GetOpponentPositionFrom(GetPlayerVehicleID(playerid), OPPONENT_BACK, 5, X, Y, Z, ZA);
        case 2: GetOpponentPositionFrom(GetPlayerVehicleID(playerid), OPPONENT_LEFT, 5, X, Y, Z, ZA);
        case 3: GetOpponentPositionFrom(GetPlayerVehicleID(playerid), OPPONENT_RIGHT, 5, X, Y, Z, ZA);
    }
    CreateVehicle(400, X, Y, Z, ZA, -1, -1, 0);
    return true;
}
Output:



And remember that you can enter custom direction angle (45) to make diagonal positions!
Reply


Messages In This Thread
Vehicle Zangle calculations problem - by Warfish - 11.02.2012, 15:57
Re: Vehicle Zangle calculations problem - by Warfish - 11.02.2012, 18:32
Re: Vehicle Zangle calculations problem - by iPLEOMAX - 11.02.2012, 18:55
Re: Vehicle Zangle calculations problem - by Warfish - 11.02.2012, 18:58
Re: Vehicle Zangle calculations problem - by Warfish - 11.02.2012, 19:38
Re: Vehicle Zangle calculations problem - by iPLEOMAX - 11.02.2012, 19:46
Re: Vehicle Zangle calculations problem - by Warfish - 11.02.2012, 19:49

Forum Jump:


Users browsing this thread: 2 Guest(s)