04.07.2018, 00:37
Resoluзгo do seu problema:
Nгo compilei com o seu comando, mas testei com um que fiz:
Lembrando que 'testVehicle' foram os veнculos de testes utilizados.
PHP код:
/// <summary>
/// Obtйm a posiзгo X e Y de N metros a frente de um ponto especнfico.
/// </summary>
/// <param name="x">Posiзгo X.</param>
/// <param name="y">Posiзгo Y.</param>
/// <param name="angle">Angulo.</param>
/// <param name="distance">Distвncia.</param>
/// <returns>Nгo retorna valores.</returns>
stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
{
x += (distance * floatsin(-angle, degrees));
y += (distance * floatcos(-angle, degrees));
}
CMD:meuscarros(playerid,params[])
{
if(IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid,Vermelho,"ERRO: Vocк jб estб em um carro");
if(PlayerInfo[playerid][NoDuelo] == 1)
return SendClientMessage(playerid,Vermelho,"ERRO: Vocк estб em um duelo");
if(PlayerInfo[playerid][NoEvento] == 1)
return SendClientMessage(playerid,Vermelho,"ERRO: Vocк estб em um evento");
if(PlayerInfo[playerid][NaCadeia] == 1)
return SendClientMessage(playerid,Vermelho,"WTF! Vocк estб preso");
new Float:posX,
Float:posY,
Float:posZ,
Float:angle
;
GetPlayerPos(playerid, posX, posY, posZ);
GetPlayerFacingAngle(playerid, angle);
GetXYInFrontOfPoint(posX, posY, angle, 6.0);
SetVehiclePos(PegarCarroID(PlayerInfo[playerid][C1]), posX, posY, posZ);
SetVehicleZAngle(PegarCarroID(PlayerInfo[playerid][C1]), angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, 4.0);
SetVehiclePos(PegarCarroID(PlayerInfo[playerid][C2]), posX, posY, posZ);
SetVehicleZAngle(PegarCarroID(PlayerInfo[playerid][C2]), angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, -8.0);
SetVehiclePos(PegarCarroID(PlayerInfo[playerid][C3]), posX, posY, posZ);
SetVehicleZAngle(PegarCarroID(PlayerInfo[playerid][C3]), angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, -4.0);
SetVehiclePos(PegarCarroID(PlayerInfo[playerid][C4]), posX, posY, posZ);
SetVehicleZAngle(PegarCarroID(PlayerInfo[playerid][C4]), angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, 16.0);
SetVehiclePos(PegarCarroID(PlayerInfo[playerid][C5]), posX, posY, posZ);
SetVehicleZAngle(PegarCarroID(PlayerInfo[playerid][C5]), angle + 180.0);
return 1;
}
PHP код:
/// <summary>
/// Comando para alinhar cinco veнculos especнficos lado a lado.
/// </summary>
/// <param name="playerid">ID do jogador.</param>
/// <returns>Nгo retorna valores especнficos.</returns>
CMD:test(playerid)
{
new Float:posX,
Float:posY,
Float:posZ,
Float:angle
;
GetPlayerPos(playerid, posX, posY, posZ);
GetPlayerFacingAngle(playerid, angle);
GetXYInFrontOfPoint(posX, posY, angle, 6.0);
SetVehiclePos(testVehicle[0], posX, posY, posZ);
SetVehicleZAngle(testVehicle[0], angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, 4.0);
SetVehiclePos(testVehicle[1], posX, posY, posZ);
SetVehicleZAngle(testVehicle[1], angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, -8.0);
SetVehiclePos(testVehicle[2], posX, posY, posZ);
SetVehicleZAngle(testVehicle[2], angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, -4.0);
SetVehiclePos(testVehicle[3], posX, posY, posZ);
SetVehicleZAngle(testVehicle[3], angle + 180.0);
GetXYInFrontOfPoint(posX, posY, angle + 90.0, 16.0);
SetVehiclePos(testVehicle[4], posX, posY, posZ);
SetVehicleZAngle(testVehicle[4], angle + 180.0);
return 1;
}