[Ajuda] funcao GetPlayerVehicleSide do ipsbruno
#1

Bom fui usar essa funcao pra pegar os lados do veiculo, mas nao ta pegando os lados corretos, nao sei se й um erro de atencao ou sl, voces podem dar uma olhada e ver se estou usando certo? outra coisa sempre aparece c trancado e nunca aberto..

eu botei o c na frente para diferenciar do portamalas.. alem disso o portamalas a parte de tras do carro fina proximo as rodas da frente do veiculo -'

pawn Код:
if(GetPlayerVehicleSide(playerid, i) == VEHICLE_LEFT || VEHICLE_RIGHT == GetPlayerVehicleSide(playerid, i)) {
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(playerVeiculo[playerid][i][veiculoVeiculo], engine, lights, alarm, doors, bonnet, boot, objective);
    if(doors == 0) {
        doors = 1;
        playerVeiculo[playerid][a][veiculoPorta] = true;
        SetVehicleParamsEx(playerVeiculo[playerid][i][veiculoVeiculo], engine, lights, alarm, doors, bonnet, boot, objective);
        GameTextForPlayer(playerid, "c TRANCADO", 1000, 6);
        return true;
    }
    else if(doors == 1) {
        doors = 0;
        playerVeiculo[playerid][a][veiculoPorta] = false;
        SetVehicleParamsEx(playerVeiculo[playerid][i][veiculoVeiculo], engine, lights, alarm, doors, bonnet, boot, objective);
        GameTextForPlayer(playerid, "c ABERTO", 1000, 6);
        return true;
    }
    break;
}

funcao

pawn Код:
stock GetPlayerVehicleSide(playerid, vehicleid) {
        static Float:x[5],Float:y[5],Float:z[5];
 
        GetPosBetweenVehicle(vehicleid, x[0], y[0], z[0],.dangle = -180.0); // atras
        GetPosBetweenVehicle(vehicleid, x[1], y[1], z[1],.dangle = -000.0); // frente
        GetPosBetweenVehicle(vehicleid, x[2], y[2], z[2],.dangle = -090.0); // esquerda
        GetPosBetweenVehicle(vehicleid, x[3], y[3], z[3],.dangle =  090.0); // direita
 
        z[0] = GetPlayerDistanceFromPoint(playerid, x[0], y[0], z[0]);
        z[1] = GetPlayerDistanceFromPoint(playerid, x[1], y[1], z[1]);
        z[2] = GetPlayerDistanceFromPoint(playerid, x[2], y[2], z[2]);
        z[3] = GetPlayerDistanceFromPoint(playerid, x[3], y[3], z[3]);
 
        if(z[0]<z[1])
        if(z[0]<z[2])
        if(z[0]<z[3])
        return VEHICLE_BACK;
 
        if(z[1]<z[2])
        if(z[1]<z[3])
        return VEHICLE_FRONT;
 
 
        if(z[2]<z[3])
        return VEHICLE_LEFT;
 
        return VEHICLE_RIGHT;
 
}
stock GetPosBetweenVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5, Float:dangle = 0.0) {
        new Float:vehicleSize[3], Float:vehiclePos[3];
        GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
        GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, vehicleSize[0], vehicleSize[1], vehicleSize[2]);
        GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset, dangle);
        x = vehiclePos[0];
        y = vehiclePos[1];
        z = vehiclePos[2];
        return 1;
}
stock GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance, Float:dangle = 0.0) {
        new Float:a;
        GetVehiclePos(vehicleid, q, w, a);
        GetVehicleZAngle(vehicleid, a);
        q += (distance * -floatsin(-a-dangle, degrees));
        w += (distance * -floatcos(-a-dangle, degrees));
}
Reply
#2

UP !!
Reply
#3

eu nao entendi bem o que tu quer para ser sincero.

porem olha esta funcao do mauzen e ve se й isto que tu quer:

pawn Код:
stock GetVehicleRelativePos(vehicleid, &Float:x, &Float:y, &Float:z, Float:xoff=0.0, Float:yoff=0.0, Float:zoff=0.0)
{
    new Float:rot;
    GetVehicleZAngle(targetid, rot);
    rot = 360 - rot;    // Making the vehicle rotation compatible with pawns sin/cos
    GetVehiclePos(vehicleid, x, y, z);
    x = floatsin(rot,degrees) * yoff + floatcos(rot,degrees) * xoff + x;
    y = floatcos(rot,degrees) * yoff - floatsin(rot,degrees) * xoff + y;
    z = zoff + z;

    /*
       where xoff/yoff/zoff are the offsets relative to the vehicle
       x/y/z then are the coordinates of the point with the given offset to the vehicle
       xoff = 1.0 would e.g. point to the right side of the vehicle, -1.0 to the left, etc.
    */

}

//Examples:
GetVehicleRelativePos(vehicleid, x, y, z, 1.0, 1.0, 0.0);
    // xoff = 1 -> go 1m to the right side of the vehicle
    // yoff = 1 -> go 1m to the front of the vehicle
    // so this would return about the coordinates of the the front right tire of the car

GetVehicleRelativePos(vehicleid, x, y, z, 0.0, -3.0, 0.0);
    // xoff = 0 -> no change, stay between the driver and passenger seat
    // yoff = -3.0 -> go 3m back to the vehicle
    // so this would return the coordinates near the trunk of the vehicle
Reply
#4

Tipo, eu quero pegar os lados.. e a parte de tras do carro, assim quando ele tiver atras do carro abre o portamalas, quando estiver na frente abre e fecha as portas.. entendeu?


queria saber como pegar os lados do veiculo
Reply
#5

essa funcao acima faz isso

pawn Код:
GetVehicleRelativePos(vehicleid, x, y, z, 1.0, 1.0, 0.0);
    // xoff = 1 -> go 1m to the right side of the vehicle
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)